开发者

Override properties

开发者 https://www.devze.com 2023-04-02 04:05 出处:网络
I have a class *, but I can\'t override the proporties in this class later on? Why...? * { font-family:tahoma;

I have a class *, but I can't override the proporties in this class later on? Why...?

* {
    font-family:tahoma;
    font-size:11px;
    color:#3c6b93;
}

eg

.test {
    font-size:17px;
    color:red;
}

only way the .test class can override is I delete each s开发者_StackOverflow中文版pecific proporty in the * class


So this is how I do it:

body {
    font:11px/1.2 Tahoma, sans-serif;
    color:#3c6b93;
}

.test {
    font-size:17px;
    color:red;
}

The above properties trickle down (to descendant elements). Therefore, you define the most general rules on the body element. Now, unless overridden, those rules will apply to all elements on the page.


<html>
<head>
    <style type="text/css">
        * {
                font-family:tahoma;
                font-size:11px;
                color:#3c6b93;
        }
        .test {
            font-size:17px;
            color:red;
        }
    </style>
</head>
<body>
    <div>Text</div>
    <div class="test">Text</div>
</body>
</html>

works as expected in my browser.

0

精彩评论

暂无评论...
验证码 换一张
取 消