私のサイトのロゴのテキストは何らかの理由でオフセンターです。 display: inline-block
をオフにして、もう一度中央に置くことができます。しかし、これはテキストの周りの間隔を平らにし、テキストの上にスペーシングを戻すことができません(インライン要素の垂直パディングはできません)。
テキストを背景色で中央に配置する方法はありますか? (text-align: center
を追加しようとすると、何らかの理由でクロムのdevのツールに自動的に採点される?ディスプレイのインラインブロックを使用しているときにテキストがずれて表示される
HTML
<h1 class="logo">
<a href="/"><span class="text logo-title">SomeLogoText</span></a>
</h1>
以下(CSS)
h1.logo {
font-family: "Roboto Slab", arial, sans-serif;
margin-top: 0;
margin-bottom: 0;
font-weight: bold;
font-size: 15px;
float: left;
a {
color: #fff;
padding: 15px 30px;
display: inline-block;
text-align: center;
line-height: 1.4;
max-width: 155px;
background: @color;
.border-radiuses(0, 4px, 4px, 0);
.transition (color 0.4s ease-in-out);
position: relative;
font-size: 20px;
&:hover {
text-decoration: none;
}
}
.logo-title {
vertical-align: middle;
line-height: 1.6;
}
}
ありがとうございます。それは大きな助けです – Yunti