子弹与CSS3列一起消失

时间:2012-06-01 18:38:13

标签: css css3 html-lists

当我使用CSS3将它们转换为列时,列表项上的项目符号会消失。任何想法为什么或如何纠正它的建议?

请参阅示例:http://jsfiddle.net/gduDm/1/

ul li {
    list-style-type: disc !important;
    column-break-inside: avoid;
}
ul {
    list-style-type: disc !important;
    margin-top: 1em;
    column-count: 2;
    column-gap: 0.5em;
}

5 个答案:

答案 0 :(得分:81)

我认为子弹在那里,但它们被渲染到观察区域的左侧。尝试:

list-style-position: inside;

答案 1 :(得分:19)

padding-left和否定text-indent添加到列表元素似乎会产生所需的结果:

ul li {
    padding-left: 1em;
    text-indent: -1em;
}
ul {
    list-style: inside disc;
}

http://jsfiddle.net/mblase75/gduDm/4/

或者,将margin-left添加到列表元素(而不是列表)并使用outside项目符号:

ul li {
    margin-left: 1em;
}
ul {
    list-style: outside disc;
}

http://jsfiddle.net/mblase75/gduDm/9/

答案 2 :(得分:3)

设置margin-left:1em会使子弹显示而不会弄乱文本缩进。

答案 3 :(得分:2)

在这里尝试第一个答案后,我的列表项溢出到第二行而没有排队问题。使用column-gap我能够移动第二列并查看子弹。

来源:http://karlikdesign.com/how-to-split-a-list-into-two-columns-with-pure-css/

    <!– CSS CODE –>
    .two-columns {
    -webkit-column-count: 2;
    -moz-column-count: 2;
    column-count: 2;
    -webkit-column-gap: 40px;
    column-gap: 40px;
    -moz-column-gap: 40px;
}

答案 4 :(得分:1)

其他一些解决方案也不错,但是我尝试的所有解决方案都对我造成了各种副作用。我做了一些小调整,并尝试使其尽可能接近完美。

ul {
  column-count:2;
}

ul.solution {
  margin-left:-0.6em;
  margin-right:0.6em;
}

ul.solution > * {
  margin-left:0.6em;
  margin-right:-0.6em;
}
Experimental Group
<ul class="solution">
 <li>
  This solution is pretty similar to the others.
 </li>
 <li>
  It does not require you to put the bullets inside, so you can keep your left edge clean if you want. 
 </li>
 <li>
  This fixed it for me in IE11 while also not impacting the appearance on Chromium, so I didn't have to do any browser filtering.
 </li>
</ul>
Control Group
<ul>
 <li>
  This solution is pretty similar to the others.
 </li>
 <li>
  It does not require you to put the bullets inside, so you can keep your left edge clean if you want. 
 </li>
 <li>
  This fixed it for me in IE11 while also not impacting the appearance on Chromium, so I didn't have to do any browser filtering.
 </li>
</ul>