前端 - CSS3问题:请问-webkit-background-clip属性,需要写在background属性后面吗?
PHPz
PHPz 2017-04-17 11:26:12
0
2
991
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>background-clip:text</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<style>
*{margin: 0; padding: 0;}
p{width: 300px; height: 60px; 
    border: 1px solid #000;
    margin: 50px auto;
    font-size: 50px; font-weight: bold;
    text-align: center; line-height: 60px;
    /* -webkit-background-clip: text; 写在background上面则clip不生效*/
    background: -webkit-linear-gradient(red,blue);
    -webkit-background-clip: text; /*写在background属性下面,正常*/
    color: rgba(0,0,0,0);
}
</style>
</head>
<body>
    <p>你好啊!</p>    
</body>
</html>

请问一下,为什么 -webkit-background-clip:text;,需要写在background属性的后面,clip才能生效?谢谢!

PHPz
PHPz

学习是最好的投资!

reply all(2)
PHPzhong

CSS abbreviation attribute:

No value specified will be set to its initial value. This may sound reasonable, but it does mean that it will overwrite the previously set value.

MDN---abbreviation attribute of CSS

When the -webkit-background-clip attribute is written after the background attribute, -webkit-background-clip overrides the default value, so it works. On the contrary, just the opposite.

巴扎黑

The last one recognized is the valid one. No matter which attribute is the same.
So, be sure to write what you want to keep at the end.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template