【问题标题】:How expand flexbox to padding in tailwind如何在顺风中将 flexbox 扩展为填充
【发布时间】:2022-01-03 17:50:16
【问题描述】:

我如何将那个弹性框放在所有蓝色背景上

我附上一张它的样子:

此处使用 Tailwind-CSS 编写代码:

<!-- Tailwind + Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins">
<link rel=”stylesheet” href=”https://cdn-uicons.flaticon.com/uicons-regular-rounded/css/uicons-regular-rounded.css”>
<script src="https://unpkg.com/feather-icons"></script>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">


<!-- Body -->
<header class="bg-blue-default flex justify-between p-3.5 text-xs m-0">
  <div class="flex justify-between text-white-grayed">
    <a class="pl-4 pr-4 hover:text-white-default border-r border-white-default" href="">info@example.eu</a>
    <a class="hover:text-white-default" href="">+000 000 000 000</a>
  </div>
  <div>

  </div>
</header>

【问题讨论】:

    标签: html css tailwind-css


    【解决方案1】:

    你快到了。您的标头已经是一个 flexbox 并且占据了整个宽度。但是,您的第一个孩子 (div) 只占用所需的空间。您需要添加 w-full 以使 div 占据所有可用宽度,并在整个宽度内对齐其项目。

    <!-- Tailwind + Fonts -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins">
    <link rel=”stylesheet” href=”https://cdn-uicons.flaticon.com/uicons-regular-rounded/css/uicons-regular-rounded.css”>
    <script src="https://unpkg.com/feather-icons"></script>
    <link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
    
    
    <!-- Body -->
    <header class="bg-blue-default flex justify-between p-3.5 text-xs m-0">
      <div class="w-full flex justify-between items-center text-white-grayed">
        <a class="pl-4 pr-4 hover:text-white-default border-r border-white-default" href="">info@example.eu</a>
        <a class="hover:text-white-default" href="">+000 000 000 000</a>
      </div>
    </header>

    【讨论】:

    • 如果我使用了你的代码,这已经发生了,但 flexbox 仍然不在背景 IMG:ctrlv.sk/qMiU
    • 看起来你想center所有项目垂直。这可以通过将.items-center 添加到您的弹性框来完成。编辑了答案。您确实需要对您想要的内容以及正确的示例代码提供更好的解释。很难理解您要达到的目标。
    • 我需要那些横跨蓝色背景的白线和电话在一条线上如何做到这一点 IMG:ctrlv.sk/W8SH
    • 提供完整的代码给它,否则几乎不可能理解你已经尝试过的内容。
    【解决方案2】:

    仅从标题中删除 flex

    使用这个

    <header class="bg-blue-default justify-between p-3.5 text-xs m-0">
    

    而不是

    <header class="bg-blue-default flex justify-between p-3.5 text-xs m-0">
    

    【讨论】:

    • 如果我使用了你的代码,这已经发生了,但 flexbox 仍然不在背景 IMG:ctrlv.sk/IAhw
    猜你喜欢
    • 2021-09-18
    • 2020-01-21
    • 2021-11-21
    • 2020-12-04
    • 2018-06-04
    • 2016-01-21
    • 1970-01-01
    • 2016-03-17
    • 2020-02-04
    相关资源
    最近更新 更多