2014-11-01 46 views
0

簡單的問題,我有3個複選框的我怎樣才能改變文字顏色旁邊的複選框

我要讓旁邊的文白,和旁邊的文字時我的意思是部分

有任何想法嗎 ?

\t <div class="wrapper3"> 
 
\t <h3 style="color:white;"><i>Choose Your Game Preferences</i></h3> 
 
\t <h4 style="color:white;"><i>Do You Want Sound ?</i></h4> 
 
\t <input type="checkbox" value="No" id="sound">Yes 
 
    <h4 style="color:white;"><i>Do You want Text ?</i></h4> 
 
    <input type="checkbox" value="No" id="text">Yes 
 
\t <h4 style="color:white;"><i>Do You want Flashes ?</i></h4> 
 
    <input type="checkbox" value="No" id="flash">Yes 
 
\t </div>

回答

2

可能是一個跨度是最簡單的:

<h4><i>Do You want Flashes ?</i></h4> 
    <input type="checkbox" value="No" id="flash"> 
    <span class="whiteText">Yes</span> 
</div> 

CSS:

.whiteText { 
color: white; 
} 

或用內嵌樣式通過用style="color:white;"代替類。

+0

工作起來很像一個魅力 – Jamiex304 2014-11-01 20:52:16

+0

您應該考慮使用標籤。 使用標籤時,如果使用表單項目的ID指定其屬性,單擊標籤將觸發該元素,如果您真的點擊它。易於使用和用戶友好。 – 2014-11-01 21:55:43

2

通過給出所有checkbxes和單選按鈕標籤以及「for」屬性,您可以一石二鳥。

這首先允許您將CSS附加到標籤(爲此標籤提供一個標識)。但是,這也是現在編寫複選框和收音機腳本的正確方法,可以讓殘障人士訪問您的網站。視力受損或操作受損的人難以點擊與複選框一樣小的項目。一個標籤隨着它所連接的複選框一起變得可選,爲用戶提供了一個更大的區域來點擊。這些日子是很好的做法,特別是如果你做專業的網站開發。

0

只需添加一個標籤併爲標籤添加樣式。我會在這裏使用內聯樣式,但最好的做法是將html和CSS分開。

<div class="wrapper3"> 
    <h3 style="color:white;"><i>Choose Your Game Preferences</i></h3> 
    <h4 style="color:white;"><i>Do You Want Sound ?</i></h4> 
    <label style="color:white;"><input type="checkbox" value="No" id="sound">Yes</label> 
    <h4 style="color:white;"><i>Do You want Text ?</i></h4> 
    <label style="color:white;"> <input type="checkbox" value="No" id="text">Yes</label> 
    <h4 style="color:white;"><i>Do You want Flashes ?</i></h4> 
    <label style="color:white;"> <input type="checkbox" value="No" id="flash">Yes</label> 
</div> 
相關問題