Avoid the issue of float right sections overlapping the wrapper

My issue is that the sections floated to the right are overlapping with the wrapper. How can I prevent this from happening?

I also attempted to use the float property within the nth-child(odd/even) of the CSS, but it didn't work as expected. I would appreciate some guidance on how to achieve this so that I can eliminate the need for float classes.

http://codepen.io/anon/pen/bdoQPQ

body,
html {
  font: 1em "Open Sans", sans-serif;
  margin: 0px;
  padding: 0px;
}

#wrapper {
  padding: 0px 10px 0px 10px;
  width: 100%;
}

.vertSection {
  width: 75%;
  height: 175px;
  border-top: 1px solid black;
  border-bottom: 1px solid black;
  margin: 0px 0px 15px 0px;
  padding: 5px 0px 0px 10px;
  box-shadow: 0px 3px 5px #888, 0px -3px 5px #888;
  display: inline-block;
}

.vertSection:nth-child(even) {
  float: left;
}

.vertSection:nth-child(odd) {
  float: right;
  text-align: right;
}

.vertSection p {
  text-align: left;
}

.vertSection img {
  line-height: 75px;
}

.floatL {
  float: left;
}

.floatR {
  float: right;
}

.clear {
  clear: both;
}
<section id="wrapper">
  <section>
    <h1>Header</h1>

    <p>This is where some information on my services would go.</p>
  </section>

  <section class="vertSection">
    <img src="images/html5css3.png" class="floatL">

    <h2>Heading</h2>

    <p>A bunch of text and description here!</p>
  </section>

  <section class="vertSection">
    <img src="images/responsive.png" class="floatR">
    <h2>Heading</h2>

    <p>A bunch of text and description here!</p>

  </section>

  <section class="vertSection">
    <img src="images/search.jpg" class="floatL">
    <h2>Heading</h2>

    <p>A bunch of text and description here!</p>
  </section>

  <section class="vertSection">
    <img src="images/communicate.png" class="floatR">

    <h2>Heading</h2>

    <p>A bunch of text and description here!.</p>
  </section>

</section class="">

Answer №1

The issue might be connected to this specific section.

#container {
    margin: 0 auto; /*top right bottom left*/
    width: 50%;
}

Therefore, 50% + 10px + 10px is causing the overflow, removing width:50% should resolve it. Additionally, it is recommended to add article {display:block;} for consistent rendering across different browsers.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Include a div with absolute positioning that fits within the visible browser window

My current project involves creating a graphical canvas map with tooltips, but I am facing a challenge. I need to ensure that the tooltips, which are absolute positioned divs, remain within the viewport. Unfortunately, I am having trouble achieving this. ...

Fixing the problem with Materialize drop-down menus

Here are some key details: The tool I'm currently utilizing: The current outcome displayed: https://i.sstatic.net/IRZHk.jpg The desired outcome to achieve: https://i.sstatic.net/N6Itv.jpg I have incorporated a dropdown feature into the navigation ...

Is it possible to execute HTML5/JS code without relying on the client side?

Looking to develop animations using HTML5 canvas and then convert them into a video by capturing each frame. The challenge lies in running the HTML5/JS code on the server side without requiring a client(browser). Is there a way to execute it without displ ...

A guide on mapping an array and removing the associated element

I have an array called responseData, which is used to display the available card options on the screen. public responseData = [ { id: 1399, pessoa_id: 75898, created_at: '2022-11-08T16:59:59.000000Z', holder: 'LEONARDO ', validade: ...

Is it possible to modify the underline color while using the transition property in CSS?

One of the challenges on my website is customizing the navigation bar to resemble the BBC navigation bar. I want to change the border bottom/underline color using transition elements. Can anyone provide guidance on modifying the code to achieve this look? ...

What is the best way to eliminate index.html from the homepage address?

I currently have a static website with 5 pages. The logo on my site contains a link to the homepage, which is index.html. Whenever I click on the logo, it redirects me to the homepage and changes the URL in the address bar to www.mydomain.com/index.html. ...

javascript Href and onclick malfunctioning

I am encountering an issue with a form on my webpage: <form name="myForm" id="myForm" method="post" action="someUrl.php"> ... </form> There is a div outside of this form which contains an anchor link: <a href="anotherUrl.php" onclick="doc ...

Arranging buttons in a horizontal row using Bootstrap 3

Please review the example provided below. Link to Example I am looking to have the <a> tag positioned next to Button 2. ...

Tips for ensuring that your website can recall which call-to-action (CTA) has been selected for redirection

I'm attempting to create a bilingual webpage in Spanish and English. My goal is to have a main page where the user selects the language, and once chosen, the page remembers the language preference for future visits instead of prompting the choice agai ...

Assigning a value to data-ng-model in JavaScript

I am facing a challenge in setting the data-ng-model attribute of an HTML input field using JavaScript. I have attempted to do it like this: element.data-ng-model = "..."; However, I realized that it doesn't work due to the presence of dashes. So, I ...

Searching for an attribute with no value in an HTML tag using Selenium: A step-by-step guide

Example: Radio - selected <input id="rdo" type="radio" name="nrdo" value="1" checked> Example: Radio - not selected <input id="rdo" type="radio" name="nrdo" value="1"> Searching for attributes without values in HTML tags using Selenium. ...

Use CSS to activate a sibling div when hovering over a button within the same div that contains the button

Is it possible to change the color of div #panel when hovering over the button #button inside div #left? #left #button:hover~#panel { background-color: blue; } #panel { position: absolute; float: r ...

Create a radial-gradient() that covers two separate elements

Seeking to create a spherical appearance for a circle made of two semi-circular divs using background: radial-gradient(). Any ideas on achieving this effect without combining the two semi-circle divs into one circular div? [The decision to use two semi-ci ...

develop a submission form using jquery

I am looking to create a submit action where clicking the submit button does not refresh the page. Instead, the data inputted in div1 will be sent to kanjiconverter.php and displayed in div2 using <?php echo $newkanji ?>. There are three forms on thi ...

The issue I'm facing involves Materialize CSS interfering with the rendering of input fields from PrimeNG. Does anyone have a solution to resolve

The code I am working with is as follows: <div class="container" style="width:100%;"> <div class="ui-widget-header" style="padding:4px 10px;border-bottom: 0 none"> <i class="fa fa-search" style="margin:4px 4px 0 0"></i> < ...

Selecting multiple options on a mobile device

I'm facing an issue that seems quite unusual. I created a multiple select form using bootstrap. On the mobile version through the browser console, all the information is being displayed correctly (screen1). However, when I try it on an actual mobile d ...

There is a hidden delete button obscured by another element. What steps can be taken to bring that element to the forefront and make it visible?

I'm having trouble positioning a delete button in the top right corner of a collapsible box. Despite setting it to `visibility: visible`, I can't seem to get it to display at the top of the collapsible element. Any suggestions or ideas would be g ...

Modifying the image width in Bootstrap: A step-by-step guide

When the screen is lg or larger, I would like my image to be full width (w-100), and when the screen is md or smaller, I want it to be half width (w-50). <div> <div class="container"> <div class="row"& ...

Preventing data loss upon submitting a form (PHP)

Currently, I have an HTML file that allows users to select appointment times for specific days of the week. Once they click submit, a PHP file generates and displays a calendar with the chosen times as checkboxes. My goal is to enable users to input their ...