Tips for perfectly aligning an "inline-block" element with an ordered list (ol)

I'm experiencing an issue with the alignment of my ordered list. My list is structured as follows:

<ol type="a">
  <li><button style="display: inline-block">TEXT1</button></li>
  <li><button style="display: inline-block">TEXT2</button></li>
  <li><button style="display: inline-block">TEXT3</button></li>
  <li><button style="display: inline-block">TEXT4</button></li>
</ol>

When the text is short, it aligns next to the order character like this:

However, when the text is longer, it jumps to the next line instead of aligning on the same line with the order like this:

Edit: It has been pointed out that I missed some attributes for my LI in order to reproduce the problem. Each LI element also has "list-style-position: inside" CSS, which seems to be the source of the issue.

Is there a solution to correct this so that the button will align next to the order instead of jumping to the next line?

Answer №1

The appearance is quite pleasing to the eye. Take a look at this example. It appears there may be additional CSS styles impacting the display. Kindly provide the CSS for further review. If concerned about multiple lines, consider utilizing the following:

ul li a {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

Given that you have specified list-style-position: inside, try implementing the following:

li {list-style-position: inside;}
li a {width: 80%;} 

Check out the Live Demo: Example

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

Exploring the Relative Positioning of Two div Elements

Can anyone assist me with finding and comparing the positions of two '<div>' tags using an if statement? I stumbled upon a suggestion in my research, which goes like this: var obstacle = $('#obstacle').css('left', &apo ...

Hide the border below the active tab

Could anyone assist me in removing the border below the selected tab? I've attempted multiple approaches without success. I experimented with adding a negative margin to the tab and creating a white border, but as the border I want to conceal is from ...

Creating stylish rounded corners for the table header with a specific background color using CSS

I am a beginner in HTML/CSS and I am trying to create a table with rounded top corners and a different background color for the header line. I have been able to achieve each individually with the help of online resources but I am struggling to combine the ...

The column with a class of col-md-3 is not rendering properly

The design shown below was created in photoshop utilizing a 12 grid system: https://i.sstatic.net/MSGHc.jpg I am attempting to replicate this layout using bootstrap with class='col-md-3' for each input. However, when I do this, they appear next ...

Issues with inline display not being rendered properly in HTML/CSS

I've been attempting to place an image and an h1 element on the same line. After researching online, I attempted using display:inline; for both the parent div element as well as each individual element. This is my current code: <div style="displa ...

Guide to altering the color of a list item when hovering in HTML

Is there a way to change the color of the <li> element only when hovering over it, without affecting its parent or child elements? Here is an example: HTML: <div id="tree"> <ul> <li>apple</li> <li>banana</l ...

Arrange divs in a grid layout with evenly distributed dynamic spacing

I am not a big fan of bootstrap, so I was wondering if it is possible to achieve the layout without using it. I have 6 divs that I want to arrange in 2 rows and 3 columns. I need the space between each row/column to be precise. While I can calculate this ...

Empower the parent container to wrap around its child elements using Flexbox

I am trying to make the flexbox parent item adjust its width based on the children, but currently it is stretching out to full width and leaving empty space on the right side. Here is the CSS code I have tried: .flexParent { display:flex; background:# ...

Arranging the Burgers on the Menu using Flexbox

I'm looking to develop a simple note-taking app, but I'm struggling to figure out how to place a burger menu on the right side of a flexbox. Below are my JS and CSS files: JavaScript / HTML <div className={styles.wrapper}> < ...

Unable to fetch css file in Node.js

I am currently in the process of learning Node.js, but I have encountered a small issue with retrieving data from a css file. Interestingly, when I directly add the data to the index file's code, it seems to work perfectly. Let me share the relevant ...

What is the best way to incorporate web components into a React Js project?

I am currently unfamiliar with web components. My main goal is to integrate Google Material Components into my React.js project. Google Material Web Component can be found here: https://github.com/material-components/material-components-web Is there a ...

I am interested in designing a dynamic wave-themed background for a menu

I am looking to create a menu background that ripples like a wave when hovered over. Check out the first example here: https://i.sstatic.net/LoOWM.png I want to achieve the same effect. Can anyone help me with how I can do this? <ul> <li>likk ...

JQuery Mobile: Styling does not apply to dynamically populated Select elements

I've been struggling to apply jQuery Mobile styles to a select element that is dynamically filled. Even after attempting to add themes, manual styles, refreshing, $('.ui-page-active').trigger('create');, and more, I still can' ...

Position the button at the corner of the textarea

How can I position two buttons below a text_area, aligned with the bottom right corner of the text area? Here is what I have tried so far: https://i.sstatic.net/UcD2F.png Current code snippet: form with modal <%= form_for @note, :url => registrant ...

How to dynamically change the color of an AngularJS element based on a condition?

As someone who is new to AngularJS, I am currently working on changing the color of a table element to yellow if the user has voted on a specific choice. <div ng-show="poll.userVoted"> <table class="result-table"> <t ...

A Guide to Configuring jQuery UI Slider with Three Distinct Colors

I'm currently implementing the UI Slider on my website. However, I would like to customize the slider with three different colors: Handle Color Previous portion of Handle Next portion of Handle I want it to look something like this: Currently, I h ...

"Troubleshooting: The Challenge of a Persistent Footer's

I came across a sticky footer that met my needs, but now I am facing an issue. When I increase the resolution beyond my normal setting, the code works fine but there is spacing between the container div and the footer div. I have attached a screenshot to s ...

Creating a visual list in a React JS component with images and text

Hey there, I'm new to react js and I'm looking to create a list with images and text using html, css, and bootstrap. The list should include song images and have options for download and liking them after the user clicks on three dots. I've ...

Place the div at the center within the header

I'm struggling to center the logo in my media query for screens below 479px. Whenever I use margin auto, the image gets pushed to the right by the browser. Here is what I have so far and any assistance would be greatly appreciated. HTML <div clas ...

Can JavaScript impact the appearance of the printed version of a website?

Just a quick question - I currently don't have access to a printer. My client is wondering if the hidden elements of the webpage (items that are only visible when clicked on) will be included when printing or if they will remain hidden? ...