html中元素和文本之间的空间

发布于 2025-01-18 14:14:00 字数 129 浏览 5 评论 0原文

在编写 html 时,元素的内边距为零,边距为零,但文本周围有空格。我怎样才能摧毁它?

行高等。我尝试了功能,但没有用。

While writing html, the element has padding zero and margin is zero, but there are spaces around the text. How can I destroy it?

line height etc. I tried features but it didn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

回眸一笑 2025-01-25 14:14:00

您是否在提到的元素之前删除了页面的默认样式?

我认为这可能是问题。

在开始您的页面样式之前,最好的做法是删除所有样式并首先均匀的默认外观。

到目前为止,我一直在所有项目中使用代码。

  *{
    margin:0;
    padding:0;
    box-sizing: border-box;
   }

这将删除整个网页的基本样式。复制并将上述代码粘贴到您的CSS文件中。

如果不是这种情况,则需要将 line-Height 属性添加到H1标签中。这是下面给出的片段。

*{
    margin:0;
    padding:0;
    box-sizing: border-box;
}
h1 {
  background-color:lightblue;
  margin-top: 0px;
  line-height: 75%;
}
<h1>Transitional<br>Heroes<h1/>

Did you remove the page's default stylings before styling mentioned elements?

I think that may be the issue.

Before start styling of your page it is a best practice to remove all the styles and uniforming the default look first.

I've been using the code below for all of my projects up to this point.

  *{
    margin:0;
    padding:0;
    box-sizing: border-box;
   }

This will remove basic stylings for the whole webpage.Copy and paste the above code into your CSS file.

If this is not the case, you need to add the line-height property to your h1 tag. Here is the snippet given below.

*{
    margin:0;
    padding:0;
    box-sizing: border-box;
}
h1 {
  background-color:lightblue;
  margin-top: 0px;
  line-height: 75%;
}
<h1>Transitional<br>Heroes<h1/>

通知家属抬走 2025-01-25 14:14:00

删除页面默认样式。

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

remove the page default styling.

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

最美不过初阳 2025-01-25 14:14:00

使用以下 CSS 代码启动任何项目将为您节省大量时间

*{
    margin:0;
    padding:0;

   }

It'll save you ton of time to start any of your projects with the below css codes.

*{
    margin:0;
    padding:0;

   }
向地狱狂奔 2025-01-25 14:14:00

默认情况下,HTML 在不同的标签中包含某些样式。
要从头开始创建项目,建议使用 CSS 重置文件。社区已经创建了几个。
这些文件重置了所有默认的 HTML 样式以及浏览器之间的不同变体,以在市场上最流行的浏览器中实现相同的视觉结果。

以下是用户 karbassi 通过 GitHub 提供的 CSS 重置:

https://gist.github.com/DavidWells /18e73022e723037a50d6

By default, HTML includes certain styles in the different tags.
To create a project from scratch, it is advisable to use a CSS reset file. The community has created several.
These files reset all the default styles of HTML and the different variants between browsers to achieve the same visual result in the most popular browsers on the market.

Here is a CSS reset offered by the user karbassi through GitHub:

https://gist.github.com/DavidWells/18e73022e723037a50d6

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文