【问题标题】:Trouble converting TailwindCSS to Pug无法将 TailwindCSS 转换为 Pug
【发布时间】:2022-02-18 07:19:11
【问题描述】:

我正在尝试将 TailwindUI 模板转换为 Pug。模板的一部分(“推荐部分”)使用lg:h-fulllg:w-full 来定义图像的高度和宽度。此代码的 HTML 版本运行良好,包含在下面。然而,我的 Pug 转换将图像显示在一个巨大的高度(1401 像素)而不是模板。该模板以 464 的高度渲染图像。我已经尝试修复这个问题好几个星期了,这让我发疯了。

这是 HTML 中按预期工作的顺风 CSS:

<div class="pb-16 bg-gradient-to-r from-teal-500 to-cyan-600 lg:pb-0 lg:z-10 lg:relative">
    <div class="lg:mx-auto lg:max-w-7xl lg:px-8 lg:grid lg:grid-cols-3 lg:gap-8">
      <div class="relative lg:-my-8">
        <div aria-hidden="true" class="absolute inset-x-0 top-0 h-1/2 bg-white lg:hidden"></div>
        <div class="mx-auto max-w-md px-4 sm:max-w-3xl sm:px-6 lg:p-0 lg:h-full">
          <div class="aspect-w-10 aspect-h-6 rounded-xl shadow-xl overflow-hidden sm:aspect-w-16 sm:aspect-h-7 lg:aspect-none lg:h-full">
            <img class="object-cover lg:h-full lg:w-full" src="https://images.unsplash.com/photo-1520333789090-1afc82db536a?ixlib=rb-1.2.1&ixqx=LQMNMymkwX&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2102&q=80" alt="">
          </div>
        </div>
      </div>
      <div class="mt-12 lg:m-0 lg:col-span-2 lg:pl-8">
        <div class="mx-auto max-w-md px-4 sm:max-w-2xl sm:px-6 lg:px-0 lg:py-20 lg:max-w-none">
          <blockquote>
            <div>
              <svg class="h-12 w-12 text-white opacity-25" fill="currentColor" viewBox="0 0 32 32" aria-hidden="true">
                <path d="M9.352 4C4.456 7.456 1 13.12 1 19.36c0 5.088 3.072 8.064 6.624 8.064 3.36 0 5.856-2.688 5.856-5.856 0-3.168-2.208-5.472-5.088-5.472-.576 0-1.344.096-1.536.192.48-3.264 3.552-7.104 6.624-9.024L9.352 4zm16.512 0c-4.8 3.456-8.256 9.12-8.256 15.36 0 5.088 3.072 8.064 6.624 8.064 3.264 0 5.856-2.688 5.856-5.856 0-3.168-2.304-5.472-5.184-5.472-.576 0-1.248.096-1.44.192.48-3.264 3.456-7.104 6.528-9.024L25.864 4z" />
              </svg>
              <p class="mt-6 text-2xl font-medium text-white">
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed urna nulla vitae laoreet augue. Amet feugiat est integer dolor auctor adipiscing nunc urna, sit.
              </p>
            </div>
            <footer class="mt-6">
              <p class="text-base font-medium text-white">Judith Black</p>
              <p class="text-base font-medium text-cyan-100">CEO at PureInsights</p>
            </footer>
          </blockquote>
        </div>
      </div>
    </div>
  </div>

这是图像高度搞砸的 Pug 转换:

// Testimonial section
.pb-16.bg-gradient-to-r.from-teal-500.to-cyan-600(class='lg:pb-0 lg:z-10 lg:relative')
  div(class='lg:mx-auto lg:max-w-7xl lg:px-8 lg:grid lg:grid-cols-3 lg:gap-8')
    .relative(class='lg:-my-8')
      .absolute.inset-x-0.top-0.bg-white(aria-hidden='true' class='h-1/2 lg:hidden')
      .mx-auto.max-w-md.px-4(class='sm:max-w-3xl sm:px-6 lg:p-0 lg:h-full')
        .aspect-w-10.aspect-h-6.rounded-xl.shadow-xl.overflow-hidden(class='sm:aspect-w-16 sm:aspect-h-7 lg:aspect-none lg:h-full')
          img.object-cover(class='lg:h-full lg:w-full' src='https://images.unsplash.com/photo-1520333789090-1afc82db536a?ixlib=rb-1.2.1&ixqx=LQMNMymkwX&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2102&q=80' alt='')
    .mt-12(class='lg:m-0 lg:col-span-2 lg:pl-8')
      .mx-auto.max-w-md.px-4(class='sm:max-w-2xl sm:px-6 lg:px-0 lg:py-20 lg:max-w-none')
        blockquote
          div
            svg.h-12.w-12.text-white.opacity-25(fill='currentColor' viewbox='0 0 32 32' aria-hidden='true')
              path(d='M9.352 4C4.456 7.456 1 13.12 1 19.36c0 5.088 3.072 8.064 6.624 8.064 3.36 0 5.856-2.688 5.856-5.856 0-3.168-2.208-5.472-5.088-5.472-.576 0-1.344.096-1.536.192.48-3.264 3.552-7.104 6.624-9.024L9.352 4zm16.512 0c-4.8 3.456-8.256 9.12-8.256 15.36 0 5.088 3.072 8.064 6.624 8.064 3.264 0 5.856-2.688 5.856-5.856 0-3.168-2.304-5.472-5.184-5.472-.576 0-1.248.096-1.44.192.48-3.264 3.456-7.104 6.528-9.024L25.864 4z')
            p.mt-6.text-2xl.font-medium.text-white
              | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed urna nulla vitae laoreet augue. Amet feugiat est integer dolor auctor adipiscing nunc urna, sit.
          footer.mt-6
            p.text-base.font-medium.text-white Judith Black
            p.text-base.font-medium.text-cyan-100 CEO at PureInsights

如果有人能告诉我为什么图像高度变大,我将不胜感激。

【问题讨论】:

    标签: pug tailwind-css


    【解决方案1】:

    viewBox 区分大小写。通常它不会被自动转换器正确转换,尽管 html2pug VSCode 扩展前段时间已修复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-29
      • 2015-09-04
      相关资源
      最近更新 更多