gpt4 book ai didi

html - SASS 将特定属性从父级扩展/共享/继承到子级,反之亦然

转载 作者:太空宇宙 更新时间:2023-11-04 15:28:57 25 4
gpt4 key购买 nike

是否可以将选定的/特定的属性从父级扩展/共享给子级,例如不创建变量?

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

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

}

反之亦然

最佳答案

在你的例子中,.main-container { ul {将呈现为 .main-container ul { ,曾经是 ul 的父元素将是 .main-container你可以通过使用纯 CSS 解决方案来实现你想要的:inherit

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

关于html - SASS 将特定属性从父级扩展/共享/继承到子级,反之亦然,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16544361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com