(1):first-child、:last-child、:nth-child(n)、:only-child
(2):first-of-type、:last-of-type、:nth-of-type(n)、:only-of-type
将DIV添加进CSS里面,首先我们需要给这个div一个id或者是class,然后获取这个元素的id或者是class,css中书写样式就行了,如果是通用样式的话,我们就可以直接写div,然后加样式就行,请看代码:<html>
<head>
<style>
#div1{ //Id的写法
width:300px
height:30px
font-size:13px
}
.div1{//class写法
width:300px
height:30px
font-size:13px
}
div{ //通用样式写法
width:300px
height:30px
}
</head>
<body>
<div id='div1' class='div1'>
<p>我是测试文字</p>
</div>
</body>
</html>