1

I'm using SharePoint Designer and I would like to apply a custom bullet on the parent li (Desc 1 and Desc 2) of my list, but what's happening is that it is being applied on all the list items including the children li. Can someone help me with it? how it should be done correctly in CSS? Thanks.

.tab-content.content-show ul li {
    list-style-image: url(/img.png);
}

.tab-content.content-show ul li > li {
    list-style-image: none !important;
}
<div class="tab-content content-show" data-content-id="1" id="content-1">
    <div>
        <ul>
            <li>Desc 1 </li>
            <ul>
                <li>details 1</li>
                <li>details 2</li>
                <li>details 3</li>
                <li>details 4</li>
            </ul>
            <li>Desc 2 </li>
            <ul>
                <li>details 1</li>
                <li>details 2</li>
                <li>details 3</li>
                <li>details 4</li>
            </ul>
        </ul><br>
    </div>
</div>
Minal Chauhan
  • 6,025
  • 8
  • 21
  • 41
Xev
  • 109
  • 1
  • 1
  • 12

8 Answers8

1

To select the direct children and not the grandchildren, you can use ">" as shown below

.tab-content.content-show div > ul > li {
    list-style-image: url(/img.png);
}

And no need for 2nd class.

here is the customized css:

.tab-content.content-show div > ul > li {
    background: url("https://www.kindpng.com/picc/m/313-3131657_blue-bullets-icon-png-transparent-png.png") left center no-repeat;
    background-size:20px;
    padding: 0 0 0 40px;
    
}
Sunny
  • 101
  • 1
  • 3
  • 9
1

You were pretty close. Your CSS should look like this:

.tab-content.content-show div > ul > li {
    list-style-image: linear-gradient(to left bottom, red, blue);
}
<div class="tab-content content-show" data-content-id="1" id="content-1">
    <div>
        <ul>
            <li>Desc 1 </li>
            <ul>
                <li>details 1</li>
                <li>details 2</li>
                <li>details 3</li>
                <li>details 4</li>
            </ul>
            <li>Desc 2 </li>
            <ul>
                <li>details 1</li>
                <li>details 2</li>
                <li>details 3</li>
                <li>details 4</li>
            </ul>
        </ul><br>
    </div>
</div>

The Child Selector (>) applies the CSS rules to the direct children of the particular element.

See this related answer: https://stackoverflow.com/a/4830672/801544

Note I've used a gradient instead of an image just to show that it works, but you can use any image instead.

Simone
  • 20,302
  • 14
  • 79
  • 103
1

you should use "ul:first-child" in css:

.tab-content.content-show ul:first-child > li{
    list-style-image: url(https://www.w3schools.com/cssref/sqpurple.gif);
}
<div class="tab-content content-show" data-content-id="1" id="content-1">
    <div>
        <ul>
            <li>Desc 1 </li>
            <ul>
                <li>details 1</li>
                <li>details 2</li>
                <li>details 3</li>
                <li>details 4</li>
            </ul>
            <li>Desc 2 </li>
            <ul>
                <li>details 1</li>
                <li>details 2</li>
                <li>details 3</li>
                <li>details 4</li>
            </ul>
        </ul><br>
    </div>
</div>
mojgan kiyani
  • 91
  • 1
  • 4
0

Do you have access to the HTML code? If yes I would put a class on the li you are interested in.

<li class="custom-bullet">Desc 1</li>

.custom-bullet {
   list-style-image: url(/img.png);
}
Laxmana
  • 1,606
  • 2
  • 21
  • 40
  • Sadly I don't have access to the
  • of the parent list items. Those lists are coming from the backend and are bulleted already. @Laxmana
  • – Xev Jun 22 '21 at 08:50