SASS从父级到子级扩展/共享/继承特定属性,反之亦然 [英] SASS extend/share/inherit specific properties from parent to child or vice versa

查看:744
本文介绍了SASS从父级到子级扩展/共享/继承特定属性,反之亦然的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以从父母为子女扩展/共享所选/特定的属性,例如不创建变量?

Is it possible to extend/share selected/specific properties to the child from parent for e.g. without creating a variable?

.main-container {
     padding: 20px;
     margin: 20px;

     ul {
          padding:$parentPadding();
          margin: 0;
     }          

 }


推荐答案

在你的情况下, .main-container {ul { code> .main-container ul {,一旦 ul 的父元素为 .main-container 您可以使用纯CSS解决方案实现您想要的<:code>继承

In your case, .main-container { ul { will be rendered as .main-container ul { , once the parent element for ul will be .main-container you can achieve what you want by using a purely CSS solution: inherit

ul{
  padding: inherit; //Will inherit the padding value of the parent element
}

这篇关于SASS从父级到子级扩展/共享/继承特定属性,反之亦然的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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