有沒有什麼辦法讓這個覆蓋更具響應性?如何使覆蓋圖不會切斷文字,或在分辨率變化時進入圖像之外?使圖像疊加更具響應性?
爲了進一步闡明:我在一行中使用了三個圖像,每個使用的W3CSS框架都有三個圖像,下面有三個圖像等等。每個圖像都有一個覆蓋文本鏈接指向其他頁面如下例所示。我唯一的問題是迴應。我希望圖像和疊加層能夠響應屏幕尺寸的變化和分辨率。
謝謝!
.container {
\t position: relative;
\t width: 50%;
}
.image {
\t display: block;
\t width: 100%;
\t height: auto;
}
.overlay {
\t position: absolute;
\t top: 0;
\t bottom: 0;
\t left: 0;
\t right: 0;
\t height: 100%;
\t width: 100%;
\t opacity: 0;
\t transition: .5s ease;
\t background-color: #008CBA;
}
.container:hover .overlay {
\t opacity: 1;
}
.text {
\t color: white;
\t font-size: 15px;
\t position: absolute;
\t top: 50%;
\t left: 50%;
\t transform: translate(-50%, -50%);
\t -ms-transform: translate(-50%, -50%);
}
<link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet"/>
<div class="w3-row-padding">
<div class="w3-third w3-container w3-margin-bottom">
<div class="container">
<img src="https://www.google.com/images/branding/product/ico/googleg_lodp.ico" alt="Google" style="height:300px;width:400px" class="w3-hover-opacity">
<div class="overlay">
<div class="text">
<a href="https://www.google.com">Google Sample1</a><br>
<a href="https://www.google.com">GoogleSample2</a><br>
</div>
</div>
</div>
<div class="w3-container w3-white" style="height:50px;width:400px">
<h3>Example 1</h3>
</div>
</div>
</div>
1 /我冒昧地編輯您的帖子中插入代碼段(而不是原始代碼),並修正了一些拼寫錯誤(如缺少報價,成交'了'不必要的)。 2 /關於你的問題的根源,如果你想實現響應式的東西,你不應該強制元素的尺寸! –