我正在自定义样式,边框有问题。当我飞越元素时,它不是静态的(由于边界而向右移动)。
我在IP.Board上也注意到了这个问题,我找不到解决方案:http://screencast.com/t/49DgJmXuCN0v并删除了边框,一切都很完美:http://screencast.com/t/n3JVAYFQRxK
如果有人可以帮助我,谢谢。
答案 0 :(得分:1)
只需将box-sizing: border-box;
添加到您的元素即可。了解更多信息http://www.w3schools.com/cssref/css3_pr_box-sizing.asp
答案 1 :(得分:0)
边框通常会增加元素占据区域的尺寸。这会导致后续内容被推送,但确切的效果取决于许多设置。试图避免这种情况会导致问题,因为如果在添加边框时总尺寸保持不变,则上下文区域尺寸会缩小。但还有其他几种选择:
<style>
body {
background: white;
color: black;
}
.a:hover {
border: solid red medium;
}
.b {
border: solid transparent medium;
}
.b:hover {
border-color: red;
}
.c {
border: solid white medium;
}
.c:hover {
border-color: red;
}
.d:hover {
outline: solid red medium;
}
</style>
<p><span class=a>Illustrating the problem.</span> What happens on mouseover?
<p><span class=b>This has transparent border initially.</span> What happens on mouseover?
<p><span class=c>This has white border initially.</span> What happens on mouseover?
<p><span class=d>No border, but outline.</span> What happens on mouseover?
<p>That’s all folx!