html - Css - 按钮上的悬停效果不起作用
问题描述
我在我想要悬停效果按钮的 HTML 文件中执行此操作。但是,这是行不通的。
.carousel-caption button {
padding: 20px 100px;
background-color: Transparent;
border: 1px solid #ff084e;
float: right;
font-size: 20px;
font-weight: 600;
color: white;
}
.carousel-caption button :hover {
background-color: #4CAF50;
/* Green */
color: black;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<img src="https://picsum.photos/50/10" alt="test" class="img-responsive" style="width: 100%">
<div class="carousel-caption">
<button>Learn More</button>
</div>
</div>
</div>
</div>
我在哪里做错了。我的悬停效果不起作用。
解决方案
删除按钮和 :hover 之间的空格
替换button :hover
为button:hover
。
.carousel-caption button {
padding: 20px 100px;
background-color: Transparent;
border: 1px solid #ff084e;
float: right;
font-size: 20px;
font-weight: 600;
color: white;
}
.carousel-caption button:hover {
background-color: #4CAF50;
/* Green */
color: black;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<img src="https://picsum.photos/50/10" alt="test" class="img-responsive" style="width: 100%">
<div class="carousel-caption">
<button>Learn More</button>
</div>
</div>
</div>
</div>
推荐阅读
- c++ - 使用 Qt 绘制像素完美的圆
- css - 如何控制文本框显示
- python-3.x - 如何在 virtualenwrapper 中安装特定版本的 python?
- anylogic - 如何在 Ubuntu 操作系统中使用 USB 加密狗激活 AnyLogic?
- c# - 如何对打印到物理打印机的功能进行单元测试?
- r - 通过给定分布更改分类变量中字段的分布
- arrays - vertx 决定 jsonobject vs jsonarray
- python-3.x - 使用 matplotlib(或 seaborn)绘制 d 轨道图
- git - 如何创建新分支并将来自另一个分支的差异合并到其中,但单个目录除外
- machine-learning - coremltools管道输入节点未连接到模型的其余部分