How to control size of list-style-type disc in CSS?

后端 未结 11 1195
暗喜
暗喜 2020-12-23 17:24

My HTML first:

相关标签:
11条回答
  • 2020-12-23 17:49

    I have always had good luck with using background images instead of trusting all browsers to interpret the bullet in exactly the same way. This would also give you tight control over the size of the bullet.

    .moreLinks li {
        background: url("bullet.gif") no-repeat left 5px;
        padding-left: 1em;
    }
    

    Also, you may want to move your DIV outside of the UL. It's invalid markup as you have it now. You can use a list header LH if you must have it inside the list.

    0 讨论(0)
  • 2020-12-23 17:52

    I'm surprised that no one has mentioned the list-style-image property

    ul {
        list-style-image: url('images/ico-list-bullet.png');
    }
    
    0 讨论(0)
  • 2020-12-23 17:55

    Instead of using position: absolute, text-indent can be used to solve the "inside" problem:

    li {
        list-style: inherit;
        margin: 0 0 4px 9px;
        text-indent: -9px;
    }
    li:before {
        content: "· ";
    }
    

    http://jsfiddle.net/poselab/zEMLG/

    0 讨论(0)
  • 2020-12-23 17:56

    Since I don't know how to control only the list marker size with CSS and no one's offered this yet, you can use :before content to generate the bullets:

    li {
        list-style: none;
        font-size: 20px;
    }
    
    li:before {
        content:"·";
        font-size:120px;
        vertical-align:middle;
        line-height:20px;
    }
    

    Demo: http://jsfiddle.net/4wDL5/

    The markers are limited to appearing "inside" with this particular CSS, although you could change it. It's definitely not the best option (browser must support generated content, so no IE6 or 7), but it might be the easiest - plus you can choose any character you want for the marker.

    If you go the image route, see list-style-image.

    0 讨论(0)
  • 2020-12-23 17:57

    I think by using the content"."; The dot becomes too squared if made too big, thus I believe that this is a better solution, here you can decide the size of the "disc" without affecting the font size.

    li {
        list-style: none;
    	  display: list-item;
    	  margin-left: 50px;
    }
    
    li:before {
        content: "";
    	  border: 5px #000 solid !important;
    	  border-radius: 50px;
    	  margin-top: 5px;
    	  margin-left: -20px;
    	  position: absolute;
    }
    <h2>Look at these examples!</h2>
    <li>This is an example</li>
    <li>This is another example</li>

    You edit the size of the disk by editing the size of the border px. and you can adjust the distance to the text by how much - margin left you give it. As well as adjust the y position by editing the margin top.

    0 讨论(0)
提交回复
热议问题