What is the best way to create a horizontally scrolling list with lengthy text that needs to wrap?

Take a look at this : example of horizontal scroll

I'm looking to place a large amount of text in a fixed-size container and have it wrap properly. However, when I try adding lengthy text in the fiddle, it overflows instead of wrapping around.

<div class="DocumentList">
<ul class="list-inline">
    <li class="DocumentItem">
        <span>Insert lots of text here and it spills over instead of wrapping</span>
    </li>
    ... // Additional list items here
</ul>
</div>

What I envision is a series of divs with extensive text content (e.g., 200 by 200 dimensions) that require horizontal scrolling to view all items in the list.

Can anyone provide guidance on achieving this using the provided fiddle or any alternative method?

Answer №1

Try implementing the following CSS code:

.DocumentList {
    overflow-x:scroll;
    overflow-y:hidden;
    height:200px;
    width:100%;
    padding: 0 15px;
    white-space: nowrap; // ensure no wrapping
}

.DocumentItem {
    border:1px solid black;
    padding:0;
    height:200px;
    display: inline-block; // elements aligned inline
    width: 200px; // set specific width
    white-space: normal; // allow text to wrap
    vertical-align: top; // align items to the top
}

By using this code, your text will wrap inside the LI element and the UL will have a scroll.

For reference, check out this JSFiddle link

UPDATE -

View the modified version on JSFiddle

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

The scroll-to-top arrow remains concealed when the height of the html and body elements is set to 100

I recently added a scroll-to-top arrow using Jquery, and it's functioning flawlessly. However, I encountered an issue when I set body and html to a height of 100%, as it mysteriously disappears. View this fiddle for reference The HTML structure is a ...

What is the procedure for inserting comments into inline CSS?

You know, I've been wondering how to effectively comment out inline CSS styles within HTML tags. Is it best to use the /* */ comments from CSS? Or should we opt for <!-- --> in HTML? <span class="color_dark" style="top:20px;font-size: 17px;l ...

Is it possible to identify horizontal scrolling without causing a reflow in the browser?

If you need to detect a browser scroll event on a specific element, you can use the following code: element.addEventListener('scroll', function (event) { // perform desired actions }); In order to distinguish between vertical and horizontal ...

Is there a reason for specifying a CSS parameter twice, with an asterisk on the second declaration?

Similar Question: CSS reset - purpose of asterik within a style While going through the CSS styles for HTML5BoilerPlate, I stumbled upon an unfamiliar code snippet: button, input, select, textarea { font-size: 100%; margin: 0; vertical-align: base ...

CSS has no effect

While editing the CSS for a module in PrestaShop, I encountered an issue where the changes I made were not reflecting on my website. To troubleshoot, I deleted the CSS stylesheet to confirm that I was working with the correct CSS file. Surprisingly, all th ...

The sticky footer is functional on every page except for one

Check out the page here I have implemented a sticky footer on my website, however, it seems to be working perfectly except for on my portfolio page. The issue I am facing is that the gallery section, which is relatively positioned, is overflowing from its ...

Design a collection of image icons to use as a toolbar in a web

I am in the process of creating a basic online application that allows users to select images from a toolbar (or storage box) and drag them onto a canvas. I am relatively new to web development but have figured out the drag and drop functionality. Right no ...

Encountered an error while attempting to access the .text attribute of a pre-existing <a> element: NoneType error

I'm utilizing BeautifulSoup to scrape the initial wikitable on the webpage List of military engagements during the Russian invasion of Ukraine in order to extract the names of all 57 battles. I've provided an image of the table's HTML for yo ...

Inability to activate hyperlink to a new page when utilizing a passed variable

I am currently working on a form that contains two input fields named UIN and Order Date. These fields are populated with data from a table. There is also a button labeled "Generate" that is supposed to navigate to a new page called viewstationerypdf.php ...

Is there a way to append the current path to a link that leads to another URL?

I am currently in the process of separating a website, with the English version being on the subdomain en. and the French version residing on the www. Before making this change, I have a drop-down menu that allows users to select their preferred language ...

The data-offset attribute in Bootstrap Scrollspy seems to have no effect on the offset

My attempts to adjust the data-offset for scrollspy seem to have no effect. Below, you can find the relevant snippets of HTML, CSS, and JS: HTML <nav class="navbar navbar-fixed-top navbar-default"> <div class="container-fluid"> <div ...

Activate the Chrome Extension that allows you to open a link in a new tab with just a middle click or regular click, without closing the popup

When I try to click a link in my extension popup and open it in a new tab using "middle click -> open link in a new tab", the popup closes. Is there a way to keep the popup open so I can click on multiple links from my extension without interruption? A ...

Ways to identify and differentiate various checkboxes using HTML and CSS

I am currently working on implementing a thumbs-up and thumbs-down feature, where clicking on the thumb-up icon will change the color to green, and clicking on the thumb-down icon will change it to red. However, I am facing some difficulties understanding ...

Is browser rendering performance affected by wrapping everything in a div?

Let's consider a scenario where I have an HTML page with the following simplified content within the body: <div class="wrapper"> <div class="block1"></div> <div class="block2"></div> <div class="block3"></ ...

Using Multiple SCSS Files to Reference a Centralized Style Sheet

I am currently developing a React application and facing an issue with my SCSS files. I have three SCSS files, one main file that contains theme variable colors, and the other two are located in component folders. When I import the main SCSS file into the ...

Angular silhouette casting on CSS fold

I am attempting to recreate this design as accurately as possible, but I am struggling with replicating the shadow effect on the right side. Is it achievable using CSS? CSS: *{margin:0px;padding:0px;} html { width:100%; height:100%; te ...

Is it possible to create a dropdown like this using CSS?

Planning to create a new webpage. The main feature will be a dropdown menu that I envision like this: Check out the design here: http://img694.imageshack.us/img694/9350/dropdown.png Wondering if it can be achieved purely with CSS, or would I have to reso ...

Using CSS to automatically convert a table into one column layout with labels from the thead section

Is it possible to automatically create the labels for data when converting a multi-columns table into one column using CSS and taking the information from the thead section? This resource discusses how to convert a multi-column table into a single column ...

Props and theme merge to create uniquely designed styled components with a thematic twist

Out of sheer curiosity, I've been incorporating styled-components into my React application. Within this framework, I make use of the recommended theme to ensure consistency in colors and sizes throughout. Currently, my approach looks something like ...

Extract the URL from the query parameters and inject it into a div element

I am currently working on a project to create an ASPX page with two separate div's. The first div will have static content, while I want the content in the second div to be dynamic. Users should be able to input a URL as a query string, and that URL s ...