Correction status:Uncorrected
Teacher's comments:
介绍关于css的一些常用选择器
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>常用选择器</title> <style> /*标签选择器*/ ul { border: 1px solid red; margin: 0 auto; padding-left: 0; } /*层级选择器;子代选择器*/ ul li{ list-style: none; width: 40px; height: 40px; background-color: aqua; display: inline-block; text-align: center; line-height: 40px; border-radius: 50%; margin-left: 10px; /*设置阴影*/ box-shadow: 2px 3px 1px #888; } /*id选择器*/ #bg-blue{ background-color: blue; } /*类选择器*/ .bg-green{ background-color: green; } /*属性选择器*/ li[id='bg-blue']{ border: 2px solid red; } /*群组选择器*/ #bg-blue,.bg-green{ border: 2px solid black; } /*相邻选择器*/ #bg-blue + li{ /*background-color: yellow;*/ } /*兄弟同级选择器*/ #bg-blue ~*{ background-color: yellow; } </style> </head> <body> <ul> <li>1</li> <li id="bg-blue">2</li> <li class="bg-green">3</li> <li class="bg-green">4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> <li>9</li> <li>10</li> </ul> </body> </html>
点击 "运行实例" 按钮查看在线实例