[英]media queries to hide the 1st element doesn't work
I have several <hr />
and I use the below css in media queries 我有几个<hr />
,我在媒体查询中使用以下CSS
hr:first-child {
no luck, why? 没有运气,为什么? My scope of media queries is ok, other class work fine but not this one, I wonder.. ?? 我的媒体查询范围还可以,其他课程都可以,但是这还不行,我想知道。
try this: 尝试这个:
hr:first-of-type
{
display:none;
}
As the name of the selector suggests, :first-child
refers to the first child of the element, and :first-of-type
refers to the first element of that type. 就像选择器的名称所暗示的那样:first-child
指元素的第一个子元素,而:first-of-type
指该类型的第一个元素。 I believe you are looking for the latter. 我相信您正在寻找后者。
To select the first HR
You need to use 要选择第一个HR
您需要使用
hr:first-of-type {display: none; }
Using the :first-child
pseudo selector selects every hr
element that is the first child of it's parent. 使用:first-child
伪选择器选择每个hr
元素,它是其父元素的第一个孩子。
Using the :first-of-type
pseudo selector selects the first hr
element of it's parent 使用:first-of-type
伪选择器选择其父元素的第一个hr
元素
Also you can try like the following: 您也可以尝试以下操作:
<hr class="hideinsmallscreen" />
Change the class name as you want .hideinsmallscreen
根据需要更改类名.hideinsmallscreen
Within media query you can use the class to hide that <hr/>
在媒体查询中,您可以使用该类来隐藏<hr/>
.hideinsmallscreen{
display:none;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.