javascript - How do You Change Content in CSS When Hovering?
问题描述
How can I replace text with CSS
using content
?
Also just FYI don't worry about the .fab
or Font Awesome unless you also know how to fix that. And if you can fix the JavaScript that'd be great too.
To use Font Awesome in your HTML put
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
in your head tag.
.sell {
margin: -20px auto;
width: 300px;
height: 30px;
background-color: #FDFEFE;
border: 2px solid #FDFEFE;
border-radius: 5px;
}
.styff {
font-size: 20px;
padding: 5px;
position: relative;
text-align: center;
margin: 0 auto;
}
.styff:hover:after {
font-size: 20px;
padding: 5px;
font-family: Font Awesome 5 Free;
position: relative;
text-align: center;
margin: 0 auto;
content: "This is currently not available in the App Store \f370";
}
.fab {
color: #29B6F6;
}
<div class="sell">
<p class="styff">Buy now in the App Store <i class="fab fa-app-store-ios fa-lg"></i></p>
</div>
解决方案
.sell {
margin: -20px auto;
width: 300px;
height: 30px;
background-color: #FDFEFE;
border: 2px solid #FDFEFE;
border-radius: 5px;
}
.styff {
font-size: 20px;
padding: 5px;
position: relative;
text-align: center;
margin: 0 auto;
}
.styff:after {
content: 'Buy now in the App Store';
font-size: 20px;
padding: 5px;
position: relative;
text-align: center;
margin: 0 auto;
}
.styff:hover:after {
content: "This is currently not available in the App Store";
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
<div class="sell">
<p class="styff"><i class="fab fa-app-store-ios fa-lg"></i></p>
</div>
您可以为此使用:before
&:after
伪元素。
推荐阅读
- wordpress - 在古腾堡编辑器中居中图像标题
- p2p - Kadelmia k-bucket split 的理解
- c - malloc'ed 内存中的数据损坏
- c# - 运行 docker.exe 时 vsdbg 的权限问题 - exec: \"/app/vsdbg\: 权限被拒绝
- android - 由于没有窗口焦点,BoxInsetLayout Dropping 事件
- python - Python 优化:在随机生成的 1000 个字母字符串中查找出现次数最多的 4 个字母序列
- flutter - 使用整数数据字段上传多个图像
- android - 在相对布局中浮动时如何消除图标的间隙?
- python - 其中一个线程卡住了
- ios - 如何在 firebase 查询后将值附加到字典?