Html 如何在同一班级中为“ul”、“li”和“a”应用样式?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41582830/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 14:14:11  来源:igfitidea点击:

how to apply style for 'ul' and 'li' and 'a' in same class?

htmlcssclasshtml-lists

提问by Scott

i am new to front end development.. i want to apply style for <ul>and <li>and also for <a>in same class.. is it possible ?

我是新来的前端开发..我想申请样式<ul><li>,也为<a>在同一类..这可能吗?

here is my code

这是我的代码

<html>
<head>
<title></title>
<style type="text/css"> 
.menu ul, li, a {
    text-decoration: none;
    list-style-type: none;
    padding: 10px;
    margin-left: 10px;
    border: 2px solid green;
}
</style>
</head>
<body>
    <div class="menu">
    <ul>
        <li>
            <a href="#">Home</a>
            <a href="#">Services</a>
            <a href="#">Customers</a>
            <a href="#">Locations</a>
            <a href="#">Fare</a>
            <a href="#">Contact Us</a>
        </li>
    </ul>
</div>
</body>
</html>

回答by Scott

Yes it's possible...

是的,有可能...

.menu ul { /*css here*/ }
.menu ul li { /*css here*/ }
.menu ul li a { /*css here*/ }

or

或者

.menu ul, .menu ul li, .menu ul li a { /*css here*/ }

or

或者

.menu ul, .menu li, .menu a { /*css here*/ }