Is it possible to control vertical space using purely CSS? -


i have header bar logo on left , search form following. both floated left. trying control vertical spacing of search form using css cannot find solution other adding padding and/or margin either on top or bottom of search form, , although may able find values work in 1 browser, not solution consistent across browsers... same problem exists if have search button next search field. there solution cross-browser compatible or need use javascript? there standard doing this?

p.s. reset css in dev code.

here simplified version of header code:

body {      font-family: arial, sans-serif;  }    header {      overflow: hidden;      background-color: black;  }    {      text-decoration: none;      color: white;  }    #site-title, #search {      float: left;  }    #site-title {      margin-right: 50px;      background-color: green;      font-size: 28px;  }    #search {      background-color: red;      margin-top: 5px  }
<body>      <header>          <div id="site-title"><a href="#">site title</a></div>          <div id="search">              <form>                  <input type="search" placeholder="search..." />              </form>          </div>      </header>  </body>

link code on jsfiddle: http://jsfiddle.net/mg535m80/2/

edit: found solution, it's not cross-browser compatible i'd hoped, works in modern browsers. added display: flex; , align-items: center parent, , worked charm. new code:

body {      font-family: arial, sans-serif;  }    header {      overflow: hidden;      background-color: black;      display: flex;      align-items: center;  }    {      text-decoration: none;      color: white;  }    #site-title, #search {      float: left;  }    #site-title {      margin-right: 50px;      background-color: green;      font-size: 28px;  }    #search {      background-color: red;  }
<body>      <header>          <div id="site-title"><a href="#">site title</a></div>          <div id="search">              <form>                  <input type="search" placeholder="search..." />              </form>          </div>      </header>  </body>

updated jsfiddle: http://jsfiddle.net/mg535m80/9/

the problem style of input, different between browsers.

solution: make input way want, set styles explicitly instead of relying on defaults. example:

input {     width:10em; height:1.25em;     margin:0; border:2px solid #888; padding:0;     font:inherit; vertical-align:baseline; } 

see updated fiddle


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -