A single buoy is positioned above another buoy

All list items (li's) are set to float:left; and the 4th li has been positioned on top of the 1st li.

I would like the 4th li to be displayed separately and not interfere with the layout of the 1st li.

Here is the desired result: http://jsfiddle.net/TomasRR/s9nQ6/6/embedded/result/

Here is the relevant code snippet: http://jsfiddle.net/TomasRR/s9nQ6/6/

<ul>
    <li>
        <div class="front">1</div>
        <div class="back">Back</div>
    </li>
    <li>
        <div class="front">2</div>
        <div class="back">Back</div>
    </li>
    <li>
        <div class="front">3</div>
        <div class="back">Back</div>
    </li>
    <li>
        <div class="front">4</div>
        <div class="back">Back</div>
    </li>
</ul>

li {
    height: 150px;
    width: 400px;       
    list-style: none;       
    background: red;        
    float: left;        
    margin-right: 20px;     
    margin-bottom: 50px;
    margin-top: 10px;               
}
.front, .back {
    width: 100%;
    height: 100%;
}
.front {    
    background: gray;

}
.back {
    background: yellow;
}

Answer №1

It seems like the height setting for your li elements is causing them to overlap with the blocks that contain both the front and back sections. When the browser window is resized and items move to a new line, they start too close together due to the smaller height value. You can fix this by adjusting the heights of the li elements to match the overall height of the containing elements. Adding some spacing between rows with padding or margin could also help prevent overlap.

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

Is it possible to remove certain 'css-' class names that MUI automatically applies to its components? (Using Next JS and MUI)

After successfully migrating my create-react-app project to Next JS using the latest version (12.1.0) and following the migration guide at https://nextjs.org/docs/migrating/from-create-react-app, I encountered an unexpected issue. Despite still using MUI a ...

Challenges with implementing CSS transitions

I've been delving into CSS3 transitions, and I'm encountering some confusion. I can't tell if I'm misunderstanding something or if it's the browsers causing issues. Initially, I believed Opera had transition support starting from ...

Picture loading using Ajax placed above the content area

Utilizing the Ajax Loading image referenced at this link to display a loading image during various stages of an ajax request (begin, complete, success). I'm interested in learning how to position the image above all content and center it on the scree ...

What is the reason behind IE's decision to reduce the size of password boxes compared to text

Take a look at the uncomplicated form right below. You'll notice that it consists of a text box positioned above a password box. In older versions of Internet Explorer like 7 and 8, as well as possibly in other browsers, you might observe that the tex ...

Understanding the significance of the asterisk symbol in CSS

Is This CSS Syntax Correct? css: the meaning of * mark What is the function of * in CSS? I came across some code here that included it: .center-wrapper{ text-align: center; } .center-wrapper * { margin: 0 auto; } Could this be a mistake? ...

What would be more efficient: inputting all items in a form at once or adding them one by one consecutively

My mind is preoccupied with a dilemma: is it better to have all possible items already on the form, or should items only be added when the user requests them? Let me elaborate - Imagine I have a form with 4 input fields and one textarea. Alongside that, t ...

Leveraging MS Excel VBA for extracting information from intricate HTML/JS code

Greetings! I would like to start by saying that I am an intermediate VBA coder who lacks HTML experience. My goal is to extract data from a HTML/JS webpage using MS Excel VBA. Despite spending several hours testing my code on different pages and searching ...

What could be causing the @each statement in SASS to not function properly in Next.js?

I am struggling with my SCSS files and color scheme colors.scss @import './variables'; $colors: ( p: $color-primary, s: $color-secondary, t: $color-tertiary, q: $color-quartary, ); @each $name, $hsl in $colors { .c-#{name} { colo ...

Trigger an immediate repaint of a DOM element in the browser

Searching for a way to insert a large HTML markup into a DOM element that will take some time. This is why there's a need to display a preloader indicator before the process begins. Two blocks are involved: #preloader and #container. Initially, the pr ...

javascript/jquery - steps to design an effective modal page overlay

Struggling for the past few weeks to create a modal dialog using javascript/jQuery. While iOS and Android devices seem to work fine, Windows mobile/Opera mobile often present issues with the modal size. It either requires excessive scrolling or ends up bei ...

utilizing AJAX in PHP for a dynamic selection process with MariaDB

I am working on a dynamic select feature using AJAX, PHP, and queries to a database. There are three main components involved in this process: the HTML where the select options are populated from database queries done through AJAX, the PHP scripts that han ...

Optimizing Image Size According to the Container, Not the Screen Size: A Guide

After exploring various resources on responsive images, I have come across a challenge that has me stumped. It seems like it should be simple, but I can't quite figure it out: How can I serve the appropriate image size based on container width rather ...

Is there a way for me to position my emoji directly alongside the title text?

I'm facing a challenge with aligning my image right next to the heading. Specifically, I want it to be placed next to "Sample Text". Currently, the container that includes the heading and emoji is set as a flexbox. .container{ display:flex; ...

How can I utilize Bootstrap to organize multiple div layers on top of each other?

I am trying to accomplish the following: layered div The rows are displaying correctly, but I'm having trouble positioning the top layer div (the one with the class map) in the correct place. It keeps pushing some of the rows to the side. How can I a ...

Add a d3 table to an svg element based on its id

The code below contains a table that is not displaying properly. When using Chrome's developer/elements tool, I can see that the elements are being created but they are not rendering in the browser. Despite this, the data appears correctly under devel ...

Utilizing the <a> element within a Thymeleaf loop

I'm looking to use Thymeleaf to display a list of links in my project. Below is the code I used successfully for displaying the links: <div class="col-12 col-md-6" th:each="ApplicationVO: ${ApplicationList}"> & ...

a container holding two floating divs

I have been attempting to create two divs positioned side by side, with one containing content and the other acting as a sidebar. Both of these divs are contained within another larger container div. Despite my efforts, I have not been successful in achiev ...

Removing the "%20" code from URLs in your Django project

Currently, I am using Django 1.3 and implementing template inheritance. However, I have encountered an issue with the /static/ settings path once I navigate away from the home page. The problem arises when I load home.html, which inherits from base.html - ...

Issues with FF6 CSS Javascript MozBorderRadius functionality not functioning as expected

While attempting to set the border radius using JavaScript in Firefox 6, I'm experiencing some issues. Interestingly, when I use the same code with WebkitBorderRadius on Safari, it works perfectly. that.element.style.WebkitBorderRadius = '10px&a ...

What is the best way to make a background image that adjusts in size while maintaining the aspect ratio?

Looking to set up a unique loading screen for my GMOD server. When players are using a 4:3 monitor, the background image needs to be resized or cropped accordingly. Any suggestions on how I can achieve this? ...