简体   繁体   English

CSS-将H1与跨度符号对齐

[英]CSS - aligning H1 with a span symbol

I'm styling the section headings for a website and I can't quite get a span symbol and a H1 heading to align properly. 我正在为网站的节标题设置样式,但是我无法完全获得一个跨度符号和一个H1标题才能正确对齐。 This is how it looks on the site - 这是网站上的样子-

标题

Annoyingly, when I've come to include the code in this snippet the two elements seem to align. 令人讨厌的是,当我将代码包含在此片段中时,这两个元素似乎对齐了。 When I check the console the span element seems to have a buffer around the symbol which prompts it slightly out of line as you can see in the image. 当我检查控制台时,span元素似乎在符号周围有一个缓冲区,提示它在图像中稍有出入。 I'm using bootstrap for the site, could this be a hidden rule that I'm missing? 我正在为网站使用引导程序,这可能是我所缺少的隐藏规则吗?

 .secthead span { font-weight: bolder; font-size: 80px; font-family: 'Gotham-Medium', sans-serif; } .secthead h1 { font-size: 50px; font-family: 'Gotham-Medium', sans-serif; color: #000; text-align: left; padding: 0 0 20px 20px; } .secthead h1, span { display: inline-block; } 
 <div class="secthead"><span style="color: rgb(255,128,55);">&#43;</span><h1>Who We Are</h1></div> 

Just use vertical-align: middle; 只需使用vertical-align: middle; in both tag & remove padding from bottom in h1 tag. 在两个标签中&移除h1标签底部的填充。 check updated snippet below.. 检查下面的更新的片段。

 .secthead span { font-weight: bolder; font-size: 80px; font-family: 'Gotham-Medium', sans-serif; } .secthead h1 { font-size: 50px; font-family: 'Gotham-Medium', sans-serif; color: #000; text-align: left; padding: 0 0 0px 20px; } .secthead h1, span { display: inline-block; vertical-align: middle; } 
 <div class="secthead"><span style="color: rgb(255,128,55);">&#43;</span><h1>Who We Are</h1></div> 

You could use a height and line-height. 您可以使用高度和线高。

 .secthead span { font-weight: bolder; font-size: 80px; font-family: 'Gotham-Medium', sans-serif; } .secthead h1 { margin: 0; font-size: 50px; font-family: 'Gotham-Medium', sans-serif; color: #000; text-align: left; padding: 0 0 20px 20px; line-height: 92px; } .secthead h1, .secthead span { height: 92px; display: inline-block; vertical-align:top; height: 92px; } 
 <div class="secthead"> <span style="color: rgb(255,128,55);">&#43;</span> <h1>Who We Are</h1> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM