1

我想更改 websforms 中可用的复选框列表的默认样式,我可以将更改应用到文本,但不能更改看起来更好且吸引人的复选框。

<div id="left_columnforSale">   
 <asp:Accordion ID="Accordion1" runat="server" SelectedIndex="0" HeaderCssClass="accordHeader" ContentCssClass="accordContent" HeaderSelectedCssClass="accordHeaderSelected"
           AutoSize="None"
            FadeTransitions="true"
            TransitionDuration="50"
            FramesPerSecond="20"
            RequireOpenedPane="false"
            SuppressHeaderPostbacks="True">
            <Panes>
              <asp:AccordionPane>
               <Header>
                &nbsp;&nbsp;&nbsp;CheckListBox
                </Header>
                 <Content>
                    <asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged" CssClass="chkbox">
                    <asp:ListItem Value="0 AND 1000">0 - £1,000</asp:ListItem>
                    <asp:ListItem Value="1000 AND 2000">£1,000 - £2,000</asp:ListItem>
                    <asp:ListItem Value="2000 AND 3000">£2,000 - £3,000</asp:ListItem>
                    <asp:ListItem Value="3000 AND 4000">£3,000 - £4,000</asp:ListItem>
                    <asp:ListItem Value="4000 AND 5000">£4,000 - £5,000</asp:ListItem>
                    <asp:ListItem Value="5000 AND 6000">£5,000 - £6,000</asp:ListItem>
                    <asp:ListItem Value="6000 AND 7000">£6,000 - £7,000</asp:ListItem>
                    <asp:ListItem Value="7000 AND 8000">£7,000 - £8,000</asp:ListItem>
                    <asp:ListItem Value="8000 AND 9000">£8,000 - £9,000</asp:ListItem>
                    <asp:ListItem Value="9000 AND 10000">£9,000 - £10,000</asp:ListItem>

                    </asp:CheckBoxList>

                </Content>

            </asp:AccordionPane>

            </Panes>
 </asp:Accordion>

CSS:

#left_columnforSale .accordContent
{
color: #999999;
font-size: 11px;

}
#left_columnforSale .accordContent .chkbox td:hover
{
color: #606060;
text-decoration: underline;
cursor: pointer;
 }

任何教程;l 或帮助将不胜感激

4

1 回答 1

0

首先,请注意复选框远非灵活。浏览器不允许您使用 CSS 来设置它们的样式。任何不会改变复选框外观的纯 CSS 解决方案...对于任何严重的样式更改,您都必须在 javascript 中编写类似于复选框的代码。

如果您的更改很小/可以在 css 中完成:

如果要直接在 CSS 中设置所有复选框的样式,请使用以下代码:

input[type="checkbox"]{
    /* Here are the styles that will be applied to ALL checkboxes */
}

现在,如果您想要某些复选框的特定内容,您可以使用类。通过将 CSS 类直接应用于您的复选框。CssClass 是 ASP.NET 中标准 Web 控件的属性,因此您可以将其应用于

<asp:ListItem CssClass="checkbox" Value="0 AND 1000">0 - £1,000</asp:ListItem>

例如。

从那里,在你的 CSS

.checkbox {
    /* Here are the styles that apply to checkboxes that have the checkbox css class */
}

如果你不能用 CSS 做到这一点:这里有几个例子说明你可以用 javascript/css 做些什么: http ://www.no-margin-for-errors.com/projects/prettycheckboxes/ http:// ryanfait.com/resources/custom-checkboxes-and-radio-buttons/

于 2011-04-08T15:27:19.690 回答