2017-05-30 47 views
-1

我試圖讓一些CSS屬性出現在我的窗體中,但是當我將屬性移動到父html元素時,它不起作用。 的CSS屬性直接應用於.input類的工作,但是當應用於父.form-control類,他們不工作,似乎並沒有影響到.form-control性的輸入和沒有出現在Chrome瀏覽器開發工具,如果我檢查文本輸入元素?沒有出現在文本輸入上的CSS屬性

.form-control { 
 
    display: inline-block; 
 
    height: 34px; 
 
    width: 100%; 
 
    margin: 10px; 
 
    border-radius: 4px; 
 
    border: 1px solid #ccc; 
 
} 
 

 

 
/*.form-control .input {*/ 
 
/*height: 34px;*/ 
 
/*width: 100%;*/ 
 
/*margin: 10px;*/ 
 
/*border-radius: 4px;*/ 
 
/*border: 1px solid #ccc;*/ 
 
/*}*/ 
 

 
.form-control .button { 
 
    display: block; 
 
    background-color: limegreen; 
 
    font-size: 14px; 
 
    font-weight: 400; 
 
    color: white; 
 
    margin: auto; 
 
    vertical-align: middle; 
 
    padding: 6px 12px; 
 
    border: 1px solid transparent; 
 
    height: 25px; 
 
    border-radius: 4px; 
 
}
<form className="form-control"> 
 
    <input className="input" type="text" /> 
 
    <button className="button">Get Weather</button> 
 
</form>

+0

why className =「」and not class =「」? –

+1

很可能是因爲OP採用陣營:https://facebook.github.io/react/docs/dom-elements.html – Terry

+1

是抱歉,我應該怎麼用陣營增加了。 – Yunti

回答

1

從代碼片斷你提供的,那是因爲你是直接應用規則的形式,而不是形式的輸入。輸入不會繼承您在窗體上設置的屬性。您需要特別針對輸入,就像您在註釋掉的代碼中一樣。