您好! 我使上述圖像響應320x767像素的屏幕分辨率。我的代碼工作正常。
但是,我有一個問題,在圖像上創建的陰影效果沒有反應。我想要的是隨着我的形象變得更小,隨着形象的高度,陰影也應該變小。或者它應該表現得很敏感 我該怎麼做?
HTML
<body>
<div class=" background-img">
<img src="img/learning.jpg" class="img-responsive">
<div class="overlay">
</div>
</div>
</body>
的CSS
.background-img{
max-width: 100%;
height: auto;
}
.overlay{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 10;
background-color: black;
opacity: 0.5;
}
@media only screen and (min-width:320px) and (max-width:767px){
.background-img{
width: 426px !important;
height: 320px !important ;
}
.overlay{
position:fixed;
top: 0;
left: 0;
width: 30% !important;
height: 25%!important;
z-index: 10;
position: absolute;
background-color: black;
opacity: 0.5;
}
刪除'位置:固定'絕對會做,並將您的寬度和高度設置爲100%還添加'位置:相對'background-img – winresh24
嘗試使用位置作爲相對。 –
可能重複[圖像覆蓋響應大小的圖像引導](http://stackoverflow.com/questions/21263800/image-overlay-on-responsive-sized-images-bootstrap) –