Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在不创建变量的情况下从父级向子级扩展/共享选定/特定属性?
.main-container { padding: 20px; margin: 20px; ul { padding:$parentPadding(); margin: 0; } }
或相反亦然
在您的情况下,.main-container { ul {将呈现为.main-container ul {,一旦父元素ul将是.main-container您可以通过使用纯 CSS 解决方案来实现您想要的:inherit
.main-container { ul {
.main-container ul {
ul
.main-container
inherit
ul{ padding: inherit; //Will inherit the padding value of the parent element }