gpt4 book ai didi

css - 为什么 margin top 在 Tailwind CSS 中不起作用?

转载 作者:行者123 更新时间:2023-12-05 05:48:15 25 4
gpt4 key购买 nike

我试图在 first 中达到 top margin mt-10 但它不起作用。但是,如果我将该表达式作为 mx-10 - 它可以正常工作。

<div className="font-bold text-white">
<a id='first' className="mt-10">Explore</a>
<a id='second' className="mx-4">Collections</a>
<a id='third' className="mx-4">Profiles</a>
</div>

最佳答案

当谈到边距和填充时,浏览器对内联元素的处理方式不同。您可以在内联元素的左侧和右侧添加空间,但不能为内联元素的顶部或底部填充或边距添加高度。给出 <a>标记一个 inline-block类来解决这个问题。

<div className="font-bold text-white">
<a id='first' className="mt-10 inline-block">Explore</a>
<a id='second' className="mx-4 inline-block">Collections</a>
<a id='third' className="mx-4 inline-block">Profiles</a>
</div>

相关链接:Margin Properties

关于css - 为什么 margin top 在 Tailwind CSS 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70837138/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com