父级div的position属性设置为relative后,并没有设置上下左右偏移量,所以还是在原地。实际上可以设置top: 100px看看效果。
同时子元素的position属性设置为absolute,因为父级div具有位置属性,所以可以相对父级元素进行偏移
同时子元素的position属性设置为absolute,因为父级div具有位置属性,所以可以相对父级元素进行偏移
2021-12-07
最赞回答 / DuDB
<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>css3选择器优先级</title> <style type="text/css"> div{ color:black; } #box{ color:red; } .dv{ color:blue; } ...
2021-11-26
最新回答 / 逍遥猿
直接 .first{ border:1px solid red;} 就行,你的错误是:first就是第二段p的id属性,重复了。first就相当于是给p取的一个独立的名字,就像身份证一样。p有很多,但first只有一个。
2021-11-22