Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Input is offset when changing text size next to it

Not sure why but whenever I change the links next to my search bar on my nav menu, For some reason the input gets slightly moved down. I’m not sure how to explain it….

  @import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@500&display=swap');
  body {
  margin: 0px;
}
.top-nav-bar {
  background-color: #292929;
  height: 55px;
  text-align: center;
  font-family: 'Open Sans', sans-serif;
  color: #DDDDEB;
  font-size: 50px;
}
.spacer {
  margin: 5px;
  display: inline;
  cursor: help;
}
a {
  text-decoration: none;
  color: inherit;
}
a:hover {
  color: #597BEB;
}
.searchbar {
  font-size: 16px;
  border-width: 2px;
  border-color: #CCCCCC;
  background-color: inherit;
  border-style: solid;
  border-radius: 50px;
  width: 150px;
  height: 50px;
}
<div class="top-nav-bar">
  <a href="#">Home</a>
  <div class="spacer"></div>
  <a href="#">Profile</a>
  <div class="spacer"></div>
  <input class="searchbar" type="text" placeholder="Search">
  <div class="spacer"></div>
</div>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How about using vertical-align:top;?

  @import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@500&display=swap');
  body {
  margin: 0px;
}
.top-nav-bar {
  background-color: #292929;
  height: 55px;
  text-align: center;
  font-family: 'Open Sans', sans-serif;
  color: #DDDDEB;
  font-size: 50px;
}
.spacer {
  margin: 5px;
  display: inline;
  cursor: help;
}
a {
  text-decoration: none;
  color: inherit;
}
a:hover {
  color: #597BEB;
}
.searchbar {
  font-size: 16px;
  border-width: 2px;
  border-color: #CCCCCC;
  background-color: inherit;
  border-style: solid;
  border-radius: 50px;
  width: 150px;
  height: 50px;
  vertical-align:top;
}
<div class="top-nav-bar">
  <a href="#">Home</a>
  <div class="spacer"></div>
  <a href="#">Profile</a>
  <div class="spacer"></div>
  <input class="searchbar" type="text" placeholder="Search">
  <div class="spacer"></div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading