请大家帮我看看有什么需要改动的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | <!DOCTYPE html> < html > < head > < meta charset = "UTF-8" > < title ></ title > < style type = "text/css" > /*此处写代码*/ *{margin:0; padding:0; } .bg{background:black; width:1100px; height:100px; position:absolute; top:50%; left:50%; margin-left:-550px; margin-top:-50px; } .logo{ background:url(http://img1.sycdn.imooc.com/climg//58c0d2d900016ce303000100.png); width:300px; height:80px; float:left; } .dht{ width:100px; height: auto; color: white; float: right; font-size: 20px; line-height: 100px; margin-left:30px; text-align: center; cursor: pointer; } .dht:nth-child(4){margin-left: 40px;} </ style > </ head > < body > <!-- 此处写代码 --> < div class = "bg" > < div class = "logo" ></ div > < div class = "dht" >手记</ div > < div class = "dht" >猿问</ div > < div class = "dht" >实战</ div > < div class = "dht" >职业路径</ div > < div class = "dht" >课程</ div > </ div > </ body > </ html > |
14
收起
正在回答
3回答
:nth-child(n) 选择器匹配属于其父元素的第 N 个子元素,不论元素的类型。
你的代码中,匹配的是其父元素<div class="bg">的第4个子元素。
该选择器是CSS3中的选择器,当前学习阶段,使用我们的类或者id选择器去写就可以实现了,进阶的专题中会有详细讲解CSS3的选择器,先学好当前的内容吧。
祝学习愉快!
前端小白入门系列课程
- 参与学习 人
- 提交作业 11218 份
- 解答问题 36712 个
从一个不会编程的小白到一个老司机是需要过程的,首先得入门,学习基础知识,然后才能进阶,最后再到精通,本专题是你走进前端世界的不二选择!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧