css存在形式及优先级
1、如果希望某个样式可以被多个文件使用,为了避免重复编写代码的繁琐,可以将该样式放入css文件中,其他文件通过link调用
新建一个css文件:common.css,写入某个样式:
.c1{ background-color: red; color: white; } .c2{ font-size: 58px; color: black; }
html文件:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="common.css"> </head> <body> <div class="c1 c2" style="color:pink">1234</div> </body> </html>
此时div标签中的三个属性都会在1234上面体现
css中的优先级:div的style标签>.c2>.c1
相关推荐
jiedinghui 2020-10-25
Ladyseven 2020-10-22
zuncle 2020-09-28
xiaohuli 2020-09-02
葉無聞 2020-09-01
nicepainkiller 2020-08-20
AlisaClass 2020-08-09
myloveqiqi 2020-08-09
buttonChan 2020-08-02
drdrsky 2020-07-29
Ladyseven 2020-07-25
nicepainkiller 2020-07-24
AlisaClass 2020-07-19
hellowzm 2020-07-19
background-color: blue;background-color: yellow;<input type="button" value="变蓝" @click="changeColorT
昔人已老 2020-07-19
骆驼的自白 2020-07-18
lanzhusiyu 2020-07-19
hellowzm 2020-07-19
CSSEIKOCS 2020-07-18