gpt4 book ai didi

html - CSS 重复选择器

转载 作者:行者123 更新时间:2023-12-01 23:05:47 25 4
gpt4 key购买 nike

我使用 CSS 来构建一个表单,其中包含必填字段的可视化队列。

CSS 有几个相同的选择器,它们显然都很重要,因为删除任何一个都会影响表单。 CSS 是如何合并这两者的?感谢您回答新手问题。完整列表如下。

    .required-field-block .required-icon {        display: inline-block;        vertical-align: middle;        margin: -0.25em 0.25em 0em;        background-color: #E8E8E8;    snip for brevity    ....    }    .required-field-block .required-icon {        background-color: transparent;        position: absolute;        top: 0em;        right: 0em;        z-index: 10;        margin: 0em;snip for brevity....}

Full Listing

.required-field-block {
position: relative;
}

.required-field-block .required-icon {
display: inline-block;
vertical-align: middle;
margin: -0.25em 0.25em 0em;
background-color: #E8E8E8;
border-color: #E8E8E8;
padding: 0.5em 0.8em;
color: rgba(0, 0, 0, 0.65);
text-transform: uppercase;
font-weight: normal;
border-radius: 0.325em;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: background 0.1s linear;
-moz-transition: background 0.1s linear;
transition: background 0.1s linear;
font-size: 75%;
}

.required-field-block .required-icon {
background-color: transparent;
position: absolute;
top: 0em;
right: 0em;
z-index: 10;
margin: 0em;
width: 30px;
height: 30px;
padding: 0em;
text-align: center;
-webkit-transition: color 0.2s ease;
-moz-transition: color 0.2s ease;
transition: color 0.2s ease;
}

.required-field-block .required-icon:after {
position: absolute;
content: "";
right: 1px;
top: 1px;
z-index: -1;
width: 0em;
height: 0em;
border-top: 0em solid transparent;
border-right: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 0em solid transparent;
border-right-color: inherit;
-webkit-transition: border-color 0.2s ease;
-moz-transition: border-color 0.2s ease;
transition: border-color 0.2s ease;
}

.required-field-block .required-icon .text {
color: #B80000;
font-size: 26px;
margin: -3px 0 0 12px;
}

最佳答案

来自 cascading order 上的 CSS 规范:

Finally, sort by order specified: if two declarations have the same weight, origin and specificity, the latter specified wins. Declarations in imported style sheets are considered to be before any declarations in the style sheet itself.



因此,如果您在同一个样式表中的同一个选择器有冲突的样式,则最后一个优先。所以在你的情况下,你会得到 margin: 0embackground-color: transparent .

关于html - CSS 重复选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24331483/

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