Reputation: 1957
I have two divs. First acts as a banner of sorts. The next is just a small div that I'm trying to place directly below the first div. I've tried taking away float and adding clear: both. Perhaps I'm missing something? Below is my html and css
<div id="background">
</div>
<div id="us">
</div>
#background
{
width: 100%;
height: 10%;
position: absolute;
left: 0px;
top: 0px;
border:1px solid #000;
background-color:black;
background-image: url(resources/images/****.png);
background-repeat: no-repeat;
background-position: center;
clear: both;
}
#us
{
display: block;
width: 165px;
height: 200px;
left: 0px;
align-top: auto;
position: absolute;
background-image: url(resources/images/*****.jpg);
background-repeat: no-repeat;
background-position: center;
background-size: contain;
}
The first div does appear at the top of the page and displays correctly. The second one appears over top of the first div. Any advice?
Upvotes: 0
Views: 70
Reputation: 1
You have used position: absolute;
in CSS of second div(#us)
that's why it is showing on top of first div
. Change that to position: relative;
or delete that line.
And you are ready to go.
Upvotes: 0
Reputation: 1
try this one
#us
{display: block;
width: 165px;
height: 200px;
left: 0px;
align-top: auto;
**margin-top: 50px;**
background-image: url(resources/images/*****.jpg);
background-repeat: no-repeat;
background-position: center;
background-size: contain;
}
Upvotes: 0
Reputation: 8413
Check this out.
Just add top:10%;
to your #us
because you are using position:absolute
.
The size of your top
in #us
must be the same size with your height
in #background
. I also added box-sizing:border-box;
for you borders not to take space.
Upvotes: 1