我有一个div,它位于绝对位置,我知道它的意思是不会将div下推,但我怎样才能不用margin margin或top为下面的div。div设置为绝对位置,不会将其他div压低到低于
我想.header
留在position: absolute
,但它下面的div .blog
应该在它下面堆叠。
body {
font-family: Georgia, serif;
}
.clear {
clear: both;
}
.header {
background-color: #e9118c;
left: 0;
right: 0;
top: 0;
position: absolute;
padding: 5px 0 5px 0;
}
.inner-container {
padding: 0 30px 0 30px;
width: 1100px;
display: inline;
}
.search,
.social {
display: inline-block;
width: 600px;
}
.social {
text-align: right;
}
.social img {
width: 35px;
}
.blog {
position: relative;
}
<!DOCTYPE html>
<html>
<header>
<title>Christina's Baking Adventure</title>
<link href='http://fonts.googleapis.com/css?family=Open+Sans|Roboto:400,500,700,900' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="./christinasbakingadventure.css">
</header>
<body>
<div class="container">
<div class="header">
<div class="inner-container">
<div class="search">
search box
</div>
<div class="social">
<img src="./fb-icon.png" alt="facebook">
<img src="./fb-icon.png" alt="facebook">
<img src="./fb-icon.png" alt="facebook">
<img src="./fb-icon.png" alt="facebook">
<img src="./fb-icon.png" alt="facebook">
</div>
</div>
</div>
<div class="clear"></div>
<div class="blog">
<div class="inner-container">
<img src="./christinasbakingadventurelogo.png" style="width: 350px;" alt="Christina's Baking Adventure logo">
</div>
</div>
</div>
</body>
</html>
请问有没有办法做你想要什么,而无需使用绝对?绝对定位的元素不会改变其他元素的位置,无论如何 – 2015-01-26 20:09:00
我不能看到没有使用填充或边距的解决方案.. – 2015-01-26 20:14:30