How to align checkboxes and their labels consistently cross-browsers

前端 未结 30 2259
有刺的猬
有刺的猬 2020-11-22 05:56

This is one of the minor CSS problems that plagues me constantly. How do folks around Stack Overflow vertically align checkboxes and

30条回答
  •  不要未来只要你来
    2020-11-22 06:04

    Yay thanks! This too has been driving me nuts forever.

    In my particular case, this worked for me:

    input {
        width: 13px;
        height: 13px;
        padding: 0;
        margin:0;
        vertical-align: top;
        position: relative;
        *top: 1px;
        *overflow: hidden;
    }
    label {
        display: block;
        padding: 0;
        padding-left: 15px;
        text-indent: -15px;
        border: 0px solid;
        margin-left: 5px;
        vertical-align: top;
    }
    

    I am using the reset.css which might explain some of the differences, but this seems to work well for me.

提交回复
热议问题