我不太确定你的边框想要什么。此小提琴仅使用以下代码在内容的顶部和底部有边框:
HTML
<div class="top">Top</div>
<div class="middle">
<div class="content"></div>
</div>
<div class="bottom">Bottom</div>
CSS
.top,
.bottom {
position: fixed;
height: 100px;
top: 0;
left: 0;
right: 0;
background-color: red;
z-index: 1;
}
.bottom {
bottom: 0;
top: auto;
background-color: blue;
}
.middle {
position: absolute;
top: 100px;
left: 0;
right: 0;
bottom: 100px;
}
.content {
width: 100%;
height: 1000px;
background-color: yellow;
border: 10px solid black;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin-bottom: 100px;
}
这段代码(与上面的 html 相同)在这个小提琴周围不断有边框:
CSS
.top,
.bottom {
position: fixed;
height: 100px;
top: 0;
left: 0;
right: 0;
background-color: red;
border-bottom: 10px solid black;
z-index: 1;
}
.bottom {
bottom: 0;
top: auto;
background-color: blue;
border-top: 10px solid black;
border-bottom: 0;
}
.middle {
position: absolute;
top: 110px;
left: 0;
right: 0;
bottom: 110px;
}
.content {
width: 100%;
height: 1000px;
background-color: yellow;
border-right: 10px solid black;
border-left: 10px solid black;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin-bottom: 110px;
}