如何在Tailwind CSS中创建曲线或弯曲线的线条?

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

How to create the curve/ or a bend in a line with tailwindCss

问题

如何使用Tailwind CSS类创建线条弯曲,如您所看到的图片中,在绿色圆点下方有一条线?明确不使用CSS样式表?还是创建一个SVG并简单地使用它更好?

这是我的当前代码,任何支持将非常有帮助。

<div className="flex items-center justify-between gap-x-6 py-2.5 px-2.5 sm:pr-3.5 lg:pl-3 hover:bg-gray-100 border-l-4 hover:border-green-400 cursor-pointer rounded-sm">
  <a href="#">
    {/* <strong className="font-semibold"> hhh</strong> */}
    <div className="flex justify-between gap-x-3">
      {/* circle */}
      <div className="flex h-5 w-5 rounded-full bg-green-200 items-center justify-center">
        <svg
          viewBox="0 0 2 2"
          className="inline h-2 w-2 fill-current rounded-full text-green-500"
          aria-hidden="true"
        >
          <circle cx={1} cy={1} r={3} />
        </svg>
      </div>
      <p className="text-black text-md font-medium items-center justify-center">
        mdsvx in sveltekit&nbsp;
      </p>
    </div>

    {/* <span aria-hidden="true">&rarr;</span> */}
  </a>

  <div className="-m-3 flex gap-3 p-3 focus-visible:outline-offset-[-4px]">
    <div className="flex-none leading-none tracking-normal text-sm font-normal text-gray-600 border border-gray-400 bg-transparent px-3 py-2 rounded-full">
      #mdsvx
    </div>
    <div className="flex-none leading-none text-sm tracking-normal font-normal text-gray-600 border border-gray-400 bg-transparent px-3 py-2 rounded-full">
      #svelte-kit
    </div>
    {/* <XMarkIcon className="h-5 w-5 text-black" aria-hidden="true" /> */}
  </div>
</div>

希望这对您有所帮助。

英文:

How could I create the bend in a line with Tailwind CSS classes, as you can see I the picture there's a line under the green circle/dot. explicitly not using CSS stylesheet? or is it better to create an svg and simply use it?

如何在Tailwind CSS中创建曲线或弯曲线的线条?

This is my current code now, Any support would be really helpful.

 &lt;div className=&quot;flex items-center justify-between gap-x-6 py-2.5 px-2.5 sm:pr-3.5 lg:pl-3 hover:bg-gray-100 border-l-4 hover:border-green-400 cursor-pointer rounded-sm&quot;&gt;
      &lt;a href=&quot;#&quot;&gt;
        {/* &lt;strong className=&quot;font-semibold&quot;&gt; hhh&lt;/strong&gt; */}
        &lt;div className=&quot;flex justify-between gap-x-3&quot;&gt;
          {/* circle */}
          &lt;div className=&quot;flex h-5 w-5 rounded-full bg-green-200 items-center justify-center&quot;&gt;
            &lt;svg
              viewBox=&quot;0 0 2 2&quot;
              className=&quot;inline h-2 w-2 fill-current rounded-full text-green-500&quot;
              aria-hidden=&quot;true&quot;
            &gt;
              &lt;circle cx={1} cy={1} r={3} /&gt;
            &lt;/svg&gt;
          &lt;/div&gt;
          &lt;p className=&quot;text-black text-md font-medium items-center justify-center&quot;&gt;
            mdsvx in sveltekit&amp;nbsp;
          &lt;/p&gt;
        &lt;/div&gt;

        {/* &lt;span aria-hidden=&quot;true&quot;&gt;&amp;rarr;&lt;/span&gt; */}
      &lt;/a&gt;

      &lt;div className=&quot;-m-3 flex gap-3 p-3 focus-visible:outline-offset-[-4px]&quot;&gt;
        &lt;div className=&quot;flex-none leading-none tracking-normal text-sm font-normal text-gray-600 border border-gray-400 bg-transparent px-3 py-2 rounded-full&quot;&gt;
          #mdsvx
        &lt;/div&gt;
        &lt;div className=&quot;flex-none leading-none text-sm tracking-normal font-normal text-gray-600 border border-gray-400 bg-transparent px-3 py-2 rounded-full&quot;&gt;
          #svelte-kit
        &lt;/div&gt;
        {/* &lt;XMarkIcon className=&quot;h-5 w-5 text-black&quot; aria-hidden=&quot;true&quot; /&gt; */}
      &lt;/div&gt;
    &lt;/div&gt;



</details>


# 答案1
**得分**: 3

如何使用一个带有左边框和底部边框的 div,并将底部左角设置为圆角?

在 tailwind 中,类似于以下内容:https://play.tailwindcss.com/W8XLs2pqB1。

```html
<div class="h-7 w-4 rounded-bl-lg border-l-2 border-b-2"></div>

将所有内容放在一起,可能会看起来像这样:https://play.tailwindcss.com/cD7U8CZwZJ。

<div class="p-4">
  <div>
    <div class="flex items-center gap-2">
      <div class="h-5 w-5 rounded-full bg-gray-200"></div>
      <div class="text-sm">mdsvx in svelte kit</div>
    </div>
    <!-- 这是带有弧线的元素。调整高度以调整标题之间的间距。 -->
    <div class="-mb-3 ml-2.5 mt-1.5 h-7 w-4 rounded-bl-lg border-l-2 border-b-2"></div>
  </div>
  <ul class="ml-8 space-y-2">
    <li class="flex items-center gap-2">
      <div class="h-5 w-5 rounded bg-gray-200"></div>
      <span class="text-sm">Item</span>
    </li>
    <li class="flex items-center gap-2">
      <div class="h-5 w-5 rounded bg-gray-200"></div>
      <span class="text-sm">Item</span>
    </li>
    <li class="flex items-center gap-2">
      <div class="h-5 w-5 rounded bg-gray-200"></div>
      <span class="text-sm">Item</span>
    </li>
  </ul>
</div>
英文:

How about using a div with a border left and bottom and applying a border radius to the bottom left corner?

In tailwind, something like this https://play.tailwindcss.com/W8XLs2pqB1.

&lt;div class=&quot;h-7 w-4 rounded-bl-lg border-l-2 border-b-2&quot;&gt;&lt;/div&gt;

Putting everything together, it could look like this https://play.tailwindcss.com/cD7U8CZwZJ.

&lt;div class=&quot;p-4&quot;&gt;
  &lt;div&gt;
    &lt;div class=&quot;flex items-center gap-2&quot;&gt;
      &lt;div class=&quot;h-5 w-5 rounded-full bg-gray-200&quot;&gt;&lt;/div&gt;
      &lt;div class=&quot;text-sm&quot;&gt;mdsvx in svelte kit&lt;/div&gt;
    &lt;/div&gt;
    &lt;!-- This is the element with a curved line. Adjust the height to adjust space between title. --&gt;
    &lt;div class=&quot;-mb-3 ml-2.5 mt-1.5 h-7 w-4 rounded-bl-lg border-l-2 border-b-2&quot;&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;ul class=&quot;ml-8 space-y-2&quot;&gt;
    &lt;li class=&quot;flex items-center gap-2&quot;&gt;
      &lt;div class=&quot;h-5 w-5 rounded bg-gray-200&quot;&gt;&lt;/div&gt;
      &lt;span class=&quot;text-sm&quot;&gt;Item&lt;/span&gt;
    &lt;/li&gt;
    &lt;li class=&quot;flex items-center gap-2&quot;&gt;
      &lt;div class=&quot;h-5 w-5 rounded bg-gray-200&quot;&gt;&lt;/div&gt;
      &lt;span class=&quot;text-sm&quot;&gt;Item&lt;/span&gt;
    &lt;/li&gt;
    &lt;li class=&quot;flex items-center gap-2&quot;&gt;
      &lt;div class=&quot;h-5 w-5 rounded bg-gray-200&quot;&gt;&lt;/div&gt;
      &lt;span class=&quot;text-sm&quot;&gt;Item&lt;/span&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;

huangapple
  • 本文由 发表于 2023年2月27日 15:17:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/75577646.html
匿名

发表评论

匿名网友

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

确定