【发布时间】:2018-09-26 18:33:36
【问题描述】:
我在 Cargo Collective 上使用网站模板。在主页上,有一个带有仅在悬停时出现的文本的图像网格。在移动视图中,文本不会出现。我了解悬停在移动设备上无法始终如一地工作。有没有办法设置在移动设备上加载页面时显示此文本?
或者,我将如何删除悬停功能并使文本始终可见?
以下是 CSS 中出现悬停的两个位置:
[data-predefined-style="true"] bodycopy a:hover {
}
bodycopy a.image-link,
bodycopy a.icon-link,
bodycopy a.image-link:hover,
bodycopy a.icon-link:hover {
border-bottom: 0;
padding-bottom: 0;
}
/**
* Thumbnail Hover
*/
.thumbnails .thumbnail > a {
position: relative;
}
.thumbnails .thumbnail .title {
background: rgba(0, 0, 0, 0.4);
padding: 0.5rem 1.2rem 0.7rem 1.2rem;
margin: 2.4rem;
color: rgba(255, 255, 255, 1);
align-content: center;
display: flex;
position: absolute;
left: 0;
top: 0;
z-index: 9;
opacity: 0;
}
.thumbnails .title span {
margin: auto;
display: inline-block;
}
.thumbnails .thumbnail:hover .title {
opacity: 1;
}
body.mobile .thumbnails .thumbnail:hover .title {
opacity: 0;
}
【问题讨论】:
-
您可能想要使用媒体查询。使用此方法,您可以根据给定的屏幕尺寸将文本设置为可见/隐藏。 stackoverflow.com/questions/42025632/…