对齐两个元素,一个左,另一个右

时间:2019-02-20 10:34:18

标签: tailwind-css

我第一次尝试使用TailwindCSS,并且尝试自定义下面寺庙中最后一行的表格。

https://www.tailwindtoolbox.com/templates/admin-template-demo.php

我想在标题的右侧添加一个圆圈。像

enter image description here

我尝试了不同的解决方案,而最接近我想要的解决方案是

This has been great for me. I've been on it for 2 weeks and in the last week I only had 3 headaches which went away with 2 Tylenol. I was having chronic daily headaches that wouldn't go away no matter what I took. I'm still a little sleepy during the day, but I know that will get better.

This has been great for me. I have been on it for 2 weeks and in the last week I only had 3 headaches which went away with 2 Tylenol. I was having chronic daily headaches that would not go away no matter what I took. I am still a little sleepy during the day, but I know that will get better.

将绿点放在下边框上。显然, <div class="border-b-2 rounded-tl-lg rounded-tr-lg p-2"> <h5 class="uppercase"><%= host.name %></h5> <span class="rounded-full px-2 py-2 float-right"></span> </div> 不是正确的方法,但我想不出一种使之起作用的方法。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

请勿使用<span>,而应使用<div>,因为<span>需要内容。然后,您可以向左浮动<h5>,向右浮动'circle',但是您需要将clearfix添加到父div。

此外,不必添加类px-2,而只需使用类h-*定义高度,这与宽度w-*相同。我还使用类bg-green设置了绿色的背景色。

<div class="border-b-2 rounded-tl-lg rounded-tr-lg p-2 clearfix">
    <h5 class="uppercase float-left"><%= host.name %></h5>
    <div class="rounded-full h-3 w-3 circle bg-green float-right"></div>
</div>

在这里查看我的codepen:https://codepen.io/CodeBoyCode/pen/jdRbQM

或者您可以使用flex

<div class="border-b-2 rounded-tl-lg rounded-tr-lg p-2 flex">
    <h5 class="uppercase flex-1 text-center"><%= host.name %></h5>
    <div class="rounded-full h-3 w-3 circle bg-green"></div>
</div>