Personalize the style of ordered lists

Greetings! I am attempting to customize the style of an ordered list like the one shown in the image on another website. https://i.sstatic.net/BQok4.png

However, instead of the circle used in that picture, I want to use a different CSS Image like the one (without text) shown here https://i.sstatic.net/qWoRZ.png

I've tried using the code provided by the other website, but I'm unsure how to change the blue circle to the green symbol. Can anyone assist me with this?

 .blog-blau-liste {
    position: relative;
    margin: 0.8em 0px 0px;
    list-style: outside none none;
    counter-reset: big-numba;
    padding-left: 0px;
}

.blog-blau-liste-item {
    position: relative;
    margin: 0.8em 0px 0px 1.9em;
    list-style: outside none none;
}

.blog-blau-liste-item::before {
    content: counter(big-numba, decimal);
    counter-increment: big-numba;
    position: absolute;
    top: -2px;
    font-size: 19px;
    left: -1.9em;
    box-sizing: border-box;
    width: 1.5em;
    height: 1.5em;
    line-height: 1.5;
    color: #FFF;
    background: #009DD9 none repeat scroll 0% 0%;
    font-weight: 600;
    text-align: center;
    border-radius: 50%;
}
    <ol class="blog-blau-liste">
<li class="blog-blau-liste-item">Point Number 1</li>
<li class="blog-blau-liste-item">Point Number 2</li>
<li class="blog-blau-liste-item">Point Number 3</li></ol>

Is there a way to achieve this and create the green logo (just the circle without text and white line) using CSS?

I came across this code which is not rounded, and I'm unsure how to implement it.

#burst-8 {
    background: red;
    width: 80px;
    height: 80px;
    position: relative;
    text-align: center;
    -webkit-transform: rotate(20deg);
       -moz-transform: rotate(20deg);
        -ms-transform: rotate(20deg);
         -o-transform: rotate(20eg);
}
#burst-8:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 80px;
    width: 80px;
    background: red;
    -webkit-transform: rotate(135deg);
       -moz-transform: rotate(135deg);
        -ms-transform: rotate(135deg);
         -o-transform: rotate(135deg);
}
<div id="burst-8">1</div>

Answer №1

Creating Shapes Using ::after and ::before Pseudo Elements

A new method has been developed to create shapes using the ::after and ::before pseudo elements in CSS. This technique combines previous approaches mentioned in earlier responses, with a limitation of only being able to create shapes with 8 sides. To overcome this limitation, additional HTML elements would need to be created within each li element. Here is an example of how this can be achieved:

.shape-list {
    list-style: none;
    counter-reset: shape-list-number;
}

.shape-list li { position: relative; margin-bottom: 20px;}

.shape-list li::before, .shape-list li::after {
  content: '';
  display:inline-block;
  vertical-align: middle;
  height: 50px;
  line-height: 50px;
  width: 50px;
  background: green;
  border-radius: 10px;
  font-size: 2em;
  color: #FFF;
  text-align: center;
}

.shape-list li::before {
  content: counter(shape-list-number, decimal);
  counter-increment: shape-list-number;
  margin-right: 20px;
}

.shape-list li::after {
  content: '';
  z-index: -1;
  position: absolute;
  left: 0;
  transform: rotate(45deg);
}
<ol class="shape-list">
  <li>Number 1</li>
  <li>Number 2</li>
  <li>Number 3</li>
</ol>

Check out the live demo on jsFiddle: https://jsfiddle.net/azizn/Lda7hwkj/

The key aspect of this method is that the transformation is applied to the ::after pseudo-element so that it does not impact the number displayed. By adding a z-index of -1, the ::after element is positioned behind the ::before element to prevent overlapping.


Original Approach:

To apply images as backgrounds to each li element's ::before pseudo-element, follow this code snippet:

.image-list {
    list-style: none;
}

.image-list li::before {
  content: '';
  display:inline-block;
  vertical-align: middle;
  height: 50px;
  width: 50px;
  background: url("https://i.sstatic.net/qWoRZ.png") no-repeat center;
  background-size: contain;
  margin-right: 10px;
}
<ol class="image-list">
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ol>

View the implementation on jsFiddle: https://jsfiddle.net/azizn/ffyrhu7o/


Edit: For those looking to recreate shapes using pure CSS, utilize the border-radius property for smooth edges. Here's an example:

body {margin:3em;}

.custom-shape {
  background: green;
  width: 80px;
  height: 80px;
  line-height: 80px;
  font-size: 2em;
  color: #FFF;
  position: relative;
  text-align: center;
  border-radius: 10px;
}

.custom-shape::before, .custom-shape::after {
  content: "";
  position: absolute;
  z-index:-1;
  top: 0; left: 0; bottom: 0; right: 0;
  background: inherit;
  border-radius: inherit;
  transform: rotate(27deg);
}

.custom-shape::after {
  transform: rotate(-30deg);
}
<div class="custom-shape">1</div>

Experiment with the code on jsFiddle: https://jsfiddle.net/azizn/r3wtjemr/

Answer №2

ul{ 
    list-style-image: url("CustomImage.png") 
}

Answer №3

To enhance the look of your sentences, consider incorporating a png image at the beginning of each one. This simple touch will add visual interest without overwhelming your page. You have endless possibilities for customization to suit your aesthetic preferences. For dynamic effects, explore options such as:

  • applying a class attribute + Jquery (utilizing before, for instance)
  • exploring the use of ul list-style-image
  • or experimenting with CSS before pseudo-element like you did before - check out this insightful post

Answer №4

    .vegan-list {
        list-style: none;
      counter-reset: section;
    }

    .vegan-list li::before {
       counter-increment: section;
    content: counter(section);
      display:inline-block;
      vertical-align: middle;
      height: 50px;
      width: 50px;
      background: url("https://i.sstatic.net/qWoRZ.png") no-repeat center;
      background-size: contain;
       line-height: 50px;
    text-align: center;
    font-size: x-large;
    color: brown;
    }
    <ol class="vegan-list">
      <li>Item Number 1</li>
      <li>Item Number 2</li>
      <li>Item Number 3</li>
    </ol>

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

Turn off the functionality of Telerik in DotNetNuke

After installing the DNN module on a remote machine, I noticed that it altered the CSS styling. Upon inspecting it with Firebug, I discovered that the styles causing issues are located in telerik.web.ui.webresource.axd, making it difficult to overwrite the ...

CSS: Trouble with elements positioning

I am attempting to position two boxes on top of each other at the bottom of a different div. Here is the code I have: <div style = "height:400px;width:400px;border:1px solid #000;"> <div style = "position:relative;height:100px;width:100px;bor ...

What could be causing my div to display a horizontal scrollbar in Firefox?

Here's a straightforward test scenario: <html> <body> <div style="border:2px solid black; overflow: auto;"> x </div> </body> </html> Upon rendering, a horizontal scrollbar appears! I was using F ...

hide the side menu automatically - wordpress

is the official website created using a WordPress platform. Upon visiting the site, you will immediately notice a prominent "showcase" banner positioned right below the navigation bar. On the right side, there are additional posts that users can choose t ...

Issue with IE failing to load a particular Stylesheet

Have you had a chance to view this live demonstration? My website has two different stylesheets, one specifically for Internet Explorer and another for regular browsers. Here's how they are set up in the header: <link rel="stylesheet" type="text/c ...

NodeJS for CSS Parsing and Selecting

Can anyone recommend a NodeJS library similar to https://github.com/alexdunae/css_parser? I have tried using https://github.com/visionmedia/css, but it doesn't fulfill all my requirements. For example, when I parse the following CSS: .behavior1 {co ...

Expanding divs automatically depending on the content they contain

Currently, I have been developing a template for a database-driven page that is supposed to contain four divs for content arranged like this: ----- ----- | 1 | | 2 | ----- ----- ----- ----- | 3 | | 4 | ----- ----- The information in each box will always ...

Tablet displaying incomplete background image

I am facing an issue with my background image only showing inside the content blocks, as you can see in the screenshot. I have a small fadeIn animation for the content, but nothing else special. Here is the CSS code I am using: .template_home { backgro ...

Web Dialogue Dimensions: Adjusting the MDC-Web Dialog Width

When designing a dialog following Material Design guidelines, one issue that often arises is how to handle the width of the dialog on larger viewports such as tablets and desktops. Some sources suggest using increments of 56px for dialog width, but it&apos ...

The server mistakenly sent the resource as a Stylesheet even though it was interpreted differently

Dear Fellow Coders, Could anyone lend a hand? I encountered this issue on my website after uploading it to my FTP: "Resource interpreted as Stylesheet but transferred with MIME type text/plain" </head> <body> <div class= "navbar navbar ...

Incorporating a unique BRAND logo as the header of an HTML page

https://i.sstatic.net/NV5BO.jpg Currently enhancing my front end development skills with HTML and CSS. I am trying to set up a menu bar with an image (header image) above it. However, I am facing issues in displaying the image stored in my images folder. ...

AngularJS input range is written inside the bubble that crosses over the screen

Is there a way to write inside the bubble of the range slider? I have adjusted the design of the range slider and now I simply want to display the number inside the bubble: Please see image for reference I aim to display the number inside a circle. What ...

Matching up irregular rows in div-made table

I have created a table using div elements that contain images as cell data. When an image is missing, I would like to center the remaining images in the row like this: With all images present: xxxxx xxxxx Missing images (2 in the second row): xxxxx xx ...

How to ensure HTML elements are styled to occupy the full width of their parent container while respecting the minimum width requirement

Is there a way to make HTML elements have a width ranging from 150px to 200px while filling up 100% of their parent's width? Check out Image 1: https://i.sstatic.net/nYNGp.jpg And here is Image 2 (after resizing the window): https://i.sstatic.net/ ...

What is causing the pull-right class to not function correctly in Bootstrap version 4.1.0?

After upgrading from Bootstrap version 3+ to 4.1.0, I encountered an issue with aligning elements using pull-right and pull-left, as well as float-right and float-left. The problem persists despite my efforts. Here is an image (https://i.sstatic.net/Z6ba3. ...

JavaScript function to toggle the visibility of navigation with a click of a button

I'm attempting to create a functionality in my code where the Open navigation button hides when the side navigation opens upon clicking. The desired behavior is for the openNav button to be hidden when it's clicked and then shown again when close ...

When a child of a flex-item does not inherit the height of its parent in a flex container with a column direction and flex-basis set

Wow, that title was long! Let me try to clarify my confusion: So I have a flex-container with 2 flex items. <!-- HTML --> <div class="container"> <div class="item-1"> <div class="child-of-item-1"></div> < ...

Unexpected blank space detected at the bottom of the page in Angular 13

Using the NGX-ADMIN template built on Angular 12 has been smooth sailing until an upgrade to Angular 13. With this simple version change, I am now faced with a perplexing issue that I can't seem to pinpoint or resolve. I can confidently say that shif ...

What is the best way to ensure that all components within a Container automatically inherit its calculated width?

Check out my tab panel setup on Sencha fiddle. The buttons are dynamically added to a tabs container with a layout of hbox within a vbox. The width of the tabs container is determined by the flex property. I attempted to set each button's width to &a ...

Addressing the spacing and alignment issues within the progress bar

I need some help with my Angular app. I am currently working on creating a progress bar, but I am facing some issues with the alignment of the bars. Here is the code snippet that I have used: CSS: .progressbar { position: relative; height: 56px; mar ...