あなたが望むのは、paragraph
常に画像のすぐ下にいることだと思います。
and since you have made your img position:absolute
, it will behave independent of it's parent div. that's why the paragraph gets rendered just after the h1 tag.
also, fixations through setting margin
values of a position:absolute
element, or padding, won't help you much, as you can never tell what width and size your image can be, combined with range of resolutions(including IE). so i'am not gonna suggest you those temporary workouts:
What best you should do in my views is, changing your layout structure: see, anyway, content-area behind your img is not going to be visible, so why not keep three separate containers?
and position them relatively?
see this markup:
<div class="wrapper">
<div class='header'>
<h1>Some Title</h1>
</div>
<div class="image">
<figure>
<img src="someimage.jpg" />
</figure>
</div>
<div class="para">
<p id="paragraph">Some description</p>
</div>
</div>
and see this css:
.header
{
position: relative;
left:10%;
width:80%;
height: 20%;
background-color: #CCCCCC;
text-align: center;
}
.wrapper
{
width: 100%;
height: auto;
}
.image
{
position: relative;
top:20%;
width: auto;
background-color: #EEEEEE;
height: auto;
text-align: center;
}
.image > figure >img
{
width: 1800px;
height: 800px;
border:1px Solid #CCCCCC;
}
.para
{
position: relative;
left:10%;
width:80%;
height: 20%;
background-color: #555555;
text-align: center;
}
fiddle
benefits:
this will work in all resolutions.
your paragraph container will position itself according to the img height;
今、私は img に非常に高い値を与えました。あなたがしなければならないことは、img の高さと幅を 100% に設定することだけです。
それはうまくいくはずです。そうでない場合は教えてください