CSS 如何使用css将div的边框“向上”移动一个像素
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4725692/
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 23:30:01 来源:igfitidea点击:
How to move a div's border "up" one pixel with css
提问by Ankur
I have a div, which I have given a border on top. The border needs to be shifted one pixel higher. Is this possible with CSS.
我有一个 div,我在上面给了一个边框。边框需要向上移动一个像素。这可以用 CSS 实现吗?
回答by hunter
You can accomplish this with a negative top margin
您可以使用负上边距来完成此操作
{ margin-top: -1px; }
very basic example: http://jsfiddle.net/zW6yD/
非常基本的例子:http: //jsfiddle.net/zW6yD/
回答by deadlock
You can do
你可以做
div { position: relative; margin-top: -1px; }