2014-11-01 45 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> 
相关问题