简体   繁体   English

html/css 中文本后的间距

[英]Spacing after text in html/css

so I do not know why adding padding or even margin is not creating extra space after the text.所以我不知道为什么添加padding甚至margin不会在文本之后创建额外的空间。

Output: Output:

在此处输入图像描述

I want space after the Stay Tuned text and I tried adding padding and margin but it still did not work.我想要Stay Tuned文本后的空间,我尝试添加paddingmargin ,但它仍然不起作用。 What seems to be the issue?似乎是什么问题? Any suggestions?有什么建议么?

Code of that text:该文本的代码:

 @import url('https://fonts.googleapis.com/css?family=Montserrat'); body { background: transparent; }.title123 { font-family: "Montserrat"; text-align: center; color: #FFF; letter-spacing: 1px; } h23 { background-image: url(https://media.tenor.com/images/ad3dbde6dd7863faeb8151178df7bc71/tenor.gif); color: transparent; -moz-background-clip: text; -webkit-background-clip: text; text-transform: uppercase; font-size: 35px; } /* styling my button */
 <link rel="stylesheet" href="assets/css/text.css"> <div class="title123"> <h23>Stay Tuned!</h23> </div>

Paddings and margins applies to block elements.填充和边距适用于元素。 You need to make your h23 element a block element - as it is not known HTML element it is rendered as inline by default.您需要使您的h23元素成为块元素 - 因为它是未知的 HTML 元素,它默认呈现为内联。

You shouldn't use it at all...but you can if you really want - just if you need padding or margin make it block or inline-block adding to your CSS a rule like this:你根本不应该使用它......但是如果你真的想要的话,你可以使用它——只要你需要填充或边距,让它blockinline-block添加到你的 CSS 一个这样的规则:

h23 {
  display: inline-block;
}

h23 is not a HTML element. h23不是 HTML 元素。 The heading tags are h1-h6 .标题标签是h1-h6 If you change it to <h2> it will work.如果将其更改为<h2>它将起作用。 Then you can add a class and target that.然后你可以添加一个 class 并定位它。

<h2 class="h23">Stay tuned!<h2>

Then in your css file然后在您的 css 文件中

.h23 {
    margin-bottom: 1rem;
}

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

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