2017-03-10 27 views
0

當在textarea上使用「disabled」時,它會改變其文本顏色和其他屬性,我如何保持textarea的風格而不必在textarea中寫入相同的CSS:disabled?我只是想避免由於您使用的是預處理器,使最終的CSS存在使用「混入」 /選項提供輸入有沒有辦法保持輸入元素的樣式:disabled?無需再次寫入相同的CSS?

input, textarea { 
outline: none; 
border: none; 
display: block; 
margin: 0; 
padding: 0; 
-webkit-font-smoothing: antialiased; 
font-family: $ptsans; 
font-size: rem(16); 
color: $text-color; 
@include placeholder { 
    color: $placeholder; 
} 
background-color: #fff !important; 
} 

p { 
line-height: rem(21); 
} 


textarea { 
    width: 100%; 
    resize: none; 
    background-color:transparent!important; 
    &.editable { 
    width:97%; 
    padding:10px; 
    background-color:#fff!important; 
    height:80px; 
    border-color:#ced2db ; 
    border-radius: 3px; 
    border-style: solid; 
    border-width: 1px; 
    } 
} 
textarea:disabled { 
//Should I write all same styles here again? 
} 
+3

好像你知道如何選擇結合......你爲什麼不只是使用'textarea的,文本區域:禁用{}'而不是' textarea {}'並將你想要應用於這兩者的樣式分組? –

回答

0

「擴展」 - 正確使用取決於情況。請檢查文檔。普通的舊CSS選擇器分組可以也派上用場,這樣的:

textarea, textarea: disabled { 
    width: 100%; 
    resize: none; 
    /* other properties here... */ 
} 
相關問題