css 和/或 SASS +(同级)选择器向上 [英] css and/or SASS + (sibling) selector upwards

查看:73
本文介绍了css 和/或 SASS +(同级)选择器向上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 CSS 中,如果同级在输出中的上方,即 html 中的前导元素,则无法选择带有加号的同级.

例如

<div class="第二个">.second + .first { 样式应用于 div.first}

无论如何可以在 SASS/SCSS 中做到这一点?

解决方案

SASS 支持所有 CSS3 选择器.兄弟+就是其中之一.但它并没有带来一些额外的功能.这意味着你可以做到

第一个{+ 第二 {字体大小:更小;}}

但你不能用它影响父母......

Ps : 这似乎是 CSS4 的一个特性:)

In CSS there is no way to select a sibling with plus if the sibling is above in the output, a preceding element in the html.

For example

<div class="first">
<div class="second">

.second + .first { style applied to div.first}

Is there anyway to do this in SASS/SCSS?

解决方案

SASS support all CSS3 selectors. Sibling + is one of them. But it does not bring some extra features. It means you can do

first {
  + second { 
     font-size: smaller;
  }
}

But you can't impact a parent with it ...

Ps : it seems to be a features of CSS4 :)

这篇关于css 和/或 SASS +(同级)选择器向上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆