1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > css相邻兄弟选择器写法 css中父子元素和兄弟元素的区别 – CSS – 前端 css3图片遮罩层

css相邻兄弟选择器写法 css中父子元素和兄弟元素的区别 – CSS – 前端 css3图片遮罩层

时间:2023-03-14 05:14:34

相关推荐

css相邻兄弟选择器写法 css中父子元素和兄弟元素的区别 – CSS – 前端 css3图片遮罩层

@ css怎么增加边框没有间隙?

css增加边框没有间隙的方式如下

方法一:通用兄弟选择器( ~ )

Document

ul {margin: 0; padding: 0;}

li { list-style: none; height: 50px; line-height: 50px;}

li~li {border-top: 1px solid #000;}

1

2

3

4

5

6

li~li {…} 中的 ~ 符号称为通用兄弟选择器,匹配P元素之后的P元素,所以第一个P元素不会匹配到。

方法二:伪类选择器( :first-of-type / :last-of-type )

Document

ul {margin: 0; padding: 0;}

li { border-top: 1px solid #000; list-style: none; height: 50px; line-height: 50px;}

li:first-of-type {border-top: none;}

1

2

3

4

5

6

首先将所有 li 设置 border-top,然后用 :first-of-type 查找到第一个 li ,取消border-top。

@ css如何同时选到两个标签?

css同时选中两个标签是可以通过他们的类名来选择的,也就是将两个标签设置为同一个类名就可以了,在标签里面类名是可以重复的,如果两个标签是相同的话那么是直接可以通过标签名字就可以选择的了,是非常方便的也可以通过他们相同的属性来选择的。

@ css选择器加是什么?

css选择器加.是类选择器,选择与class属性相匹配的类名

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。