html - css calc() not producing expected result -
i trying achieve specific of responsive search bar display search input, select option filters , submit button in 1 row. submit button , select have defined widths of 44px , 110px respectively , want search input field occupy rest of available space, therefore use width: calc(100% - 154px);. not working intended. please see example here https://jsfiddle.net/t97fqqxu/
html:
<div id="main-search">     <form>         <input type="text" placeholder="search.." />         <select>             <option>option</option>         </select>         <input type="submit" value="submit"/>     </form> </div>   css
#main-search {     background-color: @palette-white; } #main-search form {     width: 100%;     background: green; }  #main-search input[type="text"] {     width: calc(100% - 154px); }  #main-search select {     width: 110px; }  #main-search input[type="submit"] {     text-indent: -9999px;     width: 44px;     height: 44px; }   edit: i'm taking advantage of bootstrap 3's box-model, no mater margins , paddings, widths 44px , 110px
you didn't account border on input elements. default, border/padding added element's width/height. in other words, if give element width of 110px, still need account element padding/border.
you either remove border, or use box-sizing: border-box account border in element's width/height calculation:
input[type="text"] {   border: none; }   or..
input[type="text"] {   box-sizing: border-box; }   in addition, it's worth pointing out inline elements respect whitespace in markup, needed remove too. see updated example above.
Comments
Post a Comment