gpt4 book ai didi

css - 如何从右到左呈现进度元素?

转载 作者:行者123 更新时间:2023-11-28 16:04:41 24 4
gpt4 key购买 nike

我有一个从左到右显示的进度条。我需要制作另一个相同样式的进度,但将从右到左显示。

这是我的风格定义:

progress, progress[role] {
-webkit-appearance: none;
appearance: none;
border: none;
background-size: auto;
height: 50px;
width: 100%;
padding-top: 10px;
}
progress[value]::-webkit-progress-bar {
background-color: grey;
border-radius: 2px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) inset;
}
progress[value]::-webkit-progress-value {
background-image:
-webkit-linear-gradient(-45deg,
transparent 33%, rgba(0, 0, 0, .1) 33%,
rgba(0,0, 0, .1) 66%, transparent 66%),
-webkit-linear-gradient(top,
rgba(255, 255, 255, .25),
rgba(0, 0, 0, .25)),
-webkit-linear-gradient(left, #09c, #f44);
border-radius: 2px;
background-size: 35px 20px, 100% 100%, 100% 100%;
}

.valuebar {
position: relative;
}
.valuebar h3 {
color: #fff;
left: 1em;
line-height: 1;
position: absolute;
}

我使用了来自网络的示例,该示例使用 ::-webkit-progress-value

如何让它从右向左渲染?

最佳答案

通常,许多元素在其 direction 时会翻转其水平渲染。属性从 ltr 更改为(这是默认值)到 rtl , 代表从右到左(与从右到左的语言兼容,例如阿拉伯语或希伯来语)。

<progress>元素没有什么不同。只需给 CSS 一些东西(比如一个特殊的类)并设置它的 direction: rtl; .

这是一个基于您发布的代码的小片段。

/* this is the important bit */
progress.rtl {
direction: rtl;
}
progress,
progress[role] {
-webkit-appearance: none;
appearance: none;
border: none;
background-size: auto;
height: 50px;
width: 100%;
padding-top: 10px;
}
progress[value]::-webkit-progress-bar {
background-color: grey;
border-radius: 2px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) inset;
}
progress[value]::-webkit-progress-value {
background-image: -webkit-linear-gradient(-45deg, transparent 33%, rgba(0, 0, 0, .1) 33%, rgba(0, 0, 0, .1) 66%, transparent 66%), -webkit-linear-gradient(top, rgba(255, 255, 255, .25), rgba(0, 0, 0, .25)), -webkit-linear-gradient(left, #09c, #f44);
border-radius: 2px;
background-size: 35px 20px, 100% 100%, 100% 100%;
}
.valuebar {
position: relative;
}
.valuebar h3 {
color: #fff;
left: 1em;
line-height: 1;
position: absolute;
}
<progress value="59" max="100">59%</progress>
<br />
<progress class="rtl" value="59" max="100">59%</progress>

我不知道你的标记是什么,因为你没有发布它,但你可能需要调整 .valuebar定位。

这是一个code pen你可以玩。

关于css - 如何从右到左呈现进度元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39439032/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com