Html li 标签周围的边框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12856279/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:20:52  来源:igfitidea点击:

Border around li tag

htmlcssborder

提问by Markinhos

Is there any way that the border in a li tag includes the number and not just the content?

有没有办法让 li 标签中的边框包含数字而不仅仅是内容?

Here is the jsfiddle of what I am trying to do: http://jsfiddle.net/Markinhos/VSnnd/8/

这是我正在尝试做的 jsfiddle:http: //jsfiddle.net/Markinhos/VSnnd/8/

I want the border includes the number two.

我希望边界包括第二个。

回答by Giona

Add list-style-position:inside;

添加 list-style-position:inside;

.borderlist {
    list-style-position:inside;
    border: 1px solid black;
}

回答by Rick Donohoe

list-style-position: inside;

is the CSS attribute your looking for, it will treat the list number as if it is inside the CSS box model.

是您要查找的 CSS 属性,它会将列表编号视为在 CSS 盒模型内。

回答by NullPoiиteя

you can do this by list-style-position: inside;

你可以这样做 list-style-position: inside;

The list-style-position CSS property specifies the position of the marker box in the principal block box. :MDN

list-style-position CSS 属性指定标记框在主块框中的位置。: MDN

jsFiddle

js小提琴