我已经创建了一个带有响应式图像的表格,但不知道如何在调整窗口大小时停留在那里的图像上添加固定文本。我最接近的方式是使用<p class="">,但文本没有响应...
下面是脚本:https://jsfiddle.net/2vax05et/
基本布局:
<div id="p-container">
<a href="#1">
<figure>
<img src="" alt="">
</figure>
</a>
[....]
</div>CSS:
body {
width: 80%;
margin: 30px auto;
font-family: sans-serif;
}
h3 {
text-align: center;
font-size: 1.65em;
margin: 0 0 30px;
}
div {
font-size: 0;
}
a {
font-size: 16px;
overflow: hidden;
display: inline-block;
margin-bottom: 8px;
width: calc(50% - 4px);
margin-right: 8px;
}
a:nth-of-type(2n) {
margin-right: 0;
}
@media screen and (min-width: 50em) {
a {
width: calc(25% - 6px);
}
a:nth-of-type(2n) {
margin-right: 8px;
}
a:nth-of-type(4n) {
margin-right: 0;
}
}
a:hover img {
filter:brightness(80%);
}
figure {
margin: 0;
}
img {
border: none;
max-width: 100%;
height: auto;
display: block;
background: #ccc;
transition: .2s ease-in-out;
}
.p a {
display: inline;
font-size: 13px;
margin: 0;
}
.p {
text-align: center;
font-size: 13px;
padding-top: 100px;
}有什么想法吗?
发布于 2017-01-12 22:45:03
HTML:
<a href="#1">
<figure>
<img src="image.jpg" alt="">
</figure>
<p>Text</p>
</a>CSS:
a{
position: relative;
}
a p {
position: absolute;
top: 1em;
left: 1em;
}文本中包含的p element将仅扩展到源a的边界。您可以考虑根据需要添加适当的填充和连字符。
发布于 2017-01-12 22:37:33
使用视口单位作为字体大小。它将根据屏幕的大小进行流畅的缩放。
示例:
font-size: 2vwhttps://stackoverflow.com/questions/41615187
复制相似问题