如果需要选择紧接在另一个元素后的元素,而且二者有相同的父元素,可以使用相邻兄弟选择器(Adjacent sibling selector)。

例如,如果要增加紧接在 h1 元素后出现的段落的上边距,可以这样写:

h1 + p {margin-top:50px;}

css相邻兄弟选择器(+),伪类(:hover),伪元素(::after)

css相邻兄弟选择器(+),伪类(:hover),伪元素(::after)

 

 

伪类:
a:link
{color: #FF0000} /* 未访问的链接 */ a:visited {color: #00FF00} /* 已访问的链接 */ a:hover {color: #FF00FF} /* 鼠标移动到链接上 */ a:active {color: #0000FF} /* 选定的链接 */
first-child伪类
p:first-child {color:red};

css相邻兄弟选择器(+),伪类(:hover),伪元素(::after)

 

 伪元素

css相邻兄弟选择器(+),伪类(:hover),伪元素(::after)

 

相关文章:

  • 2022-02-03
  • 2022-12-23
  • 2021-06-14
  • 2021-12-28
  • 2022-12-23
  • 2021-12-07
  • 2021-11-28
  • 2022-12-23
猜你喜欢
  • 2021-09-13
  • 2021-08-28
  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案