css 到 asp.net 中的手风琴菜单中的复选框列表控件

发布于 2024-10-31 08:30:27 字数 2328 浏览 1 评论 0原文

我想更改网络表单中可用的复选框列表的默认样式,我可以对文本应用更改,但无法更改看起来更好、更有吸引力的复选框。

<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;
 }

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

I want to change the default style of checkboxlist available in websforms, I can apply changes to the text but cant change the checkbox which looks better and appealing.

<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>
                   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;
 }

Any tutoria;l or help will be appreciated
thnx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷鸟归林 2024-11-07 08:30:28

首先,请注意复选框远非灵活。浏览器不允许您使用 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/漂亮的复选框/
http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/

First off, note that checkboxes are far from flexible. Browsers don't let you style them that much with CSS. Any pure-css solution that you won't change the look of your checkboxes that much... For any serious style change, you will have to code something in javascript that acts like a checkbox.

If your changes are minor / can be done in css :

If you want to style all checkboxes directly in your css, use the following code :

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

Now if you want something particular for some checkboxes, you can go with classes. By applying a CSS class to your checkbox directly. CssClass is a property for standard web controls in ASP.NET so you can apply it to

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

for example.

From there, in your css

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

If you can't do it with CSS :
Here are a couple of examples of what you can do with javascript / css :
http://www.no-margin-for-errors.com/projects/prettycheckboxes/
http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文