-1

enter image description here

My goal is to vertically center the input in the picture. How can I do that?

.headmenu {
  background-color: rgb(47, 47, 47);
  width: auto;
  height: 30px;
}

.headmenu-right {
  float: right;
  padding-right: 15px;
}

.headmenu-right>input {
  border-radius: 15px;
  padding-left: 5px;
}
<div class="headmenu">
  <div class="headmenu-right">
    <input type="text">
  </div>
</div>
j08691
  • 204,283
  • 31
  • 260
  • 272
Emir Bolat
  • 899
  • 3
  • 14
  • 37

2 Answers2

2

Better to use flexbox here:

.headmenu {
    background-color: rgb(47, 47, 47);
    width: auto;
    height: 30px;
    display: flex; 
    align-items: center;
}

.headmenu-right {
    margin-left: auto;
    padding-right: 15px;
}

.headmenu-right>input {
    border-radius: 15px;
    padding-left: 5px;
}
<div class="headmenu">
    <div class="headmenu-right">
        <input type="text">
    </div>
</div>
Vsevolod Fedorov
  • 481
  • 1
  • 7
  • 20
0

.headmenu {
    background-color: rgb(47, 47, 47);
    width: auto;
    height: 30px;
    display:flex;
    justify-content:end;
    align-items:center;
}

.headmenu-right {
    float: right;
    padding-right: 15px;
}

.headmenu-right>input {
    border-radius: 15px;
    padding-left: 5px;
}
<div class="headmenu">
    <div class="headmenu-right">
        <input type="text">
    </div>
</div>
Krutik Raut
  • 139
  • 7