html - 如何使用 CSS 设置常规(未标记)HTML 文本的样式?
问题描述
所以我刚开始学习 HTML 和 CSS,就像 2 天前一样,我遇到了一个问题。我正在为自己创建一个备忘单,无论我做什么,所有的 CSS 文本缩进都只适用于我的 h2 标签。
<section>
<!-- Bold, Italics, Underline -->
<h2>Bold, Italics, and Underline</h2>
<strong><strong></strong> The strong tag is used to <strong>bolden</strong> text.
<br>
<strong><em></strong> The em tag is used to <em>italicise</em> text.
<br>
<strong><u></strong> The u tag is used to <u>underline</u> text.
</section>
这就是我编写代码的方式,我根据相关标签对行进行分段,并将它们全部放在带有容器类的 div 中。在我的 CSS 样式表中,我玩弄了一下text-indent
,发现无论我把它放在哪里,它都只适用于我的 h2 标签。
我已经尝试将该命令嵌套在不同的 CSS 类中,删除我的所有部分并将我的文本保留在 div 中,等等,但没有任何效果。由于填充,我不想为每一行文本使用段落标签,这就是我使用常规文本的原因。
解决方案
正如w3schools所说text-indent
:
定义和使用
text-indent 属性指定文本块中第一行的缩进。
至于什么算作文本块,你可以在这里找到。
或者,您可以使用 CSSmargin-left
样式移动该部分。
例子:
<section style="margin-left: 12px;">
<strong>This is Indented with margin</strong>
<br>
Lorem consectetur mollit proident ad quis commodo pariatur ullamco mollit eiusmod cupidatat amet fugiat.
</section>
<br>
<br>
<br>
<section>
<strong>This is unindented</strong>
<br>
Lorem consectetur mollit proident ad quis commodo pariatur ullamco mollit eiusmod cupidatat amet fugiat.
</section>
推荐阅读
- mysql - 如何在具有条件的第二个表上使用 Group by 时从左表中检索所有数据
- angular - styles.css - 错误:(0 , _identifier.getUndoPath) 不是函数
- java - Error Creating Bean 错误(Spring Cloud Config Client)
- c# - 谷歌控制台应用程序包(Xamarin)上传问题
- asp.net - 使用 blob 将图像上传到服务器
- python - 忽略y轴标题位置
- amazon-web-services - SQS - 减少非空队列的最大消息大小
- c# - 混合 Winforms/控制台应用程序正确终止,但必须按“Enter”才能恢复控制台提示
- javascript - 与根相关的 Shadow Dom 媒体查询
- asp.net - IIS URL 重写模块不适用于 WCF Post API