【问题标题】:Sass - H5 text alignment [duplicate]Sass - H5文本对齐[重复]
【发布时间】:2015-11-02 04:32:34
【问题描述】:

您好,我目前正在使用 rails 4.2 并使用 sass 和 haml 。我正在尝试将我拥有的 h5 居中对齐,但它似乎不想与我合作,我已经尝试使用谷歌搜索但仍然失败

这是我的代码

静态页面是这样的

.row#mod
    .container#space
        .row
            .col-md-2
                .thumbnail
                    .caption
                        =image_tag "a.png", tag: "",class: "img-thumbnail"
                        %h5
                            %b#tag Lead
                        %br

sass 是这样的

#tag
    text-align: center

但是h5的中心对齐仍然无济于事,谁能帮助我,谢谢

【问题讨论】:

  • 这不是 Rails 或 Sass 问题,请提供编译后的标记/CSS。
  • 这是为页面上的一个 h5 标签设置样式,否则使样式更概括为“.thumbnail .caption h5”之类的内容并添加“text-align: center”。

标签: sass ruby-on-rails-4.2


【解决方案1】:

id tag 位于内联元素 <b> 上,因此 text-align: center 不会在块 h5 元素中居中。您可以制作#tag display: block,或者您应该将text-align: center 移动到h5。

示例 1:

#tag
    display: block
    text-align: center

示例 2:

.caption h5
    text-align: center

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-27
    • 1970-01-01
    • 2016-12-08
    • 2012-01-29
    • 2020-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多