Tips for styling a UL list with LIs on separate lines using CSS

As depicted in the image below, the list is extending beyond the screen. I am trying to limit the width of the ul element but it is still exceeding the specified width. Current CSS being utilized:

.menu ul{
width:100%;
max-width:100%;
}

Answer №1

Give this a shot

.menu li {
    display: inline-block;
}

Good browser support and check out this article.

In case you encounter

  • margin-left, avoid setting width to 100%, use 100% - margin-left-value instead
  • padding-left, consider using box-sizing: border-box

If older browser compatibility is not an issue, try using the flexbox model.

Answer №2

Use either: display: inline; or display: inline-block;

Both options are effective.

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

What is the best way to align an ordered or unordered list to the left in HTML?

Is there a way to align my HTML list all the way to the left without it shifting slightly to the right? My name is: 1. John 2. Jack 3. Jones I want it to look like this: My name is: 1. John 2. Jack 3. Jones Sincerely, Peter ...

How can I reduce the size of a Bootstrap 5 carousel that spans the entire screen?

As someone new to web development, I have found using bootstrap to be extremely helpful. However, I am currently struggling with creating a carousel for my website. My goal is to display some pictures in one corner of the page, but the carousel keeps str ...

Transform this color matching game into an image matching game using JavaScript and jQuery

I have a color matching game that I would like to enhance by matching background-images instead of just background-colors. However, I am facing difficulties in making this change. For instance, instead of matching the color red with the text "red," I wan ...

Using Selenium WebDriver to click the Compose button in Gmail

The command to press the button is not working as expected. It successfully finds the button, but fails to click on it. The desired behavior is for a native page to open within Gmail upon clicking the button. Below is the code that attempts to click on th ...

Guide: Placing two divs with variable widths inside a fixed-width container

Currently, I am working on customizing my subheadings to fit within a 960 grid layout design. The challenge is that the headings need to have a trailing decoration (in this scenario, two lines aligned at the bottom). To achieve this, I created a div for t ...

failed to apply external CSS to style React components

I am experiencing an issue where my React file is not recognizing my external styles.css index.js : import React from "react"; import ReactDOM from "react-dom"; import "./css/styles.css"; ReactDOM.render( <div> & ...

Why do CSS media queries stop working at exactly 5 distinct resolution sizes? This seems odd

Just completed my first JavaScript project, a 3D website using three.js. However, right before publishing, I realized that the dimensions and contents were not optimized for viewing on browsers other than 1920x1080. So, I delved into setting DevicePixelRat ...

What is the best way to extract text from multiple "div class" (html) elements in R?

My objective is to collect data from this html page in order to build a database: https://drive.google.com/folderview?id=0B0aGd85uKFDyOS1XTTc2QnNjRmc&usp=sharing One of the variables I am interested in is the price of the apartments. I have noticed th ...

Conditionally Display a Button using Bootstrap-vue

Upon clicking the button labeled Launch centered modal, I anticipate that the modal will hide the buttons x,cancel, and ok due to the boolean value of showButton being set to false. Subsequently, if I click on the show button, the buttons within the modal ...

Error in PostCSSS: Unable to find the variable "$widthStandard" in "$widthStandard:"

$containerWidth: 90%; $containerMaxSize: 1200px; // defining styles for container width $styledContainerWidth: { width: $containerWidth; max-width: $containerMaxSize; margin: 0 auto; } What is the syntax to create the $style ...

Table with expansive width housed in a div container but the div container fails to

How can I make a parent div expand when the child table exceeds the page width? What is the most effective CSS approach to achieve this? ...

What makes the transparent border colors on <tr> appear too dark?

For instance, take a look at this code: http://jsfiddle.net/WaJy7/ In my attempt to apply a semi-transparent border to every <tr> element, I've encountered an issue where the color of the border appears darker than intended for all rows except ...

Using Javascript to trigger a setTimeout function after the user's mouse leaves

There is a div that pops up when the user's mouse exits the webpage, containing a survey pertaining to my website. I want to avoid prompting users to take the survey if they move their cursor out of the page within the first few minutes of browsing. ...

Is there a way to dynamically assign the background color of a webpage based on the exact width and height of the user's screen?

I have customized the CSS of my website by setting the height to 800px and width to 1050px. Additionally, I have chosen a blue background-color for the body tag. It is important that the entire application adheres to these dimensions. However, when viewe ...

How about: "What about Using Percentage-Based Image Holders?"

I'm wondering if it's possible to use a placeholder with percentages instead of pixels. I know there's code that allows for pixel dimensions, but is there a way to use percentages? Currently, the code for the placeholder is img src="http://p ...

Creating custom fonts using compass

Apologies if my English is not up to par, as I am French. I'm encountering an issue where I include a font-face in my scss file like so: @include font-face("Enhanced Dot Digital", font-files("font/enhanced_dot_digital.ttf")); However, upon compilati ...

Get rid of the drop-down shadow effect

Currently working on a website project for a client and looking to remove the blue "shadow" effect from the dropdown menus. I believe the code that needs editing is as shown below: .main_nav ul.sub-menu { position: absolute; top: 65px; width: ...

Scrolling in iOS 8 causing flickering problem with background image

Utilizing the Supersized jQuery slider plugin to create a full-page background slider with a fade-in effect and added height for scrolling. The slider functions correctly on desktop, but upon testing on an iOS 8 iPad device, there is noticeable flickering ...

I am facing an issue where my Tailwind classes are not functioning properly when passed through props, but they work seamlessly when I directly link the Tailwind CSS using

//Button.jsx import React from 'react'; const Button = (props) => { let color = props.color || 'blue'; return ( <button className={`px-4 py-2 font-bold text-black bg-${color}-500 rounded-full hover:bg-${color}-700 focus ...

The collapse component from bootstrap is not visible due to an overlapping button

I am currently working on a responsive calendar featuring full-width buttons for events, accompanied by additional information displayed using the collapse component below. However, I am facing an issue where the button overlaps with other elements, preven ...