Input box 100% width, with label to the left

后端 未结 2 1338
无人共我
无人共我 2021-02-06 05:48

I\'m trying to have a fluid input box with 100% width, while having the label floated to the left. Here\'s what I currently have:

.left {
  float: left;
}

inpu         


        
2条回答
  •  天涯浪人
    2021-02-06 06:40

    I recently found out about calc in css:

    width: calc(100% - 100px);
    

    this can be used to solve this problem: jsfiddle here

    HTML:

    label

    CSS:

    .setting {
        position: relative;
        width: 100%;
    }
    .setting .s2 {
        position: absolute;
        left: 180px;
        width: calc(100% - 184px);
    }
    

提交回复
热议问题