简体   繁体   English

重用CSS样式并应用于其他HTML元素

[英]Reuse CSS style and apply to other HTML element

I would like to reuse given css formatting .parsley-errors-list > li and apply it to different HTML element than it it designed to be used for. 我想重用给定的css格式.parsley-errors-list > li并将其应用到与其设计使用的HTML元素不同的HTML元素。 I would like to apply it to <span> in order not to create another duplicated style and to be sure that span will always be of the same style as .parsley-errors-list > li . 我想将其应用于<span> ,以便不创建其他重复样式,并确保span始终与.parsley-errors-list > li

.parsley-errors-list {
    display: none;
    margin: 0;
    padding: 0;
}

.parsley-errors-list > li {
    font-size: 12px;
    list-style: none;
    color: #f05050;
}

EDIT: 编辑:

Given CSS sample is part of an updatable theme, so I would like to avoid changing it for the maintainability. 给定的CSS示例是可更新主题的一部分,因此,我想避免为了维护性而对其进行更改。

That's very easy to do. 那很容易做到。 Just put a comma on the CSS selector like this: 只需在CSS选择器上添加一个逗号,如下所示:

.parsley-errors-list > li, span {
    font-size: 12px;
    list-style: none;
    color: #f05050;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM