asp.net - css to checkboxlist控件在asp.net的 Accordion 菜单中

标签 asp.net css accordion checkboxlist

我想更改 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或帮助将不胜感激 谢谢

最佳答案

首先,请注意复选框远非灵活。浏览器不允许您使用 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/

关于asp.net - css to checkboxlist控件在asp.net的 Accordion 菜单中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5596373/

相关文章:

javascript - 当另一个打开时如何关闭 Accordion ?

css - 单击 Accordion 标题时移动设备上的文本缩放

javascript - Semantic-ui Accordion 获取 onOpen 事件中打开项目的索引

asp.net - 在 azure 上转换 web.config

asp.net - 如何设计 "Country"、 "Province"和 "City"表?

css - 我必须使用什么 webpack 加载器来组合媒体查询?

html - 导航栏子菜单显示在图像后面

.net - 我是否需要手动删除所有事件以使我的对象从内存中删除?

c# - 如何集成 Expression<Func<>> 来清理我的 Linq-to-Entity 查询?

javascript - 我想在点击的范围内添加类(class)