Werfen Sie einen Blick auf diese Geige: https://jsfiddle.net/hkbynkmf/1/Centered divs mit insgesamt Grenze
Wie lasse ich die grüne Grenze alle divs umfließen, ohne div „überfüllt“ die Grenze? Das obere div ist in Ordnung, das untere div ist nicht OK. Auch brauche ich einen Abstand zwischen den divs;
Ich weiß, dass Padding und Rand transparent ist, also wählte ich (eine grüne) Grenze, um meinen Punkt zu veranschaulichen. Am Ende sollte die Freigabe transparent sein.
HTML:
body {
position: relative;
background-color: #ff0000;
background-repeat: no-repeat;
background-attachment: fixed;
padding: 0px;
border: 10px solid #190;
margin: 0px;
}
#header {
position: relative;
margin:0 auto; /* div will be H-centered */
top: 10px;
left: 0px;
bottom: 0px;
right: 0px;
width: 960px;
height: 250px;
background-color: #DDDDDD;
overflow: hidden; /* Keep all sub-elements inside this div */
}
#intro {
position: relative;
margin:0 auto; /* div will be H-centered */
top: 15px;
left: 0;
bottom: 0px;
right: 0px;
width: 960px;
height: 150px;
background-color: blue;
overflow: hidden; /* Keep all sub-elements inside this div */
}
<body> <!--position: relative;-->
<div id="header"> <!--position: relative;-->
</div>
<div id="intro"> <!--position: relative;-->
</div>
</body>
hinzufügen 'padding-bottom: 15px;' an das Körperelement – bhv