Adjusting the text to fit the div's dimensions

I need some help with a CSS issue I'm facing. I want to create a list on the left side of my fiddle, which you can find at this link: http://jsfiddle.net/KH45Y/72/.

<div id="left">
<ul id="myList">
</ul>
</div>

Everything was working fine when the item names were short, but once they got longer, they started overflowing into the right div.

Does anyone know how I can keep the list item names within the left div, even when they are displayed inline?

Answer №1

take a look at this code snippet

word-break: break-all;

solves the issue perfectly

Answer №2

To automatically break a line in your item name, simply insert a space where you want the break to appear:

http://jsfiddle.net/jofish999/KH45Y/73/

For example:

var textnode = document.createTextNode("ContactContactContact MoreTextOhNo"+i);

               with space here to break the line ^

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

Incorporating a variable within an HTML document without the need for

Here's a snippet of HTML code I'm working with: <body> <table width="650"> <tr width="650"> <td width="650"> lots of text here </td> </tr> </table> </body> Is there a way I can use a variable or c ...

Enhancing React components with dynamic background colors for unique elements

I am encountering an issue while using a map in my code. Specifically, I want to set the background of a particular element within the map. The element I am referring to is "item .title". I aim for this element to have a background color like this: https:/ ...

script code to limit selection of dates within a predefined range

I'm seeking assistance to limit my customers from selecting a date beyond 10 days in advance. Although I previously had a code that functioned properly when there were more than 10 days left in the current month, it is now ineffective. This is becaus ...

What is the recommended image size for Next.js websites?

According to documentation: The width of the image, in pixels. Must be an integer without a unit. The height of the image, in pixels. Must be an integer without a unit. https://nextjs.org/docs/api-reference/next/image Different devices come in various ...

How can I ensure text remains within a parent div and is positioned above an image?

After writing the following HTML and CSS, an issue arose when resizing the page: <div style="position: relative;"> <img width="100%" src="images/some.jpg"> <div class="header"> <h1>my header</h1> ...

Adjust the Column Alignment Without Affecting the Entire Row or Table

My inquiry revolves around altering the sort direction of a particular column within a Telerik RadGrid. Utilizing Firebug, it is possible to identify and modify the sorting direction of a table (either master or detail). However, there seems to be no desig ...

Insert JavaScript code into the head of the document (including the complete script code)

I am looking to insert a script in the head section of a website so that the target HTML appears as follows: <head><script type="text/javascript">*some code...*</script></head>. This particular script works perfectly: var head = d ...

innerhtml does not display the entire array contents

I'm facing an issue with my innerHTML output where it seems to be displaying one less value than expected from the array. I've been unable to pinpoint the exact problem. await fetch(urlbody, bodyrequestOptions) .then((response) => response ...

The fancybox only opens when I specify the "id", but it doesn't work when I use the "class"

I have an article with content, and also a link to a div that opens a fancybox with the div's content, like this: <p>Content of the news<a class="fancybox" href="#show">See more</a></p> Now, I want to change my div #show wher ...

Is there a way to retrieve the complete relative path of an image in CakePHP 3.1?

I am trying to send an email with images that require the full path, such as http://www.example.com/img/image-name.jpg. I am currently using CakePHP 3 framework and have written the following code: $this->Html->image('image.jpg', ['fu ...

Building a dynamic tab menu using JavaScript: A step-by-step guide

In order to generate dynamic tab menus with JavaScript, I am seeking a solution that does not rely on jQuery as it may not be supported by all mobile devices. Any advice for replicating the same functionality using pure JavaScript would be greatly apprec ...

Is there a way to align six columns on the left side and have a dynamic column on the right that fills the width of the browser window?

Is there a way to make a fluid container in Bootstrap 5 that contains a normal container on the left with 6 columns of content, while allowing the right side of the container to expand to the end of the browser window? When using a normal fluid container, ...

Is it necessary for children to occupy the same area while beginning from the coordinates 0, 0?

Imagine a scenario where you have a modal with tabs and tab content. Each tab has a different height - the first tab is 100px high, the second tab is 500px high, and the third tab is 50px high. The challenge here is to ensure that the modal body always mat ...

Proper Sequence of Bootstrap Header Configuration

I'm working on creating a header/navbar using bootstrap, but I'm unsure about the correct order and method to achieve this. This is how I want it to look: And when collapsed: Should everything be contained within the NAV tag? I have a header ...

The align-self-end CSS class seems to be malfunctioning

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" /> <div class="col-md-3"> <div class="card bg-dark text-white"> <img class="card-img" src="http://via.placeholder.com/300x340" al ...

Four boxes sharing identical code, yet yielding distinct outcomes

Can someone help me understand the concept of positioning in CSS? I created a simple code with 4 boxes that have identical width and height settings. When I position them as fixed or absolute, they look fine and identical. However, when I position them wit ...

The card-img-overlay in Bootstrap 5 seamlessly integrates into the following div container

Currently, I am in the process of creating a painting website layout for my CS50 homepage. However, there seems to be an issue with the background-color: rgba(0,0,0,0.7); not aligning correctly with the images within the card-group. <div class="car ...

Designing links within a web application

Currently, I am developing a web application that will contain a high volume of clickable elements. The challenge lies in maintaining a visually appealing design while adhering to web best practices such as using different colors and underlines for links. ...

What causes the behavior of <body> backgrounds to differ from that of other HTML elements?

After examining the HTML code provided: <p style="margin:100px;border:1px solid red;background-color:#dff"> Hello </p> We can observe that when rendered by the browser, it looks like this: https://i.sstatic.net/rADHC.png If we were to mod ...

The Android WebView is unable to run JavaScript code in a local HTML file

Currently, I am attempting to load a local HTML file from the assets folder into a webview. Even though I can successfully load the HTML file in the webview, there seems to be an issue with the file's reliance on an external .js file for calculations. ...