位置絶対div内で画像スケールを作成するにはどうすればよいですか。画像も絶対画像です。
コードは次のとおりです。
HTML
<div id="home" class="panel">
<div class="content">
<p> Welcome! </p>
<div id="plan" class="home-design">
<p class="bottom-plan">Learning About the requirements</p>
<img class="top-plan" src="plan.png"
style="max-width:100%; height:auto;" />
</div>
</div>
</div>
CSS
html,body {
height:100%;
}
body {
width:100%;
color:#000;
text-align:center;
}
.panel {
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
margin:auto;
width:600px;
height:100%;
border:1px solid #ddd;
}
.content {
width:600px;
top:0;
position:absolute;
margin:auto;
height:100%;
}
.home-design {
width:225px;
height:200px;
text-align:center;
padding-left:64px;
float:left;
}
.home-design p {
font-weight:bold;
margin-top:80px;
font-size:10px;
}
#plan .top-plan {
position:absolute;
left:65px;
top:30px;
border:1px solid #ddd;
-webkit-transition:all 1s ease-in-out;
-moz-transition:all 1s ease-in-out;
-o-transition:all 1s ease-in-out;
transition:all 1s ease-in-out;
}
#plan img.top-plan:hover {
opacity:0;
padding-top:50px;
}
テキストは画像の後ろにあり、ユーザーが画像にカーソルを合わせると、テキストがフェードアウトして下がります。テキストの上に表示できるように、画像を絶対的なものにしました。
これが画像です。
ここにjsfiddleがあります http://jsfiddle.net/endl3ss/guKS4/1/
編集
ウィンドウのサイズを変更した場合、またはモニターの解像度が小さい場合。計画画像もサイズ変更する必要があります。