Maintaining a roster all in one row

I'm in the process of creating a list that should accommodate 5 images per line. If there are more than 5, I want the next set to start on a new line below. Using float: left; is not working as it's causing some layout issues.

Here is the HTML code:

<html>
<head>
<title>LolChamps - Knowledge Database</title>
<link rel="stylesheet" type="text/css" href="css/champions.css">
<link rel="stylesheet" type="text/css" href="css/css.css">
<link href='http://fonts.googleapis.com/css?family=Sansita+One' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Belleza' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
</head>
<body>

<!-- NAVIGATION --> 
<div id="nav-bar">
    <div id="nav-bar-title">LoL Champs</div>
    <ul>
    <li><a href="champions">Champs</a></li>
    <li><a href="">Info</a></li>
    <li><a href="">Guides</a></li>
    <li><a href="">Model Viewer</a></li>
    <li><a href="">Lists</a></li>
    <li><a href="">Support</a></li>
    </ul>
</div>
<!-- END NAVIGATION -->

<div id="main-body">
<div id="nav-body-divider"></div>

<p id="home-body-title">Champions</p>

<div id="champ-list">
<ul>

<li><a href="champs/aatrox.html"><img src="images/champion-icons/aatrox.png" /><br/><div id="champ-text">Aatrox</div></a></li>
<li><a href="champs/ahri.html"><img src="images/champion-icons/ahri.png" /><br/><div id="champ-text">Ahri</div></a></li>
<li><a href="champs/akali.html"><img src="images/champion-icons/Akali.png" /><br/><div id="champ-text">Akali</div></a></li>
<li><a href="champs/alistar.html"><img src="images/champion-icons/Alistar.png" /><br/><div id="champ-text">Alistar</div></a></li>
<li><a href="champs/amumu.html"><img src="images/champion-icons/amumu.png" /><br/><div id="champ-text">Amumu</div></a></li>
<li><a href="champs/anivia.html"><img src="images/champion-icons/anivia.png" /><br/><div id="champ-text">Anivia</div></a></li>
<li><a href="champs/annie.html"><img src="images/champion-icons/annie.png" /><br/><div id="champ-text">Annie</div></a></li>

</ul>
</div>

</div>

</body>
</html>

This is the CSS code being used:

#champ-list {
    color: black;
    font-family: Arial;
}
#champ-list li {
    list-style-type: none;
    color: #B0B0B0;
}
#champ-list ul li {
    display: inline;
}

I have attempted to use display: inline;, but it hasn't worked as expected. Here's an idea of how I envision the layout should look like:

Answer №1

Experiment with this code snippet

#champion-list ul li {
   display: inline-block;
}

To ensure that 5 items fit per line, consider adjusting the width of each li.

Answer №2

Positioning elements to the left is a viable option, although it may be causing complications if you're not clearing your floats. Instead, consider using display: inline or display: inline-block, which are more conventional methods. You can adjust the width of your list items (li) to 20% or potentially less depending on your layout requirements.

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

Difficulty encountered when trying to update a re-updated HTML DOM using Flask

I have a flask dropzone for file uploads, and after each upload I want to display a log text on the website. While it currently works, there is an issue where the log text does not update after the second upload. The website continues to show the text from ...

Solid colored fill for the active item in the Bootstrap navbar

As I work on constructing a web page using Bootstrap 5 with a fixed top navbar, I am aiming to have the "active" item highlighted with a solid background color similar to the example shown here. Upon inspecting the page using developer tools, I noticed th ...

having trouble generating a vertical advertisement banner on wordpress

Hey there, I'm attempting to place a vertical banner ad created with HTML/CSS inside a textarea in the WordPress widget section. I added a textarea to the side column, inserted the HTML with corresponding CSS styles into the stylesheet. However, the s ...

I'm looking to integrate AngularJs with JsBarcode - can anyone provide guidance on how

Hey everyone, apologies if this is a bit rough, but it's my first time asking a question here. I'm currently working on creating a barcode with AngularJS using JsBarcode. However, when I try to include the Angular code like {{y.code}}, JsBarcode ...

Positioning the close button on the top right edge of a Material-UI Dialog: A step-by-step guide

https://i.sstatic.net/ARTtq.png How can I include a close icon in the top right corner of the header section? I'm using the Material UI Dialog and everything works well, but I need a close button in the top section. Can anyone assist me with this? ...

Implementing CKEditor instances within AngularJS Controller scopes

Greetings everyone, Recently, I have been exploring Angular JS. Everything is going smoothly - my controllers, services, and so on. However, when attempting to make a Div editable that is within the ng-controller, the ckeditor toolbar fails to appear. On ...

What is the best way to display the content below a bootstrap card while utilizing relative positioning?

Currently working on a bootstrap card design featuring an image. With the card body positioned above the image using position: absolute and top. The challenge arises when adding a new div below the card; it ends up being pushed onto the image instead of s ...

I encountered an issue while iterating through Object HTMLDivElement and applying ChileNode style z-index, resulting in an undefined output in both Firefox and Chrome browsers

function adjustPosition(currentDiv) { try { for (var i = 0; i < document.getElementById("parentContainer").childNodes.length; i++) { document.getElementById("parentContainer").childNodes[i].style.zIndex = 0; ...

Trouble with Metro UI Library: CSS not loading properly

I am having trouble with the navbar CSS on my website while using the Metro UI CSS library. Check out my HTML code: <!DOCTYPE html> <html lang="en"> <head> <title>TelePrint Blog</title> <link rel="stylesheet" href= ...

Create a page turning effect in React that simulates scrolling a certain amount at a time

Is there a way to disable default scrolling and have the page automatically scroll to the next item? For example, if I have element2 below element1, how can I set it up so that when I scroll down once, the page scrolls directly to the position of element2 ...

Issue encountered with jQuery trigger functionality

I'm facing a challenge $('input[type=radio][name="voucher_type"]').on('change', function() { //doing something here }); So, when a radio button is clicked, actions are taken. The radio button sits inside a styled div that acts as ...

Is there a solution to move my navbar that is frozen halfway on the screen?

I'm in the process of developing a website and have implemented a sticky navbar using CSS. However, I've noticed that when I scroll down, the navbar appears to be "stuck" slightly further down the page (as shown in the second image). Can anyone p ...

Focus will be set automatically on input field that is loaded dynamically

While using jQuery, I have been attempting to use .focus() on an input field after an AJAX call but without success so far. Here is a brief snippet of what I am trying to achieve: $.ajax({ type: "GET", url: url, success: function (data) { ...

JQuery UI - Issue with Draggable functionality immediately after dropping it

HTML: <div class="character_list"> <div id="draggable" class="character_list_container"> <div><img class="1" src="http://ahna.web44.net//img/charas/13.png" /></div> <div><img class="2" src="http://a ...

The jquery UI button is displaying too wide even though the padding is set to zero

My goal is to decrease the width of certain jQuery buttons. Though I have attempted to eliminate padding using the code below, there remains a minimum of 5 pixels on either side of the text within my button. .button().css({ 'padding-left':' ...

Retrieve the <style> tag response and inject it into the head section of the HTML using React

Although I am aware that this may not be the best practice, it seems to be the most suitable solution for this particular case. The server response contains something like this: <style id="styles">.color_txt{color:green;}</style> I am attempt ...

Variable width items inside an overflow-x container

I'm searching for a solution to create a vertical navigation list that can accommodate elements wider than the container itself. Since users have the freedom to input any names for the items, I cannot predict their width, except maybe by setting a ver ...

quickest method for attaching a click listener to dynamically added elements in the document object model

When adding multiple elements to the DOM, how can we ensure that these elements also have a click handler attached to them? For instance, if there is a click handler on all elements with the "canvas-section" class, and new "canvas-section" elements are con ...

Ways to adjust the overflow content to display below rather than forcing it into a single row

I've configured an XSL file like this: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template name="homeArticleThumb" match="/"> <xsl:for-each sele ...

Creating a stationary div in Internet Explorer 10 Mobile

Is there a way to create a fixed div that is compatible with IE10 Mobile on Windows Phone 8? Currently, I have been using the following code: <div style="position:fixed;width:100%;background-color:blue;"> test </div> This solution is only ...