【问题标题】:How Do I Use More Than One Style On HTML Label?如何在 HTML 标签上使用多个样式?
【发布时间】:2019-04-05 17:54:27
【问题描述】:

以下 HTML 代码在我的 GSP 上工作,使标签 bold,但我还想指定一个底部边距。

这是我标签的当前代码:

<label class="control-label col-sm-6" style="font-weight: bold;" for="customerSection">
                    Most Updated Customer Information Available
</label>

我还想在这个标签上设置如下样式:

style="margin-bottom: 0.3cm"

但是,我还不需要将两者都分配给一个标签。我将如何将粗体样式和边距底部样式分配给此标签?

【问题讨论】:

  • 为什么不将control-label 类和样式与 CSS(或其他选择器)一起使用?

标签: html gsp


【解决方案1】:

你应该像下面这样添加所有的 css,因为内联 css 不是一个好习惯。我建议您在“样式”标签内的不同文件或同一文件中提供如下所有样式

label.control-label.col-sm-6 {
  margin-bottom: 0.3cm;
  font-weight: bold;
  float: left;
}
<label class="control-label col-sm-6" for="customerSection">
                    Most Updated Customer Information Available
</label>

【讨论】:

    【解决方案2】:

    ; CSS(编写样式的编程语言)中的符号表示语句的结束。意义;要更改多种样式,您只需用此符号将它们分开即可。

    修改后的 HTML:

    <label class="control-label col-sm-6" style="font-weight: bold; margin-bottom: 1em;" for="customerSection">
                        Most Updated Customer Information Available
    </label>
    

    对于大小,请使用 em、px 或 %。

    另一种加粗的方法是将文本包围在标签中,而不是 - 例如:

    <label class="control-label col-sm-6" style="margin-bottom: 1em;" for="customerSection">
                            <strong>Most Updated Customer Information Available</strong>
    </label>
    

    【讨论】:

      【解决方案3】:
      <label class="control-label col-sm-6" style="font-weight: bold;margin-bottom: 0.3cm" for="customerSection">
                      Most Updated Customer Information Available </label>
      

      【讨论】:

      • 只有代码的答案通常可以从一些解释性文本中受益。在这种情况下,您可以讨论它的工作原理以及是否有任何限制,甚至可以建议有更好的方法来处理样式。
      【解决方案4】:

      分号后面可以添加更多的css语法

      <label class="control-label col-sm-6" style="font-weight: bold;margin-bottom: 0.3cm;" for="customerSection">
                          Most Updated Customer Information Available
      </label>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-03-27
        • 1970-01-01
        • 2021-08-31
        • 2017-12-21
        • 1970-01-01
        • 2022-01-07
        • 2021-07-25
        • 1970-01-01
        相关资源
        最近更新 更多