CSS3 List Style Floating Challenge

I have encountered a seemingly simple question, but I am struggling to find a solution.

In my HTML code, I have two ul elements. Each li within these lists is styled with float:left in my CSS. The reason behind this styling choice is that I am working on a four-column grid layout and needed to arrange the list items accordingly.

The issue arises when a list does not occupy the full width of my grid, causing the subsequent list to start on the same line.

https://i.stack.imgur.com/D8EoC.jpg

It is important for the items within each list to remain inline while the lists themselves should be displayed below one another.

Visit this link for more details: https://jsfiddle.net/gugubaight/93xv9tgt/1/

Here is the structure of the HTML:

<div class="wrapper">
  <ul id="tools">
    <li>
      <img>
    </li>
  </ul>

  <ul id="tools">
    <li>
      <img>
    </li>
  </ul>
</div>

This snippet shows the SCSS styling being used:

.wrapper {
      width: 1440px;
      max-width: 90%;
    margin: 0 auto;
}
ul#tools {
    padding: 0;
    margin: 0;
    list-style: none;
    li {
        padding: .25rem .25rem 3rem;
        width: 25%;
        float: left;
        -webkit-animation: appear .5s ease-in;
        animation: appear .5s ease-in;
        img {
            width: 350px;
            max-width: 350px;
            height: 225px;
            max-height: 225px;
            border-radius: 3px;
        }
    }
}

Your assistance with solving this issue would be greatly appreciated!

Answer №1

It's possible that the issue lies with the h1 tag. Update: I have provided a live fiddle with the structure I created for you. Try removing float: left from li and adding it to your ul class or id instead.

{display: inline-flex;}

It might be better to use class instead of id, but if you prefer using ids, make sure to differentiate them like tools1 and tools2. For now, I am using class.

.wrapper {
      width: 1440px;
      max-width: 90%;
    margin: 0 auto;
}

ul.tools {
  padding: 0;
  margin: 0;
  list-style: none;
  display:inline-flex;
  li {
    padding: .25rem .25rem 3rem;
    width: 25%;

    -webkit-animation: appear .5s ease-in;
    animation: appear .5s ease-in;
    img {
      width: 350px;
      max-width: 350px;
      height: 225px;
      max-height: 225px;
      border-radius: 3px;
    }

  }

}
ul li >  .footer{
      float:right ;
    }

<div class='wrapper'>
 <h1>Recent Tools by my favorite Developers</h1>
 <ul class='tools'>
  <li>
   <img src="http://placehold.it/150x100" />
    <h2>test  </h2>
  <p>test test test</p>
  <p><i class="fa fa-user"></i>test</p>
  <p> <i class="fa fa-tags"></i>test</p>
  <span class="footer">
    <i class="fa fa-star-o"></i>
    <i class="fa fa-heart active"></i>
    <i class="fa fa-eye"></i>
    <i class="fa fa-share"></i>
  </span>
</li>

<ul class='tools'>
<li>
  <img src="http://placehold.it/150x100" />
  <h2>test  </h2>
  <p>test test test</p>
  <p><i class="fa fa-user"></i>test</p>
  <p> <i class="fa fa-tags"></i>test</p>
   <span class="footer">
    <i class="fa fa-star-o"></i>
    <i class="fa fa-heart active"></i>
    <i class="fa fa-eye"></i>
    <i class="fa fa-share"></i>
   </span>
 </li>

Enjoy coding :)

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

Rearranging the order of Div elements within a main container using JavaScript DOM manipulation

How can I move elements within a div from the start to the end in the same div, for example, changing the order from 1-2-3 to 2-3-1? My code: const cards = document.querySelectorAll(".card"); const firstCard = document.querySelectorAll(".card")[0].inne ...

The overflow property is not functioning as anticipated

I've browsed Google and this site, but I couldn't find a solution to my issue. On my webpage, I have a shoutbox and a teamspeak viewer with a specific height for the outer div. The scrollbars don't look good on our new design, so I attempt ...

Four-pointed star design with rounded edges

My goal is to create a pixel-perfect star using CSS. I have attempted to achieve this so far, but the star currently has 5 points and I would like it to only have 4 points. Additionally, I am looking for a way to make the corners of the star more rounded. ...

What is the process for transferring a file to a different directory?

<html> <head> <title>Main Page</title> </head> <body> <h2>Main Page</h2> <form method="post" action="index.php" enctype="multipart/form-data"> <input type="file" name="filename"> <input type=" ...

Having trouble with AJAX within AJAX not functioning properly?

Similar to the Facebook commenting system, I am aiming for comments to be appended to previous ones and displayed all at once. However, currently the comments only show up after the page is reloaded. Please Note: Each post initially loads with just two co ...

Avoiding the <br> tag in list items with TinyMCE

I am currently using tinyMCE and I needed to enable the "force_br_newlines: true" option. Without this setting, if I press the "Enter" key twice and check the source code, I only see one <br> tag. However, when I set the option to TRUE, it creates a ...

Is it possible for me to utilize code blocks within the head content and link tags to make reference to specific themes

I am currently in the process of developing an ASP.NET application using themes. I have successfully assigned a theme to the application via the web config file. One issue I am facing is trying to reference a bookmark icon located within the themes direct ...

Customizing Material UI: Adjusting the visibility of slider thumb upon user interaction and value changes in the slider

In my application, I have implemented a Material UI Slider and I am looking to keep the thumb invisible until the user interacts with it. Once the user changes the slider value, I want the thumb to remain visible at that specific value. By using the CSS pr ...

Seamless blend of images with a stunning mosaic transition effect

I attempted to create a mosaic effect on my carousel similar to this example: , but not exactly like this. I want to include control buttons for next and previous, and have images in HTML tag. However, my attempt is not working and I need help. This is ...

Trimming whitespace from strings within HTML tag attributes can be achieved using various methods

I have been reviewing the .cshtml pages of a website with the aim of adding ID attributes to various divisions and elements for testing purposes. These pages utilize AngularJS, and many of the elements I need to add ID attributes to are part of a list tha ...

Div controls the margins of all other elements

I am encountering an issue when trying to position #slider, where the navigation and elements above it also move. It seems as though they are contained within #slider, even though they are not. HTML: <div id="slider" class="clearfix"> <d ...

Firefox not responding to mouse movements

I am experimenting with creating an "animation" using JavaScript's "mousemove" Check it out here This is the code I am currently using $("body").mousemove(function(e){ var wWidth = $("body").width()/2 var wHeight = $("body").height()/2 var posX; v ...

retrieve the image name of the background using jQuery

How can I use jQuery to extract only the background image name from a div with a background image? I currently get 'http://localhost/xampp/uconnect/images/tour-networks-ss.png' but I only want 'tour-networks-ss.png' Any assistance wi ...

Creating a List with Sublists that are displayed when hovering over the parent List is a key element of effective design

Hovering over 'View Rows' should open up both New Records and Old Records <div> <li>Add Rows</li> <li>DeleteRows</li> <li>View Rows <ul> <li>View New Records</li ...

What could be causing my modal to not animate from the center of the screen?

I am aiming to have my .modal div class smoothly scale from 0 to 1 right in the center of the screen instead of starting at the bottom right and then moving to the center before settling in its final position. I have checked various resources like MDN docu ...

Search bar that automatically adjusts based on the size of the containing div

https://i.stack.imgur.com/wtn8K.gif I'm interested in learning how to achieve a layout similar to this. Here's an example of what I've created: <div class="header-con"> <div class="search-bar-con"> <input type ...

Change the background color of all cells in a Bootstrap table by hovering over a single cell

Here is the code for a bootstrap table: <body leftmargin="0" topmargin="0" bgcolor="#ffffff" marginheight="0" marginwidth="0"> <div class="container-fluid h-100"> <div class="row float-right align-items-center" style="height: 5%;"> ...

Can a div be aligned in the center with an "absolute" parent element?

<style type="text/css"> .square { width:251px; height:207px; border: 1px solid #d6d6d6; -webkit-box-shadow: 1px 1px 3px rgba(0,0,0,.1); -moz-box-shadow: 1px 1px 3px rgba(0,0,0,.1); box-shadow: 1px 1px 3px rgba(0,0,0,.1); ...

Tips for embedding Jquery code within Vuejs applications

Trying to code a Vue.js Navbar that changes color when scrolling using Jquery and CSS script. It works, but I encountered an error with Vue.js not supporting the syntax '$' after page refresh, resulting in a "$ not defined" error message. As a ne ...

Tips for concealing labels until the submit button is activated

I am currently handling a project involving a Spring Controller and JSP. Within a JSP page, I have included a button labeled Process. Upon clicking this button, two radio buttons are displayed below it along with a Submit button. After tapping the Submit ...