Customize bullet list icons to adjust in size based on content using css

In my CMS project, the CMS team has a special requirement regarding unordered and ordered lists. They want the size of the bullet list icon to adjust according to the text content within the list.

The image below shows the default design of a list item:

https://i.sstatic.net/kiaSF.png

However, in the image below, the size of the bullet list icon remains constant even if the text inside the list has a larger font-size:

https://i.sstatic.net/rLwyS.png

https://i.sstatic.net/amTxt.png

I have attempted to fix this issue with the following code, but it did not work:

ul {
    li {
        position: relative;
        list-style-type: none;
        padding-left: 9/@rem;
        &::before {
            content: "\2022";
            color: @primary-c1-hex1;
            font-weight: bold;
            display: inline-block;
            width: 1em;
            margin-left: -28/@em;
            padding-right: 11/@em;
            transform: scale(0.8);
        }
        >h6, >strong  h6, > b h6 {
            display: inline-block;
        }
    }
}

How can I make the size of the bullet list icons dynamic using CSS? If CSS alone is not sufficient, is there a workaround using JavaScript?

Answer №1

Typically, the size of list bullets adjusts to the font size of the parent element automatically. It appears that your CMS editor may not be adjusting the font size of the li or ul elements directly, but instead wrapping a container around the content (a common practice among many editors). You can try this code:

<ul>
    <li>One</li>
    <li>Two</li>
</ul>

<ul style="font-size: 2em;">
    <li>One</li>
    <li>Two</li>
</ul>

… but it seems like your CMS is doing this:

<ul>
    <li>One</li>
    <li>Two</li>
</ul>

<ul>
    <li><span style="font-size: 2em;">One</span></li>
    <li>Two</li>
</ul>

Check out this fiddle to see how it works.

If you want more control over the position and color of the circles, you could use something like this. However, if your editor handles text formatting differently, this approach might not be helpful as it relies on the parent's size and color just like native CSS bullets do.

I suggest reviewing the syntax generated by your CMS editor.

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

Identify the moment all Dropzones are added to a form

I am working on a page where multiple dropzones are set up for individual images. Once the user submits the form, all the images attached to the dropzones are resized and then added to the rest of the form fields. After resizing and appending the images, ...

Complete and submit both forms during a single event

Essentially, I have an event called onclick that takes form data and stores it in a variable. When another function is executed by the user, I want to send that variable through ajax within the function. This is the onclick event (first form): $('#n ...

Exploring the process of constructing this form with the assistance of Bootstrap

Create Dropdown Form https://i.sstatic.net/rqJtS.png I am looking to create a form that allows for updating team scores based on kills. I am struggling to divide the form into 2 sections for input, as demonstrated. I am using only bootstrap for styling, ...

Is there a dynamic element that cannot be accessed in the rest of the DOM?

Currently, I am facing an issue with a dynamically generated button using jQuery. This button is present on every row of my table, and I am looking to implement some functionality to it. However, my biggest challenge is selecting the parent elements of thi ...

Obtaining the attribute value of a disabled element in an Angular JS application

Currently, I am struggling to retrieve the attribute value of a disabled element during runtime and then assert its value. The code I'm using is not providing the desired result: softAssert.assertFalse(shrSub.nextButton().waitForPresent().getAttribu ...

Variations in the appearance of scrollbars on the x-axis and y-axis within a single <div> element

Let's say we have a div element like this: <div class="nav-menu"></div> I want to customize the CSS style for scrollbar using the ::scrollbar pseudo-element: .nav-menu::-webkit-scrollbar { width: 8px; background: white; ...

Ways to implement CSS styling to every input element excluding inputs located within list items of a specific class

input.not(li.tagit-new >input) { background-color: lightgrey; } <ul id="tagAdministrator" style="width: 505px" class="tagit ui-widget ui-widget-content ui-corner-all"> <li class="tagit-new" style="box-shadow: none;"> <input ty ...

Having trouble with AngularJS not sending form values properly?

I have a code snippet in my app.js file where I am trying to pass the value of email to a file named handler.php. $scope.doForget={email:''}; $scope.doForget = function (customer) { //email = $scope.forget.email; For Testing i am hardcoding ...

Using JavaScript ES6, we can access a specific array nested within a JSON array and loop through its elements by utilizing the

I have retrieved a JSON data from this link "response": [{ "id": "1", "title": "Star Wars", "project": [ "Star Wars Proj1", "Star Wars Proj2", "Star Wars Proj3", "Star Wars Proj4" ] }, { "id": "2", "titl ...

JavaScript: A guide to solving systems of equations

I'm attempting to perform algebraic operations in JavaScript using certain conditions and known variables. However, I lack proficiency in mathematics as well as JavaScript to comprehend how to articulate it. Here are the conditions: var w1 = h1/1.98 ...

Exploring the angular js repeater component's context menu options

In one of my current projects, the client has specifically requested a right-click menu feature. However, the challenge lies in ensuring that the function triggered by the menu options has access to relevant information from the model. For instance, you ...

Enhancing the functionality of an existing framework through the integration of a

My coding style involves a lot of ASP.NET MVC and jQuery, particularly with ajax calls that return json. Lately, I've been tinkering with organizing my code structure by creating an object within the global object which contains success and fail callb ...

Including additional data to a page after each iteration in order to display the current progress

I am currently working on a loop that iterates through the lines of a text area and processes each line sequentially. However, I am facing an issue where the page becomes unresponsive until all the data has been processed. Is there a way to dynamically u ...

Is there a way to adjust user privileges within a MenuItem?

One of my tasks is to set a default value based on the previous selection in the Userlevel dropdown. The value will be determined by the Username selected, and I need to dynamically update the default value label accordingly. For example, if "dev_sams" is ...

Tips for maintaining the original height of an image within an <img> element using HTML and CSS

I am facing an issue with a grid where I add grid-items, and then use the thumbnail class to provide dimensions to the thumbnail. When I insert an image into the <img> tag, it alters the height dimension, which is not desirable. I want the thumbnail ...

Utilizing Fullcalendar v5's sticky header feature alongside a Bootstrap fixed top navigation bar for a seamless

Currently experimenting with the latest version of fullcalendar 5.4.0. I have integrated the calendar into a bootstrap 4 web page that features a fixed navigation bar at the top. The issue arises when attempting to set stickyHeaderDates, aiming to keep th ...

Combining jQuery event handlers for two specific DOM elements into a single line

Task at hand involves running a single function on two elements within the DOM, each requiring different events. $("div.form-group").children("input,button").on("click blur",function(){ console.log("GO!"); }); Initially attempted to achieve this by t ...

Shaky parallax movement

I recently created a website with a parallax effect, but I'm experiencing some performance issues with jittery movement. The page uses CSS3 transform scale to zoom in and out, and automatically resizes on page resize with JavaScript/jQuery. For the ...

After removing an item from the array, React fails to display the updated render

As a newcomer, I am struggling with a particular issue. I have implemented a delete button for each item in a list. When the button is clicked, the object in the firstItems array is successfully deleted (as confirmed by logging the array to the console), b ...

What is the most efficient way to remove all typed characters from fields when clicking on a different radio button? The majority of my fields share the same ngModel on a separate page

Is there a way to automatically clear all typed characters in form fields when switching between radio buttons with the same ngModel on different pages? I noticed that the characters I type in one field are retained when I switch to another radio button. ...