Reputation: 141
I'm trying to get the "footer" div to sit below the "main" div, except it keeps appearing next to it. I just want it to sit directly below the preceding div (not be forced to the bottom), except it always seems to sit below the header.
<body>
<div class="wrapper">
<div class="header">
Heading
</div>
<div class="main">
Content
</div>
<div class="footer">More details on how you can help coming soon.</div>
</div>
</body>
CSS:
body {
background-image: url("./../img/bg.jpg");
background-repeat: no-repeat;
background-size: 100%;
margin: 0;
padding: 0;
}
.header{
color: #FFFFFF;
font-size: 14vw;
text-align: center;
font-family: OSWALD;
font-style: normal;
text-transform: uppercase;
font-weight: 700;
letter-spacing: 2px;
width: 100%;
line-height: 1.2em;
}
.main{
display: inline-block;
width: 300px;
height: 380px;
overflow: hidden;
padding: 19px 22px 7px;
color: #fff;
font-size: 13px;
text-transform: uppercase;
font-weight: 700;
font-family: "futura-pt", sans-serif;
letter-spacing: 2px;
line-height: 45px;
position: absolute;
right: 0px;
}
.contact{
border-top: 6px solid #e2d056;
border-bottom: 6px solid #e2d056;
width: 250px;
margin: 25px 0 0;
padding: 10px 22px 10px;
text-align: center;
}
.footer {
color: #fff;
font-size: 13px;
text-transform: uppercase;
font-weight: 700;
font-family: "futura-pt", sans-serif;
letter-spacing: 2px;
line-height: 25px;
text-align: left;
padding-left: 30px;
}
Upvotes: 3
Views: 14435
Reputation: 16301
Just change postion:absolute
to position:relative
for .main
as absolute takes the div element out of the layout flow.
.main {
position:relative;
}
Here's a jsfiddle with updated code: https://jsfiddle.net/AndrewL32/ewaLf4ct/
Upvotes: 1
Reputation: 28318
You could just remove display: inline-block;
altogether since it doesn't appear to have a purpose.
If you still need the display: inline-block;
you can use .footer { clear: both; }
or do .main { float: left; clear: both; }
.
Upvotes: 1