html - 使用 CSS 背景颜色拆分两个链接的按钮
问题描述
我正在尝试创建两个由 CSS 拆分的链接按钮background-color
。
.right-part {
display: inline-block;
width: 100px;
height: 52px;
background: linear-gradient(110deg, #fff 0%, #fff 50%, #FF7240 50%, #FF7240 100%);
background-color: #FF7240;
border-radius: 0px 26px 26px 0px;
}
.left-part {
display: inline-block;
width: 100px;
height: 52px;
border-radius: 26px;
}
<div class="left-part">left</div>
<div class="right-part">right</div>
背景颜色不填充 div 元素。
解决方案
您需要给他们一个父 div 并将其设置background-image
为父级:
.button {
display: inline-block;
background-image: linear-gradient(100deg, #f4bc58 0%, #ed8b48 50%, #FF7240 50%, #FF7240 100%);
border-radius: 26px;
}
.button > * {
display: inline-flex;
justify-content: center;
align-items: center;
width: 100px;
height: 52px;
}
<div class="button">
<div class="left-part">left</div>
<div class="right-part">right</div>
</div>
推荐阅读
- apache-kafka - Coucbase 到 Kafka 源连接器
- python - 如何使 Python 模块中的变量在 Go 中可用?
- rust - 如何使用 structs 和 impl 的生命周期来推断实现的适当生命周期?
- ibm-cloud - cookie 哈希键是否特定于 appid 适配器?
- mysql - “MYSQL:我如何输入编号?”
- javascript - 由 toString() 存储为字符串的 Google 表格日期在写回单元格时不会被识别为日期?
- java - 随机游走不走 JAVA
- shell - Solaris 11 中不使用 SVR4 的 makepkg 命令的替代方法
- python - 运算符 pow() 返回与 ** 不同的值
- python - 使用 SMTLIB2 查找 z3 中的最大数字