angular - 如何将鼠标悬停在一个 div 上以触发两个不同 div 的更改?
问题描述
我正在用 Angular 6 创建简单的网站,我的部分如下所示
我有四个 div,每个 div 包含作为背景的图标,带有标题和带有描述
span
的段落p
当图标悬停时,我有另一个 div 来保存描述,它是 empyt 的名称
what-we-do__right
更新
这是stackblitz代码的链接
https://stackblitz.com/edit/bootstrap-nabar-snoyrg
这是html
<div class="what-we-do">
<div class="what-we-do__top">
<div class="what-we-do__left">
<h2>What we
<strong>do</strong>
</h2>
</div>
<div class="what-we-do__right">
</div>
</div>
<div class="animation">
<div class="center">
<div class="sat1">
<span>Managed</span>
<strong>Service</strong>"
<p>Managed Service gives our customers the opportunity to reduce the costs of the project and guarantees higher standards
of work, while maintaining complete control over the different phases of our consultants working progress.</p>
</div>
<div class="sat2">
<span>Managed</span>
<strong>Service</strong>"
<p>Managed Service gives our customers the opportunity to reduce the costs of the project and guarantees higher standards
of work, while maintaining complete control over the different phases of our consultants working progress.</p>
</div>
<div class="sat3">
<span>Managed</span>
<strong>Service</strong>"
<p>Managed Service gives our customers the opportunity to reduce the costs of the project and guarantees higher standards
of work, while maintaining complete control over the different phases of our consultants working progress.</p>
</div>
<div class="sat4">
<span>Managed</span>
<strong>Service</strong>"
<p>Managed Service gives our customers the opportunity to reduce the costs of the project and guarantees higher standards
of work, while maintaining complete control over the different phases of our consultants working progress.</p>
</div>
<h3>
<span>IT</span>
<strong>Outsourcing</strong>
</h3>
</div>
</div>
这是我在一个图标上尝试过的 css。
.sat1:hover p span strong,{
visibility: visible;
background: url('/assets/images/ico_1_dark.png') center center no-repeat #d9e5ca
}
.sat1 p{
position: absolute;
bottom: 80px;
margin-left: 700px;
color: red;
visibility: hidden;
}
.sat1 span strong{
position: absolute;
bottom: 80px;
margin-left: 700px;
color: red;
visibility: hidden;
}
但我的解决方案没有按预期工作,
我是新手请帮忙,如何才能实现我想要的?
任何帮助,将不胜感激。
解决方案
您还可以在组件中为每个标题使用变量,并根据悬停的按钮更改这些值。
在您的 html 中,您只需使用插值显示这些变量:例如 {{variable}}。
推荐阅读
- javascript - 如何使图像缩放到 div 的大小 [ReactJS TS]
- reactjs - 在嵌套组件之间传递状态
- google-data-studio - 具有重叠间隔聚合的时序图
- identityserver4 - 如何退出谷歌外部供应商?
- python - Infile 替换清空文件
- r - 在 geom_boxplot 中添加标准错误作为阴影区域而不是错误栏
- outlook - 检查当前用户是否是 Exchange 分发列表的成员 - Outlook C#
- node.js - Bash 脚本:此时“语言环境”出乎意料
- powercli - New-VMHostNetworkAdapter - 在 PowerCLI 中使用 foreach-object 循环 IP 地址
- typescript - 打字稿函数变量类型检查