Как выровнять текст ссылки по центру?

Есть ссылка, которая расположена в header. Header width = 100%, height = 41px.

Как центрировать текст ссылки Login/Register по высоте относительно header? И при наведении на ссылку background-color должен меняться на тёмно-зелёный.

header {
  background-color: rgb(0, 146, 63);
  box-shadow: 0px 5px 15px 0px rgba(0, 146, 63, 0.5);
  position: relative;
  left: 0px;
  top: 0px;
  width: 100%;
  height: 41px;
  z-index: 3;
  vertical-align: middle;
}

.login_button {
  position: absolute;
  right: 5%;
  color: white;
  height: 41px;
}

.login_button .text {
  padding: 20px;
  Почемуто отступы появляются только по бокам
}
<header>
  <div class="circle"></div>
  <div class="container_1">Free Shipping on Orders of Rs. 2587 - <strong style="color:yellow">SHIP39</strong></div>
  <div><a href="#" class="login_button"><span class="text">Login / Register</span></a></div>
</header>

Как есть сейчас

Сейчас

Как должно быть

Должно быть


Ответы (4 шт):

Автор решения: Шоха Назаров
.login_button .text {
line-height:41px;
}
→ Ссылка
Автор решения: Tryd0g0lik

position: absolute; позиционирует относительно блока position: relative; но это блок котором находится a.

Переносим position в Header > div:last-child и добавляем css

Header > div:last-child{
    position: absolute;
    right: 5%;
    top: 0;
    max-height: 41px;
    height: inherit;
   }

далее

Header > div:last-child a{
   display: block;
   width: 120px;
   }

после вариант А

Header > div:last-child a span{
display: block;
height: inherit;
padding: none;
margin:none;
position: absolute;
top: 25%;
   }

Header > div:last-child a span позиционирует относительно <a> Есть вариант B

Header > div:last-child a{
   display: block;
   height: auto;
   width: 120px;
   padding: **px 0 0 0;
   }

и выравниваете ссылку по центру

Header > div:last-child a span{
display:inline;
}
→ Ссылка
Автор решения: De.Minov

Используйте Flexbox и не заморачивайтесь с position: absolute, он тут не нужен.

body {
  margin: 0;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 41px;
  background-color: #009235;
  color: rgba(255,255,255,0.9);
  box-shadow: 0 0 10px 0 #009235;
  padding: 0 10px;
  box-sizing: border-box;
}

.header__left {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-right: 10px;
}

.header__right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.header__info code {
  font: inherit;
  font-weight: bold;
  color: #ff0;
}

.header__profile {
  margin-right: 10px;
}

.header__profile a {
  color: inherit;
  text-decoration: none;
}

.header__profile a:hover {
  color: rgba(0,0,0,0.5);
}

.header__cast span {
  display: inline-block;
  padding: 0.1em 0.45em;
  border-radius: 100px;
  font-size: 0.9em;
  background: rgba(0,0,0,0.35);
  margin-left: 3px;
}
<header class="header">
  <div class="header__left">
    <div class="header__info">Shipping on Orders of Rs. 2587 - <code>SHIP39</code></div>
  </div>
  <div class="header__right">
    <div class="header__profile"><a href="#">Login</a><span> / </span><a href="#">Register</a></div>
    <div class="header__cast">Cast <span>0.00</span></div>
  </div>
</header>

→ Ссылка
Автор решения: Arcadiy

Перевел во flex.

header {
background-color: rgb(0, 146, 63);
    box-shadow: 0px 5px 15px 0px rgb(0 146 63 / 50%);
    position: relative;
    left: 0px;
    top: 0px;
    width: 100%;
    height: 41px;
    z-index: 3;
    display: flex;
    vertical-align: middle;
    flex-direction: column;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-evenly;}

.login_button {
     position: relative;
    right: 5%;
    color: white;
    height: 41px;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-end;
    justify-content: center;
    align-items: center;
}

.login_button .text {
  padding: 20px;
  Почемуто отступы появляются только по бокам
}
<header>
  <div class="circle"></div>
  <div class="container_1">Free Shipping on Orders of Rs. 2587 - <strong style="color:yellow">SHIP39</strong></div>
  <div><a href="#" class="login_button"><span class="text">Login / Register</span></a></div>
</header>

→ Ссылка