CSS 边框不显示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13848482/
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 21:01:08  来源:igfitidea点击:

Border does not show up

cssborder

提问by Edward Granger

My border is not showing up around my image, I'm not quite sure what the issue could be. I just need a small black border around the photo. My website is http://www.welovetile.com. I can't figure out what the problem could be. Thanks.

我的边框没有出现在我的图像周围,我不太确定可能是什么问题。我只需要在照片周围加上一个小的黑色边框。我的网站是http://www.welovetile.com。我无法弄清楚可能是什么问题。谢谢。

CSS:

CSS:

#kitchen {
        height:250px;
        width:346px;
        background-image:url(images/kitchenbg.jpg);
    }

        #kitchen img
        {   
            top: 50%;
            left: 50%;
            width: 316px;
            height: 228px;
            margin-top:11px;
            margin-left:15px;
            border-color:#000000;
            border-width:thin;
        }

HTML:

HTML:

<div id="kitchen">
    <img src="images/kitchen.jpg" alt="Kitchen Tile Job"/>
</div>

回答by Chris Young

Borders have three main pieces: a width, a style, and a color; the style is required for any of the others to work.

边框具有三个主要部分:宽度、样式和颜色;任何其他风格都需要这种风格才能工作。

Try adding the style:

尝试添加样式:

border-style: solid;

Also, you can specify all these in the same line of css:

此外,您可以在同一行 css 中指定所有这些:

border: thin solid black;

Updated

更新

As pointed out by Wesley, border-style is the only required one.

正如韦斯利所指出的,边框样式是唯一需要的样式。

From http://www.w3schools.com/css/css_border.asp:

来自http://www.w3schools.com/css/css_border.asp

None of the border properties will have ANY effect unless the border-styleproperty is set!

除非设置了border-style属性,否则所有边框属性都不会产生任何效果!

回答by Ivan Feri?

You're missing:

你不见了:

border-style: solid;

回答by Vucko

You can put border width/style/color in one row like this:

您可以像这样将边框宽度/样式/颜色放在一行中:

Border: 1px solid black;

回答by systemboot

try this:

尝试这个:

border: 1px solid #F4F1E8;
box-shadow: 1px 1px 3px #4C4843;

回答by Christofer Vilander

Add a border style property as well, for example border-style: solid;.

还要添加边框样式属性,例如border-style: solid;