html - 如何使用填充在标题下方画线到标题大小

标签 html css

我想在标题下面放一条线到标题大小,如果我使用 border-bottom 那么线和标题之间就没有空格了。所以我需要一些其他的解决方案。 Style need to be like this

 h2 {
    color: #0085c3;
    font-family: Helvetica Neue,Helvetica,Arial,sans-serif;
    font-size: 33px;
    font-weight: 600;
    line-height: 30px;
    margin: 40px auto 25px;
    text-align: center;
}
h2::after {
    background: #000;
    display: block;
    height: 2px;
    width: 50px;
}

最佳答案

你使用的border-bottom很好,现在你可以使用padding-bottom来增加空间。像这样:

h2 {
  color: #0085c3;
  font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
  font-size: 33px;
  font-weight: 600;
  line-height: 30px;
  margin: 40px auto 25px;
  text-align: center;
}
h2 span {
  border-bottom: 1px solid #0085c3;
  padding-bottom: 10px;
}
<h2><span>ADVERTISING</span></h2>

关于html - 如何使用填充在标题下方画线到标题大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39191620/

相关文章:

javascript - 将值增加一个 jQuery

javascript - JQuery appendTo Div 带有ID而不是appendTo ('body')

css - Bootstrap 中的自定义按钮

html - 背景大小 : cover; makes page scrollable to sides

jquery - 我怎样才能用 jquery 覆盖这个 css 行为?

javascript - 使用 appendChild 将 CSS 附加到文档无法按预期工作

jquery - 在响应式背景图像上更改一次背景图像

html - bootstrap 4 中导航栏右侧的折叠按钮

asp.net-mvc-3 - HtmlHelper 和 htmlAttributes 帮助

javascript - 将 JavaScript 中的值集成到 HTML 表单中以将其发布到 php 中