Interrupted text sequence

Currently, I am facing an issue with a horizontal list that consists of li elements. The li elements are 200px in size inside an 800px ul. My goal is to have the ul scroll horizontally while allowing the text inside the li elements to break. However, this causes the li elements to lose their vertical position.

Here is the HTML code snippet:


<div>
    <ul>
        <li>one</li>
        <li>two</li>
        <li>three three three three three three three three three three three three three three three three</li>
        <li>four</li>
    </ul>
</div>

This is how the CSS looks like:


ul {
    width: 600px;
    height: 400px;
    display: block;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
}
li {
    width: 150px;
    height: 150px;
    display: inline-block;
}

It might be a bit complicated to explain thoroughly.. Check out the fiddle for clarity: https://jsfiddle.net/yrLtsLrf/

Answer №1

try including vertical-align: top; in the style for your list items.

Answer №2

Ensure this solution is effective by following these steps:

vertical-align:top

Also, remember to include in the list item:

whitespace:normal

Check out this example on jsfiddle

Answer №3

To make it functional, apply the following CSS to the list item:

overflow-x: scroll;
overflow-y: hidden;

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

Creating a responsive design with dynamic width using HTML and CSS to handle overflow situations

Struggling to figure out how to achieve this in html, I would like the solution to be limited to just html + css. Javascript/jquery is being utilized on the site, yet I don't want my design to rely on javascript. Section A contains a list of variable ...

``Is there a way to use CSS to break after a certain number of characters

I'm trying to break my table cell every 20 characters, but so far I've been unsuccessful. After some research, I discovered the ch unit in CSS that can help me set a maximum width like this: td { max-width: 20ch; } However, simply setting t ...

What could be preventing my image from displaying in the header section?

Having trouble displaying the image I added in the header section as a logo. The code works for my online course instructor, but no luck for me. I've tried different images and links to no avail. If you would like to take a look at the codes I used, ...

Troubleshooting Issues with Mathematical Equations in SCSS File Using Angular CLI

I don't have much familiarity with the .scss syntax. I am working with angular CLI and using the .scss extension for my css files. My goal is to determine the background-color value conditionally. @function getBgColor($value) { $modular: #{$val ...

Embellishing Your Website with Unique Cursor Styles

Looking to add personalized cursors to my website using asp.net 4.0. On my master page, I aim to set a custom cursor as the default for the entire site and have different custom cursors for all links. Is this achievable? ...

Header text refuses to cooperate and center itself

Struggling to find the best way to center the "Header" text while keeping the icon in place. I've tried using text-align: center;, but it's not producing the desired results. Could anyone provide guidance on how to achieve this? Thanks. IMG: ...

employing a list of arrays and encountering a glitch

I've been struggling to get the difference method in my code to work correctly. When I try to check if !other.contains(set), I encounter an error. The same happens when I try to add it after checking if it contains it. I'm not sure how to fix thi ...

Combining multiple images in a single row using CSS and Div tags

Insert this code for each image <div class="side-by-side"> <a href="http://example.com ....> (insert the entire image code here) </div> Here is the CSS snippet .side-by-side { float: left; margin-right: 5px } It's functional... ...

What is the best way to convert a list of string values into integers to accurately represent specific data?

As a beginner in Python and coding, I carefully phrased my question. I have two sets of lists that are evenly populated – one representing family members and the other their ages. adams = ['ben', 'susan', 'billy'] adamsage = ...

The scroll() function in jQuery does not bubble up

Recently, I encountered an issue with a Wordpress plugin that displays popups on scroll. The code I currently have is as follows: jQuery(window).scroll(function(){ //display popup }); The problem arises with a particular website that has specific CSS ...

Exploring the differences in Python's handling of lists

I'm looking to create a list of unique items from multiple lists by comparing them all. Is there an easy and efficient way to accomplish this task? I understand that these lists can function similarly to sets. ...

Styling Multiple Fullscreen Rows with Bootstrap CSS

Does anyone have any suggestions for the CSS code needed to stack five rows on top of each other? Each row should be 100% height and width of the browser. Here is the HTML code I currently have: <div id="wrapper"> <div class="container-fluid"> ...

When CSS media queries are applied, the background color of Div does not fully extend to the edge

Although the problem seems simple, I am finding it difficult to find a solution. This page was created as part of my course. https://i.sstatic.net/DKCva.jpg While in developer mode and trying to resize the screen, I noticed that the background color of ...

The navigation bar is not floating to the right of the <header> element

Having trouble with my header element and nav not floating to the right using "float: right;" Just dipping my toes into html&CSS, seeking assistance to make my nav bar float to the right. I've watched a few videos and checked out Stack Overflow, ...

overrule styling in react native

In React Native, I am looking to modify a specific style within a sub-component. For instance, I have defined a style called CircleShapeView: const styles = StyleSheet.create({ CircleShapeView: { width: 50, height: 50, borde ...

Unable to apply a border to the button

I'm having trouble adding a border to my button on the website. I've tried setting the color, which works fine for the font color within the button, but the border properties are not working. Despite trying some highly rated solutions, none of th ...

Create a responsive design for both iframes and embedded videos

When using PlusThis for video tracking, the code functions well on desktop but becomes non-responsive on mobile devices. To maintain the required JavaScript functionality from PlusThis while ensuring responsiveness, I am seeking assistance with modifying t ...

Padding for the initial element in a carousel display

I am currently working on implementing owl carousel with stage padding. My goal is to use the carousel with loop:false, and have the first item displayed without left padding, while maintaining consistent padding for both items on the left and right after ...

Expandable tool tip box

I've specified the tooltip's width and height as 100% .tool-tip, .tool-tip.top{ width: 100%; height: 100%; margin-left: -43px; } However, it still fails to expand based on the content within. The issue can be seen here: http://jsfi ...

Unleashing the Power of Reactstrap: Making Uncontrolled Collapse Panels Open by Default

Can the uncontrolled collapse be displayed as open by default? Below is the standard code for uncontrolled collapse, which is initially shown as a collapsed tab. <Button color="primary" id="toggler"> Toggle </Button> < ...