Aligning text and select boxes to the same width in CSS?

前端 未结 7 1644
误落风尘
误落风尘 2020-12-22 23:32

Ok this is seemingly impossible to get right. I have a text box and a select box. I want them to be the same width exactly so they line up on the left margin and the right m

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-22 23:57

    Add a class to both the select and input tags in question ie:

    
    
    

    then modify the css below to fit your design:

    .custom-input {
            width:140px;
            border:1px solid #ccc;
            margin:1px;
            padding:3px;
            box-sizing: border-box;
            -moz-box-sizing: border-box;
            -webkit-box-sizing: border-box;
            -ms-box-sizing:content-box;
            -moz-box-sizing:content-box;
            -webkit-box-sizing:content-box;
            box-sizing:content-box;
        }
    

    obvs this is a fix for supporting browsers

提交回复
热议问题