这里是它使用box-sizing:border-box
,以确保您可以使用100%,无溢出一个更可读的版本。
对于那些没有看到原始网站的人来说,请注意边界在4个独立的区段中进行悬停。
我们基本上是将整个边框变成透明的,然后改变特定部分的颜色。总的来说,减少了CSS所需的数量,并且也使得它更容易遵循。
Here it is as a fiddle
注释的CSS:
/*
Dump the margin and make both html and body 100% high
(as well as a dark-ish background color)
*/
html,body{
margin:0;
height:100%;
background:#363b46;
}
/*
Each frame element will be 45px and uses box-sizing.
That'll make sure the size of the border itself doesn't cause it to overflow,
and 100% 'just works'.
We'll also clear the width so we don't end up with them defaulting to width:auto
and position them so they can get placed in specific locations.
*/
.frames{
box-sizing:border-box;
border:45px solid transparent;
width:0;
position:absolute;
}
/*
Styling specific borders so they end up where they need to be
*/
.frameLeft{
left:0;
height:100%;
border-left-color:#131c30;
}
.frameTop{
width:100%;
border-top-color:#131c30;
}
.frameRight{
right:0;
height:100%;
border-right-color:#131c30;
}
.frameBottom{
bottom:0;
width:100%;
border-bottom-color:#131c30;
}
/*
The hover selectors - these changes specific borders
*/
.frameTop:hover{
border-top-color:#7b9eeb;
}
.frameRight:hover{
border-right-color:#7b9eeb;
}
.frameBottom:hover{
border-bottom-color:#7b9eeb;
}
.frameLeft:hover{
border-left-color:#7b9eeb;
}
的HTML:
<!-- The four frame parts -->
<div class='frames frameTop'></div>
<div class='frames frameLeft'></div>
<div class='frames frameBottom'></div>
<div class='frames frameRight'></div>
我想你所有你需要的是添加'左:0像素;底部:0px'以及?更新:https://jsfiddle.net/knq4L3xf/3/如果你想在右边删除'left' –
上帝保佑你,先生。我确实说过这是微不足道的。非常感谢!! –
我会把它写成答案,以防你想再次引用它,如果你想要或不需要标记它 –