有没有什么办法让这个覆盖更具响应性?如何使覆盖图不会切断文字,或在分辨率变化时进入图像之外?使图像叠加更具响应性?
为了进一步阐明:我在一行中使用了三个图像,每个使用的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 /关于你的问题的根源,如果你想实现响应式的东西,你不应该强制元素的尺寸! –