html - 为什么我的 CSS 星形图层没有正确对齐?
问题描述
我想让黄色的星星完全遮住蓝色的星星
任何人都可以帮助完成这个吗?或者至少指向正确的方向?
这是我的代码:
.star-ratings-css {
width: 100px;
}
.star-ratings-css-top {
display: block;
height: 22px;
position: relative;
overflow: hidden;
}
.star-ratings-css-bottom::before {
color: #167ac6;
content: "★★★★★";
font-size: 22px;
position: absolute;
}
.star-ratings-css-top::before {
color: #f4b414;
content: "★★★★★";
font-size: 22px;
position: relative;
}
<div class="star-ratings-css">
<div class="star-ratings-css-bottom"></div>
<div class="star-ratings-css-top" style="width: 31%"></div>
</div>
它不像我想要的那样工作。我做错了什么?
黄色的星星并没有完全覆盖蓝色的星星。
解决方案
只需删除 overflow: hidden;
它,它就会像魅力一样发挥作用。以下是 4/5 的示例。
.star-ratings-css {
width: 100px;
}
.star-ratings-css-top {
display: block;
height: 22px;
position: relative;
}
.star-ratings-css-bottom::before {
color: #167ac6;
content: "★★★★★";
font-size: 22px;
position: absolute;
}
.star-ratings-css-top::before {
color: #f4b414;
content: "★★★★";
font-size: 22px;
position: relative;
}
<div class="star-ratings-css">
<div class="star-ratings-css-bottom"></div>
<div class="star-ratings-css-top" style="width: 31%"></div>
</div>
推荐阅读
- webview - PWA 推送通知权限弹出窗口未出现在 UWP webview 上
- python - 如何使用增量日期时间模拟熊猫数据帧数据
- javascript - 为什么 onclick = function() 在文档准备好的内部不起作用?
- python - Matplotlib - 为无限数量的图创建带有 CheckButton 图例的图形
- primefaces - 生成 Primefaces 饼图时出错
- javascript - 滚动进度条
- javascript - jQuery 创建的字段不向 PHP 发送 POST 数据
- r - 全屏查看按钮
- apache-spark - 如何在 Spark 的 Pregel API 中的聚合消息中实现编写代码?
- java - 找不到类型为“org.springframework.security.oauth2.client.registration.ClientRegistrationRepository”的 Bean。- 春季安全