【问题标题】:Border and Spacing in TailwindTailwind 中的边框和间距
【发布时间】:2021-11-07 00:45:21
【问题描述】:

我很难在文本下方的线条上制作边框半径,而且我也有关于如何在文本和底线之间放置间距的问题。 这是我的预期输出

预期输出 -> https://ibb.co/RSKytWm

Codepen -> Codepen

代码

<div class="
    min-h-screen
    flex
    items-center
    justify-center
    py-4
    px-4
    sm:px-6
    lg:px-6
    bg-black
  ">
  <div class="max-w-lg w-full space-y-8">
    <div class="flex flex-col w-full px-4 py-4 sm:px-6 md:px-8">
      <div class="flex flex-row justify-center">
        <button class="
                  inline-flex
                  items-end
                  justify-center
                  h-20
                  w-28
                  text-white
                  font-regular
                  border-b-4 border-white
                  rounded-3xl
                ">
          Personal Details
        </button>
        <button class="

                  inline-flex
                  items-end
                  justify-center
                  h-20
                  w-28
                  text-white
                  font-regular
                  border-b-4 border-white
                  rounded-3xl
                        mr-10
                  ml-10
                ">
          Contact Details
        </button>
        <button class="
                  inline-flex
                  items-end
                  justify-center
                  h-20
                  w-28
                  text-white
                  font-regular
                  border-b-4 border-white
                  rounded-3xl
                ">
          Other Details
        </button>
      </div>
    </div>
  </div>

</div>

【问题讨论】:

  • 文本和边框之间的间距。您可以通过使用 padding bottom 来实现这一点。示例:pb-2
  • @Lowgy。是的,但是线的边界半径呢?
  • @Joesph 现在正在调查边界。
  • @Lowgy 谢谢。如果按钮不适用于此场景,您可以更改它,只要它看起来像我发布的图像即可
  • 我试图在文本下方的按钮内放置一个跨度。它只是您想要实现的“边界”的形状。

标签: css tailwind-css tailwind-ui


【解决方案1】:

更新:

和OP讨论了很久,OP注意到上面没有弯曲(反正我没注意到),如下:

即使添加rounded-t-sm 也无法解决它,因为这是无法解决的,因为我们将bottom-border 添加到按钮中,解决的唯一方法是删除bottom-border 并添加&lt;hr&gt; 和让它看起来像线条。

更新代码:

<div class="min-h-screen flex items-center justify-center py-4 px-4 sm:px-6 lg:px-6 bg-black">
    <div class="max-w-lg w-full space-y-8">
        <div class="flex flex-col w-full px-4 py-4 sm:px-6 md:px-8">
            <div class="flex flex-row justify-center">
                <button class="inline-flex flex-col items-end justify-center h-50 w-50 rounded-sm text-white font-regular">
                    Personal Details
                    <hr class="w-full border-white rounded-md border-2 mt-2" />
                </button>
                <button class="inline-flex flex-col items-end justify-center h-50 w-50 rounded-sm text-white font-regular mr-10 ml-10">
                    Contact Details
                    <hr class="w-full border-white rounded-md border-2 mt-2" />
                </button>
                <button class="inline-flex flex-col items-end justify-center h-50 w-50 rounded-sm text-white font-regular">
                    Other Details
                    <hr class="w-full border-white rounded-md border-2 mt-2" />
                </button>
                
            </div>
        </div>
    </div>
</div>

更新结果:

Playground

旧答案

不确定添加border-radius有什么困难,尝试添加rounded-sm,它会起作用。

如果您想在文本和行之间添加一些空格,请尝试在按钮上添加一些padding,我认为py-2 会满足您的需求。

代码:

<div class="min-h-screen flex items-center justify-center py-4 px-4 sm:px-6 lg:px-6 bg-black">
    <div class="max-w-lg w-full space-y-8">
        <div class="flex flex-col w-full px-4 py-4 sm:px-6 md:px-8">
            <div class="flex flex-row justify-center">
                <button class="inline-flex items-end justify-center h-50 w-50 py-2 rounded-sm text-white font-regular border-b-4 border-white">
                    Personal Details
                </button>
                <button class="inline-flex items-end justify-center h-50 w-50 py-2 rounded-sm text-white font-regular border-b-4 border-white mr-10 ml-10">
                    Contact Details
                </button>
                <button class="inline-flex items-end justify-center h-50 w-50 py-2 rounded-sm text-white font-regular border-b-4 border-white">
                    Other Details
                </button>
            </div>
        </div>
    </div>
</div>

结果:

Playground

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-21
    • 2011-04-22
    • 2021-03-19
    • 2022-01-25
    • 2021-12-02
    • 1970-01-01
    • 2013-04-06
    • 2021-03-13
    相关资源
    最近更新 更多