Troubleshooting a Misbehaving List with HTML and CSS

I am seeking assistance with resolving an issue in a 2-column list layout.

The problem arises when the content in the right column spills over into the left column if it exceeds a single line.

Additionally, when the content in the left column spans multiple lines, the content in the right column ends up at the bottom instead of aligning properly.

Furthermore, the line separating the columns behaves oddly when there is more than one line of content (see examples below).

It is important to keep the "Title" and "Description" columns within separate HTML tags for Responsive CSS layout purposes.

ul {
  list-style: none!important;
}
ul.my-list>li {
  width: 550px!important;
  position: relative;
  padding-left: 30px;
  padding-right: 15px;
  background: 0 0;
  border-radius: 0!important;
  margin: 0;
  box-sizing: border-box;
  background: #EEE;
}
ul.my-list>li span {
  width: 140px;
  border-right: 1px solid #E0E0E0;
  display: inline-block;
  padding: 3px 0;
  line-height: 38px;
  margin-right: 15px;
}
<ul class="my-list">
  <li><span>Title</span>Description. Not too many words – displays well.</li>
</ul>
<br>
<br>
<ul class="my-list">
  <li><span>Title</span>Description. More words – this goes wrong. Really wrong. Seriously...At least the "Description" column should not intrude into the "Title" column.</li>
</ul>
<br>
<br>
<ul class="my-list">
  <li><span>Title with many words acts weird too</span>Description. How to fix the "Description" column, so it would start from the top side, not from the bottom?</li>
</ul>
<br>
<br>

Answer №1

give this a shot

ul.my-list>li span {
  float:right;
  }

ul.my-list>li {
  min-height: 100px;
  
  }

Answer №2

After tackling the issue, I managed to resolve it by creating separate <span> elements for each column and applying display: inline-flex; to the entire <li> element.

This solution is compatible with CSS Responsive Layouts and functions seamlessly across all screen sizes.

Check out the JSFiddle link for a demonstration: http://jsfiddle.net/tay06de4/4/

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

Refresh the page excluding any <script> elements

I am looking to display a page without actually running its JavaScript code, while also injecting my own script and providing the user with a perspective similar to that of a bot. One approach I have considered is loading the page via ajax, stripping out ...

Height of Owl Carousel on mobile devices

On my desktop, I have an image that covers the entire screen using Owl Carousel. However, when viewed on a phone device, the same image only takes up one-third of the screen size. How can I adjust the height so that it appears taller on a phone? I' ...

How can I change the background color of the textArea in Summernote?

Currently, I am in the process of incorporating Summernote into the jdorn json-editor. I have successfully implemented it, but now I need to find a way to change the background color of the textArea that Summernote uses. It seems there is no built-in API f ...

When using the resize property in monaco-editor, it may result in editor popups being obscured or

My current task involves utilizing the deltaDecorations method to display errors in my editor. Feel free to check out my code here: https://gist.github.com/dinager/41578bd658b60cc912a6023f80431810 Below is the output: https://i.sstatic.net/Dtj9A.png ...

Having trouble getting the toggle menu to work using Jquery?

I am trying to create a toggle menu using jQuery on this particular page: . The menu is located in the top right corner and I want it to appear when someone clicks on the "Menu ☰" button, and then disappear when clicked again (similar to this website: ). ...

"Encountering an issue when linking the file with phpMyAdmin

I've been struggling with this issue for hours now. I'm currently working on a registration form for my website and while coding in PHP, I connected it to MySQL and the Database using this line of code (which happens to be the 6th line): $mysq ...

How can I ensure that changes made to a div in ASP.NET remain persistent during postback?

My current setup involves using jquery to toggle a div on and off successfully. However, I am encountering an issue where any changes made are not saved when a postback occurs on the page. Can anyone provide guidance on how to save these changes? Any assis ...

What is the best way to add an external CSS file specifically for my custom Vue component?

Currently, I am working on a vue js component that I plan on uploading to npm. However, I have encountered an issue: Whenever I import a third-party CSS CDN into my component, it ends up applying the styles to the entire HTML instead of just my component ...

Ways to customize the datetime-local format in an HTML input field

When dealing with the HTML input of datetime type, consider the following: Datefield: <input type="datetime-local" data-date="" data-date-format="DD MMMM YYYY, h:mm:ss"> The script below includes important code. $("input").val(moment().format(&apo ...

What steps should I take to incorporate Google sign-in on my website and gather user information efficiently?

I am looking to add the Google sign-in button to my website. While I am knowledgeable in HTML, PHP and JavaScript are not my strong suits. My goal is to allow users to sign in with their Google account and securely store their information on my database th ...

Most secure methods to safeguard videos from unauthorized downloading

How can I increase the security measures to prevent users from easily downloading videos from my website? While I understand that it is impossible to completely stop downloads, I am looking for ways to make it more challenging than just a simple right-cl ...

Show only the selected option with jQuery's on change event and disable or remove the other options

My goal is to make it so that when a user selects an option from a dropdown menu, the other options are disabled or hidden. For example, if option "1" is selected, options "2", "3", and "4" will be removed: <div class="abc"> <div class="xyz"> ...

The CSS no-repeat background image property seems to be functioning properly only in the Firefox

.myclass{ background-image: url('http://image.flaticon.com/icons/svg/34/34164.svg'); background-repeat: no-repeat; background-size:contain; background-position: 1.5%; } Every row (tr) in my table is assigned the class myclass: <tr cl ...

The browser does not support the display of Spanish special characters

I am working on a website and need to incorporate support for the Spanish language. I have prepared an XML file with both English and Spanish text. The XML file is being read based on the user's selection of language from a dropdown menu. Everything s ...

Display or Conceal Multiple Divisions Using Angular 2

I am looking to implement a functionality using Li lists to toggle the visibility of multiple divs in Angular 2. Initially, all divs on the page will be visible. When viewing on a smaller screen, I want to hide some divs and show a specific div when a cor ...

Seeking assistance in developing a dynamic footer complete with a gallery of images

Attempting to create a footer packed with images but struggling to ensure it looks good on both PCs and mobile devices. The goal is to align the bronze sponsor kitten to the left, and supporter kittens to the right, while keeping the footer at a reasonabl ...

Search bar placeholder text appears off-center in Firefox browser

I have implemented a universal search bar on our website and it is working perfectly in Chrome and Safari. However, I am facing an issue with Firefox where the placeholder text is aligned to the bottom of the bar instead of the middle. Usually, placeholder ...

The height of a div element does not automatically default to 100% in Next.js

I'm encountering an issue with styling pages in next.js. My goal is to create full-height pages. Although I've successfully set the height attribute in the body and html tags to achieve full height (verified in dev tools), I'm struggling to ...

Looking to create multiple image popups for different models using JavaScript? I am currently utilizing the W3Schools model image for this purpose

I am having trouble getting multiple image models to display, as only one pop-up is appearing. Can someone please assist me in figuring out how to show multiple pop-ups? // Obtain the modal element var modal = document.getElementById("myModal") ...

Issue with displaying Git remote repository on list item element (ul) not appearing

My attempt to showcase my GitHub repositories via their API is not displaying on my webpage, even though the exact same code works perfectly fine here on JSFiddle Upon debugging, it seems that the script is being invoked but the content is not loading wit ...