以前总是记不住CSS应用到HTML中的时候应该通过什么来进行应用,这次将应用CSS的样式选择器的方法写在这里,以供自己以后容易找到!
CSS样式选择器分为三种,分别是标签选择器、class选择器和id选择器。
注:这里以代码的形式说明样式选择器的三种不同。
标签选择器:
input{background-color:Red;}
class选择器:
<html>
<head>
<title></title>
<style type="text/css">
.mylove{background-color:Red;color:Blue;}
</style>
</head>
<body>
<input type="text" value="123" class="mylove"/>
</body>
</html>
id选择器:
<html>
<head>
<title></title>
#duanluo{color:Yellow;}
</style>
</head>
<body>
<p id="duanluo">你好,你是我的了,美女</p>
</body>
</html>