<div class=""> <div class="w-16 h-16 border-b-30 border-l-30 border-solid border-black"> <div class="h-16 w-16 border-t-30 border-r-30 bg-transparent"></div> </div>
如何在没有插件的情况下用tailwindCss制作三角形??
发布于 2021-04-17 00:19:43
您可以尝试使用transform:
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet"> <div class="w-16 overflow-hidden inline-block"> <div class=" h-11 w-11 bg-black rotate-45 transform origin-bottom-left"></div> <div class="w-16 overflow-hidden inline-block"> <div class=" h-11 w-11 bg-black -rotate-45 transform origin-top-left"></div> <div class="w-11 overflow-hidden inline-block"> <div class=" h-16 bg-black -rotate-45 transform origin-top-right"></div> <div class="w-11 overflow-hidden inline-block"> <div class=" h-16 bg-black rotate-45 transform origin-top-left"></div> <div class="w-11 overflow-hidden inline-block"> <div class=" h-16 bg-black -rotate-45 transform origin-bottom-right"></div> <div class="w-11 overflow-hidden inline-block"> <div class=" h-16 bg-black rotate-45 transform origin-bottom-left"></div> <div class="w-11 overflow-hidden inline-block"> <div class=" h-16 bg-black -rotate-45 transform origin-top-left"></div> <div class="w-11 overflow-hidden inline-block"> <div class=" h-16 bg-black rotate-45 transform origin-top-right"></div> </div>
发布于 2022-04-19 14:57:33
您也可以尝试使用边框。
顺风操场
<!-- down --> <div class="border-solid border-t-black border-t-8 border-x-transparent border-x-8 border-b-0"></div> <!-- up --> <div class="border-solid border-b-black border-b-8 border-x-transparent border-x-8 border-t-0"></div> <!-- left --> <div class="border-solid border-r-black border-r-8 border-y-transparent border-y-8 border-l-0"></div> <!-- right --> <div class="border-solid border-l-black border-l-8 border-y-transparent border-y-8 border-r-0"></div>
发布于 2022-06-10 17:38:54
也许你想用三角形来做工具提示。(这样的搜索让我来到这里):
<div class="group relative mt-4 ml-4 inline-block"> <button type="button" class="rounded-md border border-neutral-600 px-1">...</button> <!-- container for triangle and the menu ↓--> <div class="invisible absolute left-0 -mt-[2px] flex flex-col group-focus-within:visible group-active:visible"> <div class="ml-2 -mb-[1px] inline-block overflow-hidden"> <!-- ← triangle container --> <!-- triangle ↓ --> <div class="h-3 w-3 origin-bottom-left rotate-45 transform border border-neutral-500 bg-neutral-100"></div> <!-- menu ↓ -->