html - 在移动设备上悬停图像
问题描述
我的网站上有一个使用 CARGO Collective 构建的悬停图像功能。我在 CSS 中添加了悬停功能,效果很好,但是这些悬停图像不会出现在移动设备上。我的问题是如何添加到 CSS 以使它们在移动设备上可点击的图像链接但在桌面版本上保持悬停?
这是悬停 CSS 出现在网站上的位置:
.hover-title {
display: inline;
pointer-events: auto;
cursor: pointer;
}
.hover-title {
color: #FFB000;
}
body:not(.mobile) .hover-title:hover + .hover-image {
visibility: visible;
pointer-events: none;
}
.hover-image {
visibility: hidden;
display: flex;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index:5;
pointer-events: none;
flex-direction: column;
align-items: center;
justify-content: center;
/* Change width and height to scale images */
width: 90vw;
height: 90vh;
}
.hover-image img {
max-width: 100% !important;
max-height: 100% !important;
width: auto !important;
height: auto !important;
margin-bottom: 0;
}
解决方案
http://www.w3schools.com/cssref/sel_active.asp也提到了这一点;:active
如果您在悬停之前提及选择器,您可以实现您想要的(点击移动设备,悬停在桌面上):selector
推荐阅读
- c - 请帮我从文件中删除一个空行
- reactjs - 在反应中切换复选框
- c# - 对对象列表进行排序并转换为 JObject 列表
- laravel - Laravel 护照对两个中间件使用两个提供者和相同的路由
- c++ - 为什么我在 ConsoleApplication1.exe 中的 0x00000000 处出现异常异常:0xC0000005:访问冲突执行位置 0x00000000
- php - 从动态 php 列表中的用户获取 id
- javascript - 在 p5js Canvas 上显示来自本地主机的图像时出错
- machine-learning - 如果 DBSCAN 算法正常工作,是否可能导致集群的成员少于 minPoints?
- google-api - Google Speech to Text API 很慢
- angular - 在 Angular 中使用 Renderer2 渲染 SVG