The art of adjusting list padding and margin to fit varying screen sizes

When dealing with Roman numerals in lists, the width of the numeral can vary significantly from one <li> to another.

For example, you may have II next to XVII.

I am struggling to find the perfect padding for lists to ensure that wide "bullets" do not get cut off and narrow bullets are not awkwardly indented without reason.

In essence, I am seeking a CSS solution to achieve the optimal left spacing so that bullets or numerals are never clipped.

Answer №1

Your valid concerns about awkward indenting are noted. However, the nature of ordered lists often leads to this issue. To prevent clipping problems, you can utilize the following CSS declaration:

li {
    list-style-position: inside;
}

By implementing this declaration, clipping should be avoided. Keep in mind that depending on the numeral length, the content of your list item may appear further inward.

Answer №2

Uncertain if this is the solution you need without an example, but give this a try:

ul {
    list-style: upper-roman;
    margin: 0 0 0 2em ;
}

Feel free to adjust the value for margin according to your preference. JSfiddle link here.

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 <iframe> generated by Create-React-App often hinders my ability to interact with or modify the application directly, requiring me to remove it using the browser's element editor

After conducting a global installation of create-react-app, I encountered an issue where instead of editing the rendered content directly in the browser while working on a project, there is a mysterious container created around my app. Upon closer examina ...

How does HTML calculate the percentage-based size of a child element when the parent element has padding?

After analyzing the scenario presented, it appears that the outer yellow box is 240px wide (200 width plus 20 padding on each side). The red child inside has its width set at 50%. Surprisingly, when rendered, the red box measures 140px in width. You can v ...

Avoid reloading the page in PHP when the browser back button is clicked

I've built an HTML form where the values are passed to a second page using POST method. On the second page, I have an edit button that, when clicked, redirects back to the HTML form page with the user's typed values. However, my dilemma is figuri ...

Organize elements in a grid using CSS styling

I have designed a layout using grids, featuring two menus on the left and right, with a central area for content. Within the content area, there is a 4x4 grid layout. Here's an example of the 4x4-grid layout: https://codepen.io/mannberg/pen/qemayy h ...

Is it possible for HTML to call library scripts in the sidebar?

I recently encountered an issue with a sidebar created in HTML on Spreadsheets. Everything was working perfectly until I moved the code to the main library where all the code is managed. Now, it seems that the function used by the sidebar is undefined. How ...

Is there a way to adjust the font size for the label in mat-step?

Is there a way to update the design using only inline styles and CSS? Below is the code snippet I am working with: <div class="statusbar"> <mat-horizontal-stepper linear > <mat-step label="One" [complet ...

Swift: NSAttributeString generates unexpected HTML output

I attempted to use NSAttributeString to parse HTML, but encountered a problem when trying to display a table within a list item. <ol> <li>first <table> <tbody> <tr> ...

Enhancing WordPress Menu Items with the 'data-hover' Attribute

Looking for a solution to add "data-hover" to menu items on Wordpress, like: Wanting to insert: data-hover="ABOUT US" into <a href="#">ABOUT US</a> without manually editing the link's HTML to make it: <a href="#" data-hover="ABOU ...

Chic and perfectly aligned stripe button design

I need assistance with centering and styling the Stripe checkout button labeled "update card." Additionally, I want to adjust the appearance of the card number input field to be normal but readonly. How can I achieve this without relying on Bootstrap' ...

Form Validation Issues Detected

Could someone help explain why the code below is causing an error according to W3C guidelines: <form id="" method="post" action="" /> <input type="text" name="" title="" tabindex="10" class="" /> <inp ...

Adjust the width of the list items based on the specified condition

I need assistance with adjusting the width of items in a list. The list includes: <ul> <li>One</li> <li>One-One</li> <li>Two</li> <li>Two-Two</li> </ul> The display should be dyn ...

I'm running into an InvalidSelectorError and I could use some assistance in properly defining

As I gaze upon a massive dom tree, my task using NodeJS/Selenium is to locate an element by the title attribute within an anchor tag and then click on the associated href. Despite being a newcomer to regex, I am encountering numerous errors already. Below ...

Adjusting Text Size Depending on Width

I recently used an online converter to transform a PDF into HTML. Check out the result here: http://www.example.com/pdf-to-html-converted-file The conversion did a decent job, but I'm wondering if it's feasible to have the content scale to 100% ...

What is the best way to incorporate JSON data into an HTML document?

Currently, I am working on a project involving the creation of a playable ad for Facebook. Per Facebook's ad specifications (), only a single HTML file under 2mb is accepted for uploading. This necessitates the inlining of all external references into ...

What could be causing the a element tag to not affect the links? Is the syntax correct?

Why aren't my CSS properties affecting the links in my navigation bar? I want the styling to apply only to the links inside the #nav id, but it doesn't seem to be working. Can anyone help me figure out what the issue might be? CSS CODE: a#nav:l ...

Is Amazon altering the names of their CSS selectors and HTML elements on the fly?

For my Amazon.es web scraper built with Selenium, I am using a CSS selector to determine the total number of pages it will iterate through. However, the selector name seems to change dynamically and I must update it daily. As someone not well-versed in H ...

Image showcasing the background

I'm facing an issue with adding a background image to my project Even after trying to add it globally, the background image is not showing up on the Next.js index page. import { Inter } from 'next/font/google' const inter = Inter({ subsets: ...

Relocate a table beside an image

Check out the layout of my webpage: ------------- ------------- Image here ------------- ------------- Table1 here Table2 here Table3 here My goal is to redesign it to look like this: ------------- ------------- Image here Table1 here - ...

Tips on achieving horizontal scrolling for div overflow instead of wrapping onto a new line

It's a frequent occurrence in mobile apps to have a navbar with selectable text options that overflow horizontally without breaking into a new line. Instead, users must scroll horizontally to access all the options available. Is there a way for me to ...

Unable to retrieve data-id from <td> on click event

Can someone help with an issue I'm having in my code? Here is the snippet where I create a table data element: html += "<td data-id='test' class='journal' style='max-width:200px;'>"+record.source_account_code+"& ...