Vertical spacing between p tags needs to be the same as vertical spacing between p and a tags.

huangapple go评论73阅读模式
英文:

Vertical spacing between p tags needs to be the same as vertical spacing between p and a tags

问题

两个 'p' 标签之间的垂直间距与 'p' 标签和 'a' 标签之间的垂直间距不同。如何更新 Tailwind CSS,使得 Tyler Hilbert 和计算机工程之间的垂直距离与计算机工程和 Linked In 之间的垂直距离相同?

<div class="py-8 px-8 max-w-sm bg-white rounded-xl shadow-lg space-y-2 sm:py-4 sm:flex sm:items-center sm:space-y-0 sm:space-x-6 m-4">
    <img class="block mx-auto h-24 rounded-full sm:mx-0 sm:shrink-0" src="../imgs/tyler.jpg" alt="Tyler Hilbert" />
    <div class="text-center space-y-2 sm:text-left">
        <div class="space-y-0.5">
            <p class="text-lg text-black font-semibold">
                Tyler Hilbert
            </p>
            <p class="text-slate-500 font-medium">
                Computer Engineering
            </p>
            <a href="https://www.linkedin.com/in/tyler-hilbert/" class="px-4 py-1 text-sm text-blue-600 font-semibold rounded-full border border-blue-200 hover:text-white hover:bg-blue-600 hover:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2">Linked In</a>
        </div>
    </div>
</div>

Vertical spacing between p tags needs to be the same as vertical spacing between p and a tags.

英文:

The vertical spacing between 2 'p' tags is not the same as the vertical spacing between a 'p' tag and an 'a' tag. How do I update Tailwind CSS so the vertical distance between Tyler Hilbert and Computer Engineering is the same as the vertical distance between Computer Engineering and Linked In?

&lt;div class=&quot;py-8 px-8 max-w-sm bg-white rounded-xl shadow-lg space-y-2 sm:py-4 sm:flex sm:items-center sm:space-y-0 sm:space-x-6 m-4&quot;&gt;
    &lt;img class=&quot;block mx-auto h-24 rounded-full sm:mx-0 sm:shrink-0&quot; src=&quot;../imgs/tyler.jpg&quot; alt=&quot;Tyler Hilbert&quot; /&gt;
    &lt;div class=&quot;text-center space-y-2 sm:text-left&quot;&gt;
        &lt;div class=&quot;space-y-0.5&quot;&gt;
        &lt;p class=&quot;text-lg text-black font-semibold&quot;&gt;
            Tyler Hilbert
        &lt;/p&gt;
        &lt;p class=&quot;text-slate-500 font-medium&quot;&gt;
            Computer Engineering
        &lt;/p&gt;
        &lt;a href=&quot;https://www.linkedin.com/in/tyler-hilbert/&quot; class=&quot;px-4 py-1 text-sm text-blue-600 font-semibold rounded-full border border-blue-200 hover:text-white hover:bg-blue-600 hover:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2&quot;&gt;Linked In&lt;/a&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

Vertical spacing between p tags needs to be the same as vertical spacing between p and a tags.

答案1

得分: 1

以下是您要翻译的内容:

您可以向段落添加leading-none。我还会将div设为flex-col,并使用gap-y来定义行之间的间距。

我还认为,职位与按钮之间的距离应该大于姓名与职位之间的距离,所以我在a标签上添加了mt-3类。但这并不是您的问题,所以您可能希望将其删除。

<div class="flex flex-col gap-y-1">
    <p class="text-slate-700 font-semibold text-lg leading-none">
        Tyler Hilbert
    </p>
    <p class="text-slate-400 font-medium leading-none">
        Computer Engineering
    </p>
    
    <a href="https://www.linkedin.com/in/tyler-hilbert/" class="mt-3 px-4 py-1 mx-auto sm:ml-0 max-w-max text-sm text-blue-600 font-semibold rounded-full border border-blue-200 hover:text-white hover:bg-blue-600 hover:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2">Linked In</a>
</div>

以下是在Tailwind Playground中的工作示例:

https://play.tailwindcss.com/Frw4s4j3wK?layout=horizontal

英文:

You can add a leading-none to the paragraphs. I would also make the div flex-col and use gap-y to define the space between the rows.

I also think it looks better if the distance between the job title and the button is larger than the space between the name and the job title, so I added a mt-3 class to the a tag. But that was not your question, so you might want to remove that.

&lt;div class=&quot;flex flex-col gap-y-1&quot;&gt;
          &lt;p class=&quot; text-slate-700 font-semibold text-lg leading-none&quot;&gt;
              Tyler Hilbert
          &lt;/p&gt;
          &lt;p class=&quot;text-slate-400 font-medium leading-none&quot;&gt;
              Computer Engineering
          &lt;/p&gt;
          
          &lt;a href=&quot;https://www.linkedin.com/in/tyler-hilbert/&quot; class=&quot;mt-3 px-4 py-1 mx-auto sm:ml-0 max-w-max text-sm text-blue-600 font-semibold rounded-full border border-blue-200 hover:text-white hover:bg-blue-600 hover:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-600 focus:ring-offset-2&quot;&gt;Linked In&lt;/a&gt;
        
&lt;/div&gt;

Here is a working example in tailwind playground:

https://play.tailwindcss.com/Frw4s4j3wK?layout=horizontal

huangapple
  • 本文由 发表于 2023年5月21日 09:26:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76297938.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定