繁体   English   中英

如何在 HTML 标签上使用多个样式?

[英]How Do I Use More Than One Style On HTML Label?

以下 HTML 代码适用于我的 GSP 以使标签加粗,但我还想分配一个下边距。

这是我的标签的当前代码:

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

我还想在此标签上设置以下样式:

style="margin-bottom: 0.3cm"

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

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

 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>

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

您可以在分号后添加更多 css 语法

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

这 ; 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>

暂无
暂无

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

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