我正在尝试设置一个基本网页,但我的页眉和页脚略微溢出了右侧的父div。我已经尝试过多种清晰组合:两种和浮动,但似乎无法得到它。
body {
border-style: solid;
border-color: red;
background-color: white;
margin: auto;
padding: 0;
width: auto;
height: auto;
clear:both;
text-align: center;
}
.wrapper {
border-style: solid;
border-color: black;
margin-top: 210px;
margin-bottom: 210px;
background-color: white;
margin: 0px auto 0px auto;
width: 80%;
max-width: 1500px;
height: 100%;
}
.header {
background-repeat: no-repeat;
border-style: solid;
border-color: green;
width: 100%;
height: 200px;
margin: auto;
margin-right: 20px;
padding: inherit;
top: 0;
text-align: center;
}
.headerContent {
background-repeat: no-repeat;
border-style: solid;
border-color: green;
width: 80%;
max-width: 1500px;
height: 100%;
display: inline-block;
background-image: ;
}
<body>
<div class="header">
<div class="headerContent">
</div>
</div>
<div class="wrapper">
</div>
<div class="footer">
</div>
</body>
答案 0 :(得分:0)
对所有使用边框的类使用:box-sizing: border-box;
属性。
答案 1 :(得分:0)
您错过了box-sizing: border-box;
* {
box-sizing: border-box;
}
body {
border-style: solid;
border-color: red;
background-color: white;
margin: auto;
padding: 0;
width: auto;
height: auto;
clear: both;
text-align: center;
}
.wrapper {
border-style: solid;
border-color: black;
margin-top: 210px;
margin-bottom: 210px;
background-color: white;
margin: 0px auto 0px auto;
width: 80%;
max-width: 1500px;
height: 100%;
}
.header {
background-repeat: no-repeat;
border-style: solid;
border-color: green;
width: 100%;
height: 200px;
margin: auto;
margin-right: 20px;
padding: inherit;
top: 0;
text-align: center;
}
.headerContent {
background-repeat: no-repeat;
border-style: solid;
border-color: green;
width: 80%;
max-width: 1500px;
height: 100%;
display: inline-block;
background-image: ;
}
<body>
<div class="header">
<div class="headerContent">
</div>
</div>
<div class="wrapper">
</div>
<div class="footer">
</div>
</body>