我試圖用sam使用bem語法,但是我遇到一個問題。SASS BEM擴展
下面是代碼:
<button name="button" class="button button__call--full">Call</button>
$color__primary : #23ae4b;
$color__secondary : #1976d3;
////////////////////
// Placeholder //
////////////////////
%button {
background: #45beff;
border: none;
padding: 5px 8px;
font-size: 16px;
border-radius:3px;
color:#fff;
&:hover {
opacity: 0.75;
}
}
////////////////////
// Styling //
////////////////////
.button {
@extend %button;
&__call {
box-shadow:
0 0.150em 1px hsl(100, 80%, 30%), 0 0.5em 5px rgba(0, 0, 0, 0.2);
padding:5px 30px;
position: relative;
&--full{
background: url("../../static/images/arrow.png") no-repeat 96% 52% $color__secondary;
}
}
}
當我的CSS編譯我有這樣的:
.button__call {
box-shadow: 0 0.15em 1px #388a0f, 0 0.5em 5px rgba(0, 0, 0, 0.2);
padding: 5px 30px;
position: relative; }
.button__call--full {
background: url("../../static/images/arrow.png") no-repeat 96% 52% #1976d3; }
,我想有這樣的:
.button__call {
box-shadow: 0 0.15em 1px #388a0f, 0 0.5em 5px rgba(0, 0, 0, 0.2);
padding: 5px 30px;
position: relative; }
.button__call--full {
box-shadow: 0 0.15em 1px #388a0f, 0 0.5em 5px rgba(0, 0, 0, 0.2);
padding: 5px 30px;
position: relative;
background: url("../../static/images/arrow.png") no-repeat 96% 52% #1976d3; }
事實上,延伸當我有一個修飾符時,從我的阻止按鈕,我想要所有樣式,修飾符和元素。我不想這樣做:
<button name="button" class="button button__call button__call--full">Call</button>
上工作,爲什麼你以爲你會得到你想要的輸出在所有目前尚不清楚在這裏。 – cimmanon
我只是想'button__call - full'從'button__call'延伸到一個新的屬性 – Dujard
您的代碼沒有顯示出來。你似乎懂得如何擴展工作,所以在這裏我不清楚我必須解釋什麼。 – cimmanon