html - 将 float 属性应用于复选框然后无法单击复选框?

标签 html css css-float

实现这个enter image description here我做了以下代码

.ContentList {
    padding: 5px;
    border-radius: 5px;
    margin-bottom:20px;
    -webkit-box-shadow: 0px 0px 2px 2px rgba(148,135,148,1);
    -moz-box-shadow: 0px 0px 2px 2px rgba(148,135,148,1);
    box-shadow: 0px 0px 2px 2px rgba(148,135,148,1);
}

    .ContentList .ItemCells {
        width: 270px;
        height: 150px;
        margin: 10px;
        border: solid 1px;
    }

    .ContentList .ItemCellsTitle {
        width: inherit;
        height: 50px;
        border: solid 1px orange;
        vertical-align: middle;
    }

.ItemCellsTitle h4 {
    position: relative;
    top: 7px;
    left: 5px;
}

.ItemCellsContent {
    border: solid 1px green;
    height: 65%;
}

/*.SelectionIndicator {
    float:left;
    margin: 10px 5px 10px 10px;
}*/

input[type="checkbox"] {
    float:left;
    margin: 10px 5px 10px 10px;
}
<div class="ContentList">
        <asp:DataList ID="dlContentList" runat="server" RepeatDirection="Horizontal" RepeatColumns="3">
            <ItemTemplate>

                <div class="ItemCells">
                    <div class="ItemCellsContent">
                        <%# DataBinder.Eval(Container.DataItem,"ContentCD") %>
                    </div>
                    <div class="ItemCellsTitle">
                        <asp:CheckBox ID="cbContentID" runat="server" />
                 
                        <h4>
                            <%# DataBinder.Eval(Container.DataItem,"ContentTitle") %></h4>
                    </div>
                </div>
            </ItemTemplate>
        </asp:DataList>
    </div>

这带来了一个新问题,我无法再点击复选框。如果我将鼠标悬停在它上面,我就不会关注复选框(默认行为)。但是如果我删除复选框的 float 属性,那么它就可以工作了很好,我可以选择和取消选择它。为什么我在应用 float 属性时无法单击复选框

供您删除 float 属性后引用 enter image description here

谢谢......

最佳答案

移除 float ,不要将文本换行在 H4 中。相反,设置 ItemCellsTitle 类的样式以模仿您正在寻找的 H4 样式 - 或者,您可以更改 H4 的 CSS 并将显示设置为内联。如果您移除 float ,任何一个都可以工作。

关于html - 将 float 属性应用于复选框然后无法单击复选框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29959441/

相关文章:

javascript - Firefox 这个页面没有来源

html - 打印平铺在网页上的图像

css - 在网页中的 div 中使用 REM 单位

javascript - 如何关闭 Accordion 菜单的打开部分?

Jquery Datepicker 仅用于月份和年份

html - 如何正确定位此小部件的箭头?

html - 如何使用 css 使表格 td 占据整个宽度?

javascript - 如何知道插入符号位置是否在文本框中的 {} 字符之间?

html - 与 HTML\CSS 模板中页脚的 clear 属性相关的一些疑问

html - 如何使用 Bootstrap3 将两个图像居中