无法在 html div 元素周围获得边框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8798677/
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
Can't get a border around a html div element
提问by MillerMedia
I can't figure out why I can't get a border around my div here. My jsfiddle is:
我不明白为什么我的 div 周围没有边框。我的 jsfiddle 是:
I must just be crazy from staring at my computer screen but if you look at the class verticalmembersmenu
in the CSS, I can't for the life of me figure out why I can't get the border around the div.
我一定是盯着我的电脑屏幕发疯了,但如果你看看verticalmembersmenu
CSS中的类,我一辈子都无法弄清楚为什么我不能在 div 周围找到边框。
回答by leopic
You are using HTML style comments in your CSS, that seems to be breaking the rendering, take a look at http://jsfiddle.net/4HnKs/3/
您在 CSS 中使用 HTML 样式注释,这似乎破坏了渲染,请查看http://jsfiddle.net/4HnKs/3/
Some info on comments over at http://www.w3.org/TR/CSS2/syndata.html#comments
有关评论的一些信息,请访问 http://www.w3.org/TR/CSS2/syndata.html#comments
回答by reshma k
u can give inline style to div as
您可以将内联样式赋予 div 作为
<div class="verticalmembersmenu" style = "border:1px solid black;">
or
或者
.verticalmembersmenu ul{
list-style:none; border:1px solid black;
}
回答by banana pants
It took me a while to find, but the problem actually has to do with your css formatting. The css doesn't recognize html comment tags, but instead uses /* */.
我花了一段时间才找到,但问题实际上与您的 css 格式有关。css 不能识别 html 注释标签,而是使用 /* */。
<!--MEMBERS LAYOUT START -->
.verticalmembersmenu {
height:300px;
width:300px;
border:1px solid black;
}
.verticalmembersmenu ul{
list-style:none;
}
<!--MEMBERS LAYOUT END -->
回答by Shalini Subramani
please give the border in ul tag.
请在 ul 标签中给出边框。
.verticalmembersmenu ul{
list-style:none; border:1px solid black;
}