html - 在锚链接悬停时更改 DIV
问题描述
我试图在文档中悬停任何锚链接时更改 div。它仅在它不在任何其他容器内时才有效。
无论如何可以在通常的页面布局(内部正文> divs)中进行这项工作吗?
#circle {
position: fixed;
border-radius: 50%;
z-index: 5;
height: 32px;
width: 32px;
background-color: #0081ff;
pointer-events: none;
transition:
background .35s ease,
box-shadow .35s ease,
transform .35s ease;
transform: translate3d(0, 0, 0);
}
.circle:hover ~ #circle {
background-color: transparent;
box-shadow: 0 0 0 3px #E91E63;
transform: scale(1) translate3d(0, 0, 0);
}
<div> <!--If you remove this DIV, it works-->
<a href="#" class="circle">Circle</a>
</div>
<div id="circle"></div>
解决方案
#circle {
position: fixed;
border-radius: 50%;
z-index: 5;
height: 32px;
width: 32px;
background-color: #0081ff;
pointer-events: none;
transition:
background .35s ease,
box-shadow .35s ease,
transform .35s ease;
transform: translate3d(0, 0, 0);
}
.circle:hover ~ #circle {
background-color: transparent;
box-shadow: 0 0 0 3px #E91E63;
transform: scale(1) translate3d(0, 0, 0);
}
<div class="circle"> <!--If you remove this DIV, it works-->
<a href="#">Circle</a>
</div>
<div id="circle"></div>
推荐阅读
- azure - 为什么这个 PhantomJS 进程会导致“目录
不存在。”错误? - excel - 请如何修复无法从工作表功能获取预测属性的 VBA 例程
- java - docker tomcat连接数据库问题
- python - 通过 Python 脚本调用 ProxyCommand 时“没有这样的文件或目录”
- angular - 如何为用户输入添加最小/最大输入限制?
- sql - 使用 IN 运算符时显示所有给定的 ID
- angular - Typescript 从 appsettings 填充字符串模板
- php - ubuntu 反向路径上的 PHP Apache 不起作用
- javascript - 如何让我的画布图像每次旋转 90 度,它只旋转 180 度
- vue.js - 如何在不设置输入值的情况下用输入字段的值替换标签的HTML 内容