html - CSS - 将 H1 与跨度符号对齐

标签 html twitter-bootstrap css

我正在为一个网站设置部分标题的样式,但我无法完全正确对齐跨度符号和 H1 标题。这是它在网站上的样子 -

heading

令人讨厌的是,当我将代码包含在此片段中时,这两个元素似乎是对齐的。当我检查控制台时,span 元素似乎在符号周围有一个缓冲区,提示它略微不正常,正如您在图像中看到的那样。我正在为网站使用 Bootstrap ,这可能是我遗漏的隐藏规则吗?

.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>

最佳答案

只需在两个标签中使用 vertical-align: middle; 并从 h1 标签的底部移除填充。检查下面更新的代码段..

.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>

关于html - CSS - 将 H1 与跨度符号对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46604497/

相关文章:

html - .png 作为导航栏上的背景图片

html - 定位列表项

php - 如何在 php 中验证 ID(主键)?

jquery - 响应式移动 Web 开发的加载速度。

html - 如何使用 polymer 改变字体样式

javascript - Bootstrap 4 切换按钮

javascript - highchart 未显示在 django 推特 Bootstrap 中

html - table Angular 上的边框半径不起作用

html - 博主的 WhatsApp 分享按钮

javascript - Webpack 不会捆绑我的 .css 文件