Unusual placement of tags

I have organized two div tags within a container tag. The container is responsible for centering and fixing the content.

I am looking to create some space at the bottom of the webpage, separating 'home-segment' from the bottom of the browser window. However, I am encountering an issue where 'bottom-spacer' appears above 'home-segment'. How can I adjust it to sit below 'home-segment' as intended?

    <div class="container">

    // Content

    <div class="home-segment">
        <div class="col w33 col-first">
            <h2>A title</h2>
            <p>Lorem ipsum.</p>
        </div>
        <div class="col w33">
            <h2>Hey there.</h2>
        </div>
        <div class="col w33 col-last">
        </div>
    </div>

    <div class="bottom-spacer"></div>

</div>

CSS:

/* Home Page Columns */

.home-segment { width: 830px; float: left; }
.col.w33 { width: 220px; min-height: 200px; max-height: 200px; border: 1px solid #D9D4D4; background: #fff; margin-right: 15px; }
.col.w33 h2 { font-size: 18px; margin-bottom: 10px; }
.col { display: block; float: left; position: relative; overflow: hidden; padding: 10px; }

.bottom-spacer { padding-bottom: 25px; }

Answer №1

The content is moving to the top because there are floated elements that are not being cleared.

To fix this, simply add clear: both; to the .bottom-spacer CSS rule.

.bottom-spacer { clear: both;padding-bottom: 25px; background: #f00;}

See Demo


If you want a more in-depth explanation of why this is happening, check out my responses here and here.

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

Merge ReactCssTransitionGroup with React-route's Link to create smooth page transitions

React.js I'm facing an issue with the React.js code provided below. My goal is to set up the animation before transitioning to a new page using "React-router.Link" and ReactCSSTransitionGroup. Version: react: '15.2.1' react-addons-css-trans ...

"Experience the power of Angular.js through seamless animations created by blending the capabilities

I want to smoothly fade out the old view and fade in the new view. The challenge is that the new content must be positioned absolutely until the old one fades out. I also want to set a specific top position and height for the new content, but when I try to ...

Ways to enclose this text with a white border and apply a box-shadow

How can I modify text similar to this image and what is the process involved? https://i.sstatic.net/lFcGV.png ...

AngularJS fails to disable submit button despite 'Required' validation being implemented

I have an issue with my form where it still submits even if required fields are left empty. In Chrome, it shows a message to fill out text inputs but not dropdowns, and still proceeds to submit the form. Am I overlooking something obvious here? ...

Create a mobile-friendly version of the website that retains all the functionality and features of the desktop

Currently, I am in the process of optimizing my website for mobile devices. However, creating a separate subdomain and folder for a new mobile version is proving to be a challenge since it was not originally requested. How can I ensure that the website ap ...

seamless blending effect as the opacity transitions smoothly on an element with a applied filter

I've been working with a DIV that has a blur filter applied to it, and I'm attempting to smoothly "fade in" the DIV using CSS opacity (going from 0 to 1) with a one-second transition. However, even though the DIV does fade in, it's quite gli ...

Having trouble with my bootstrap slider carousel - it's just not cooperating

I incorporated Bootstrap's carousel to display the various courses on my website, featuring three courses at a time before transitioning to the next set of three. However, I am encountering an issue with this setup. Please see the image below for refe ...

Tips for displaying nested JSON arrays in HTML using Ember.js

I'm having trouble displaying the JSON data I get in app.js using HTML. Any suggestions? Here is the code for app.js (I am confident that $.post is returning valid JSON) App.CadeirasRoute = App.AuthenticatedRoute.extend({ model: function() { a ...

Using template expressions to access properties that contain spaces

Here is the code structure that I am working with: "name": { "age": [ { "data": { "how old": "23" } }, One of my JSON keys has a space in it. How can I access this pr ...

Attaching the CSS file to the Haml layout template

I'm currently working on linking a css file to a haml layout template Within the ApplicationHelper class, I have a method to properly generate html module ApplicationHelper def styletag(sheet_name) "<link rel='stylesheet' href=&a ...

Elevation navigation bar shift connections

I created a JavaScript navbar transition that changes the background color of the navbar as you scroll down. Everything seems to be working fine except for the navbar links. I assigned a new id to the links, but only the first link changes color and the ot ...

What is the method for creating parameterized xpath expressions?

I am facing an issue with a dropdown menu labeled "Select Work Area". The xpath keeps changing, and I need to parameterize it. How can I write a function that uses one xpath to call another? The current xpath is .//*[@id='step-content-2']/div/md ...

Issue with JavaScript input box not displaying text that has been typed

By using JavaScript, I am dynamically generating HTML text entry boxes. These input boxes are visible on the webpage and their border highlights when clicked. However, I am experiencing an issue where nothing appears in the input box as I type. Additional ...

Tips for adjusting the placeholder color in Material UI using React JS

Is there a way to customize the background color and flashing color of the Skeleton component in Material UI? I would like to implement custom styling for it, similar to what is shown below: <Skeleton variant="circle" classes={{root:'pla ...

Selecting a language by clicking on it

I recently designed a bootstrap navigation bar for my website and incorporated a language selection dropdown menu into it. <li class="nav-item dropdown"> <a class="nav-link dropright" href="#" id="navbarDropdown" role="button" data-toggle="dr ...

How to insert text into a text input using onKeyPress in react.js

I am looking to simulate a typing effect where the phrase 'Surveillance Capitalism' is inputted letter by letter into a text input field as a user types. However, I encounter an issue when trying to add each individual letter into the input; I re ...

Javascript clock problem, kick off on click

Currently working on a game and in need of a counter that starts when clicked and stops at 00 (From 1m to 00). It is currently starting onload and cycles back to start when it reaches 00. HTML: <body> <div> <div class="timer" >Battle t ...

Tips for incorporating a custom CSS design into a jQueryUI tooltip

I am struggling to apply my custom CSS class on top of the jQueryUI tooltip. Although the tooltip is displaying correctly, my styles are not being applied. Here is the code I'm using: $(document).ready(function () { $("#roles").tooltip({ content: ...

NodeJS/ExpressJS Image Redirection

Would it be acceptable for an img to have a src value that redirects to another page? In my view, I am using the following img tag: <img src='/images/fileName'/> In app.js app.get('/images/:fileName', subject.image); Here is ...

The jQuery pop-up fails to activate on the initial click

I have multiple "Buy Now" buttons for different products. If the button is labeled as "sold-out," it should not do anything, but if it's available, it should trigger a jQuery Magnific Popup. Currently, the popup only opens after the second click becau ...