I have this header, and I want to center the text vertically, but to keep it aligned on the right, this is my current code:
<style>
.top-menu {
font-family: "Ubuntu";
color: white;
font-size: 16px;
text-align: right;
vertical-align: middle;
line-height: 30px;
/* padding: 0px 0px 20px 0px;*/
margin-right: 10px;
}
.background-gray {
background-color: gray;
padding: 2px 0px 0px 0px;
margin: -8px -8px 0px -8px;
}
</style>
<div class="background-gray">
<h4 class="top-menu">O nama Kontakt Lokacija</h4>
</div>
You shouldn't need to do any tricky padding
or margin
stuff. Simply:
.top-menu {
font-family: "Ubuntu";
color: white;
font-size: 16px;
text-align: right;
line-height: 30px;
padding-right: 8px;
}
.background-gray {
background-color: gray;
}
<div class="background-gray">
<h4 class="top-menu">O nama Kontakt Lokacija</h4>
</div>
See this fiddle
You mean the result like this?
<style>.top-menu { font-family: "Ubuntu"; color: white; font-size: 16px; text-align: right; vertical-align: middle; line-height: 30px; /* padding: 0px 0px 20px 0px;*/ margin-right: 10px; }.background-gray { display: flex; background-color: gray; padding: 2px 0px 0px 0px; margin: -8px -8px 0px -8px; } </style>
<div class="background-gray"> <h4 class="top-menu">O nama Kontakt Lokacija</h4> </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.