English 中文(简体)
当使用绝对财产时,图像宽度为0。
原标题:Image width is 0 when using absolute property paired with relative

I am having some issues displaying images that are absolute. The outer div is relative, and the 2 images are of class absolute.

我正在将特殊产品进口作为图像的rc。

我试图将绝对财产从图像中删除。 这使得形象变得如此。

<div class="flex h-20 w-full">
    <div class="relative mt-1">
        <img class="absolute left-4 top-4 h-12 w-12" src={Polygon} alt="" />
        <img class="absolute left-4 top-2 h-12 w-12" src={Polygon1} alt="" />
    </div>
</div>

Edit:

种子本身和“相对”四的种子也为零。

问题回答

That s because the flex in the parent. Flex gives the children as less space as it need. Since the child (<div class="relative mt-1">) has only absolute elements (<img class="absolute...) Its width is 0.

给子女(<div category=“relative mt-1”>)

<div class="flex h-20 w-full">
    <div class="relative mt-1 w-40">
        <img class="absolute left-4 top-4 h-12 w-12" src="http://ipsum.photos/get/400" alt="" />
    </div>
</div>

Working Demo: https://play.tailwindcss.com/rSCJbZQmuD





相关问题
I can t use TailwindCSS in ViewComponent

Nice to meet you, I m Japanese. I want to apply TailwindCSS in Rails7 View Component, but it doesn t work. I also changed the settings in tailswind/config.js but it doesn t work. The views file has ...

Next JS Taildwind CSS navbar issue with option dropDown

I m using this navbar I created one component with navbar, the I m calling it on my src/app/page.tsx "use client"; import Login from "../app/pages/login/page"; import Dashboard ...

Tailwind background color not working as I expect

I m trying to set a background color for a div in a component, for light and dark themes, but I m not getting the result I expect. On one side, bg-gray-400 and dark:bg-gray-100 are not changing ...

Creating a background for nav sidebat

I d like to create a transparent background to go with my nav sidebar element. I was thinking of layering the div containing the sidebar on top of a div that would act as the transparent background. ...

Tailwindcs 手工艺中黑暗的风度

我需要将黑暗模式纳入我的项目。 I use NextJs v12.1.3, response 18.1.0 and tailwindcs v3.1.2. 我在官方网站上试用了这份指南,但手工挑选对我来说并不可行。 ......

热门标签