Ad
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:[email protected]&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 target="_blank" rel="nofollow noreferrer" href="#">Home</a>
<div class="spacer"></div>
<a target="_blank" rel="nofollow noreferrer" href="#">Profile</a>
<div class="spacer"></div>
<input class="searchbar" type="text" placeholder="Search">
<div class="spacer"></div>
</div>
Ad
Answer
How about using vertical-align:top;
?
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:[email protected]&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 target="_blank" rel="nofollow noreferrer" href="#">Home</a>
<div class="spacer"></div>
<a target="_blank" rel="nofollow noreferrer" href="#">Profile</a>
<div class="spacer"></div>
<input class="searchbar" type="text" placeholder="Search">
<div class="spacer"></div>
</div>
Ad
source: stackoverflow.com
Related Questions
- → October CMS create a multi select Form field
- → How to update data attribute on Ajax complete
- → laravel blade templating error
- → should I choose reactjs+f7 or f7+vue.js?
- → How to dynamically add class to parent div of focused input field?
- → Setting the maxlength of text in an element that is displayed
- → Undefined Result for Variable with Javascript innerHTML function
- → Expanding search bar not expanding before search
- → Get the calling element with vue.js
- → Blade: how to include a section in one page but not in another
- → How to print/log reactjs rendered dom?
- → how to write react component to construct HTML DOM
- → How to add a timer in HTML5 and Javascript?
Ad