Enhancing list types with CSS styles

I am looking to achieve a unique style for my list that resembles the design in the image linked below. I want an ordered list with purple numbers paired with an unordered list featuring yellow bulletshttps://i.sstatic.net/ohReN.png

However, my current styling looks like thishttps://i.sstatic.net/Kwncx.png. My HTML structure consists of a ul list inside an ol list. Here is the HTML code:


        ul {
    padding-left: 20px;
    }
    ul li {
    list-style: none;
    position: relative;
    margin-bottom: 7px;
    }
    ul li:before {
    color: #F5C400;
    content: '\2022';
    font-size: 1.2em;
    position: absolute;
    top: -.2em;
    left: -1em;
    }
    ul li ul li:before {
    content: '\25cB';
    }
    .nav-item:before {
    content: '';
    padding: 0;
    }
    ol li {
    list-style-type: none;
    counter-increment: list;
    position: relative;
    }
    ol li:before {
    content: counter(list) ".";
    position: absolute;
    left: -2em;
    text-align: right;
    color: #893579;
    }
<div class="card-body">
                                      <p>We know there are many things to consider, so ask yourself some of the following questions to help narrow down your choices.
                                          <ol>
                                              <li><b>Do you prefer to pay more out of your paycheck (premiums) and less when you get medical care or the other way around? </b></li>
                                                <ul>
                                                    <li>The Gold plan premiums are quite a bit higher, but the plan covers more of the cost when you need medical care and begins sharing the cost of your care sooner.</li>
                                                    <li>The Bronze plan premiums are the lowest, but you will pay more of your medical care costs.</li>
                                                    <li>The Silver plan is in the middle.</li>
                                                </ul>
                                              <li><b>Are you and your family generally healthy, often just getting preventive care during the year?  </b></li>
                                              <ul>
                                                  <li>Take a closer look at the Bronze plan.</li>
                                              </ul>
                                              <li><b>Does someone have a chronic condition or a potential surgery expected in 2019?</b></li>
                                              <ul>
                                                  <li>Consider the Gold and Silver plans since you know you will have significant medical expenses.</li>
                                              </ul>
                                              <li><b>Do you or a family member take prescription drugs regularly?</b></li>
                                              <ul>
                                                  <li>The Gold plan pays a higher percentage of the cost of medications.</li>
                                              </ul>
                                        </ol>
                                              You don’t have to figure it out by yourself. Visit ALEX®, your virtual benefits counselor, to help you decide which plan will work best for you and your family next year. <br>
                                      </p>
                                 </div>

We understand that there are many aspects to consider, so we have listed some questions to help guide your decision-making process when selecting a suitable plan for you and your family. Feel free to reach out if you need further assistance. Thank you!

Answer №1

While you're making great progress, it's important to consider the nesting of lists in your styling.

Using ul li will affect all li elements within the ul, including nested lists. To target only direct children, use ul > li and ol > li.

Here are the changes that should be made:

    ul {
    padding-left: 20px;
    }
    ul > li {
    list-style: none;
    position: relative;
    margin-bottom: 7px;
    }
    ul > li:before {
    color: #F5C400;
    content: '\2022';
    font-size: 1.2em;
    position: absolute;
    top: -.2em;
    left: -1em;
    }
    ul li ul li:before {
    content: '\25cB';
    }
    .nav-item:before {
    content: '';
    padding: 0;
    }
    ol > li {
    list-style-type: none;
    counter-increment: list;
    position: relative;
    }
    ol > li:before {
    content: counter(list) ".";
    position: absolute;
    left: -2em;
    text-align: right;
    color: #893579;
    }
<div class="card-body">
                                      <p>We know there are many things to consider, so ask yourself some of the following questions to help narrow down your choices.
                                          <ol>
                                              <li><b>Do you prefer to pay more out of your paycheck (premiums) and less when you get medical care or the other way around? </b></li>
                                                <ul>
                                                    <li>The Gold plan premiums are quite a bit higher, but the plan covers more of the cost when you need medical care and begins sharing the cost of your care sooner.</li>
                                                    <li>The Bronze plan premiums are the lowest, but you will pay more of your medical care costs.</li>
                                                    <li>The Silver plan is in the middle.</li>
                                                </ul>
                                              <li><b>Are you and your family generally healthy, often just getting preventive care during the year?  </b></li>
                                              <ul>
                                                  <li>Take a closer look at the Bronze plan.</li>
                                              </ul>
                                              <li><b>Does someone have a chronic condition or a potential surgery expected in 2019?</b></li>
                                              <ul>
                                                  <li>Consider the Gold and Silver plans since you know you will have significant medical expenses.</li>
                                              </ul>
                                              <li><b>Do you or a family member take prescription drugs regularly?</b></li>
                                              <ul>
                                                  <li>The Gold plan pays a higher percentage of the cost of medications.</li>
                                              </ul>
                                        </ol>
                                              You don’t have to figure it out by yourself. Visit ALEX®, your virtual benefits counselor, to help you decide which plan will work best for you and your family next year. <br>
                                      </p>
                                 </div>

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

Clicking does not trigger scrollIntoView to work properly

I'm facing an issue with a button that is supposed to scroll the page down to a specific div when clicked. I implemented a scrollIntoView function in JavaScript and attached it to the button using onClick. Although the onClick event is functioning as ...

What are the reasons that execCommand does not function correctly when attempting to justify text?

Why isn't justify with execCommand working properly? Take a look at the code below: $('#JustifyLeft').click(function(){ document.execCommand("JustifyLeft", false, ""); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2 ...

What is the best way to ensure that form inputs and labels stay aligned?

Let's consider a scenario where there is a web page containing a form: <form> <label for="FirstName">First:</label> <input name="FirstName" type="text"> <label for="MiddleName">Middle:</label> <input n ...

Is it possible to apply a PNG icon collection using CSS?

Throughout various examples, jQuery plugins, and CSS-styled HTMLElements, I have observed the setting of icons on an image with multiple options. I am eager to implement this practice in my own apps. https://i.sstatic.net/WDCH3.png For instance, in the ...

Angular causes HTML Dropdown to vanish once a null value is assigned

In my scenario, I have two variables named power and mainPower. Both of these variables essentially represent the same concept, with mainPower storing an ID of type Long in the backend, while power contains all attributes of this data transfer object. The ...

How can I make the background of a button change when I move my cursor over it

Is it possible to change the background image of a button when hovering over it? Perhaps have the image transition from left to right for a fading effect? Can this be accomplished? ...

The error message "Your session has expired" is displayed by the Wysiwyg

The WysiwygPro editor displays a dialog error message stating, "Your editing session has expired. This is usually caused by a long period of inactivity. Please re-load the page," when clicking on any controls such as Image, Media, Emoticon, etc. This iss ...

The masonry reorganization is behaving strangely

I've recently started using masonry for the first time and you can check it out here: Although I have managed to set it up, I am facing some issues with its positioning of boxes when dragging items in. For example, instead of placing a medium-sized ...

Rounded Corners on an HTML5 Canvas Triangle

Hi there, I'm relatively new to working with HTML5 Canvas and I'm currently attempting to create a triangle with rounded corners. So far, I've experimented with: ctx.lineJoin = "round"; ctx.lineWidth = 20; However, I haven't been suc ...

Ways to create auto-suggest recommendations that exceed the boundaries of the dialogue container

Is there a way to position autosuggest suggestions above the dialog instead of within it, in order to prevent scrolling of dialog content? Check out this sandbox example for reference: https://codesandbox.io/embed/adoring-bogdan-pkou8https://i.sstatic.net ...

"Enhance User Experience: Use CSS to highlight text selection based on

As a beginner in the world of css and html, I am eager to create a webpage that showcases a list of names with the ability to select one or multiple names. Instead of simply checking a box on the side, I would love for the background of the selected text t ...

Compact NiceScroll Scroller within a narrower div compared to the width of the scrolled div

I am currently working on a table layout where I have fixed two columns on the left, similar to what is shown in this example. To enhance the scrolling experience, I am using the nicescroll plugin. However, I have encountered an issue where the plugin be ...

Personalize your Native Base tab design

Recently, I've delved into the world of React Native and now find myself in need of assistance with customizing my tabs. Utilizing advanced tabs by Native Base, I aim to transform this: https://i.stack.imgur.com/xhNwP.png Into something more akin ...

Developing interactive checkboxes for individual rows through React.js

Within a form, I have rows containing two inputs each. Upon clicking "add", a new row is created. For the second row onwards, by clicking "add" a checkbox labeled 1 should be added to indicate dependency on the previous row. In addition, for the third row, ...

PHP and jQuery creating a three-tiered drop-down navigation menu

My task involves creating a jQuery dropdown menu using PHP-generated HTML from a database table of categories: cats (db table) <ul class="dropdown"> <?php $sql ='SELECT * FROM cats WHERE cat_parent = 0'; $result = $db->s ...

PHP Exception with dual inputs

I am currently exploring the best approach for capturing messages in my PHP code but I'm unsure if it's even possible. Within my simple PHP structure, I am using try and catch blocks like this: if (!$this->issetAndNotEmpty($id)) ...

Issue "The only acceptable numeric escape in strict mode is '' for styled elements in Material-UI (MUI)"

Attempting to utilize the numeric quote for quotation marks, I encountered an issue: 'The sole legitimate numeric escape in strict mode is '\0` The snippet of code causing the problem can be seen below: export const Title = styled(Typogra ...

Dynamic <figcaption> that adjusts to different screen sizes with smooth animations

My first WordPress theme is almost complete and I'm excited to share it: The responsive image grid on the homepage is giving me some trouble. When I shrink the browser window, the images don't scale properly. The grid works fine without the JS ( ...

Scroll through the menu with ease

I am facing an issue with my menu that has 2 levels. Whenever I try to scroll down, I want the position of the Logo to change to the bottom of the menu smoothly. However, during scrolling, there is a noticeable shake in the menu movement which makes it app ...

Unable to adjust iframe height

Below is a snippet of code that I am working with: <style type="text/css"> .div_class { position:absolute; border:1px solid blue; left:50%; margin-left:-375px; margin-top:100px; height:300px; width:500px; overflow:hidden; } .iframe_class { position: ...