html - 标准化 <LI> 内部文本和元素符号之间的距离

标签 html css html-lists normalization

最近注意到 Chrome 和 Safari <li> 内的文本之间的默认距离不同和子弹时list-style-position设置为inside :

enter image description here enter image description here

问题是:如何在两个浏览器中将该距离标准化为相等,而不使用 background-image哪个技术很丑陋?

Chrome 版本 53.0.2785.143(64 位), Safari 版本 10.0 (11602.1.50.0.10)

PS。屏幕截图列表代码:

ul { list-style-position: inside; margin: 0; padding: 0; }
ul > li { margin: 0; padding: 0; }

最佳答案

如果您找不到 Safari 行为不当的解决方案/原因(或者是 Chrome),您可以使用伪元素作为解决方法

ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
}
ul li {
    margin: 0;
    padding: 0;
}
ul li::before {
    content: '•';
    margin-right: 10px;
}
<ul>
    <li>A</li>
    <li>B</li>
    <li>C</li>
</ul>

关于html - 标准化 <LI> 内部文本和元素符号之间的距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40114445/

相关文章:

html - 居中对齐我的大照片,没有负边距

jquery - 当我单击除此以外的任何内容时,如何更改此样式的 css?

php - 展开 ul li 列表底部的 Accordion /链接

html - 水平 ul 导航对齐到右侧

html - 在元素中使用很棒的字体时无法更改字体系列

html - 响应式图片库

html - SVG 在不同浏览器上的缩放比例不同

javascript - jQuery 循环遍历相同的类名

html - 无序列表中的元素符号点在移动设备上一直向左移动

javascript - 带时间的日期选择器 HH :mm:ss