2017-01-03 27 views
1

我似乎无法找到任何文件的可能性(或者甚至可能)做以下事情。使用SASS的多个嵌套CSS命名空间?

下面是基本的CSS /上海社会科学院命名空间声明:

.example { 
    border: { 
    style: dashed; 
    width: 30px; 
    color: blue; 
    } 
} 

是否有可能也有这种格式,但链top, right, bottom, left声明?

我怎么会想象这个被写入:

.example { 
    border: { 
    top, right, bottom, left: { 
     style: dashed; 
     width: 30px; 
     color: blue; 
    } 
    } 
} 

.example { 
    border: { 
    [top, right, bottom, left]: { 
     style: dashed; 
     width: 30px; 
     color: blue; 
    } 
    } 
} 

回答

0

您将需要一个边界后,将它们添加一个:{},属性是这样的:

.example{ 
     border:{ 
      style: dashed; 
      width:10px; 
     color: blue; 
     } 
    border-top:{ 
     width:3px; 
     } 
    border-left:{ 
     color:red; 
    } 
    border-right:{ 
     width:25px; 
    } 
    padding:70px; 
    } 
+0

谢谢,它并没有完全回答我的问题。 –

2

有可能(抱歉,我以前的错误答案)。这个例子似乎与上海社会科学院的所有版本完美的工作:

.example { 
    border: { 
    top: { 
     style: dashed; 
     width: 30px; 
     color: blue; 
    } 
    left: { 
     style: dashed; 
     width: 30px; 
     color: blue; 
    } 
    } 
} 

检查SassMeister的例子。

+0

我认为可能是这样,我的例子纯粹是理论。似乎我应该在Github上提交一个请求? –

+0

@ shannon-young,查看我的最后一个例子。对不起,我以前的错误回应(今天我在SASS上学到了一些新东西:))。可以嵌套属性,但需要像例子那样分离主题。 –

+1

这就是我最初的想法,但如果可能的话,我正在寻找避免重复的方法。在D.R.Y的条件下思考。 –