Unexplained right-side margin when page not full screen – Nuxt/Tailwinds

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

Unexplained right-side margin when page not full screen - Nuxt/Tailwinds

问题

我正在尝试创建一个简单的简历页面,使用Nuxt、Vue3和TailwindCSS。当我的浏览器全屏时,一切都看起来很好,而且都很合适。然而,如果我不是全屏,页面的主体部分有一个右侧的边距,原因无法解释。 (请忽略可怕的设计,它仍在进行中)

如下所示,元素的右侧有一个边距,但不应该出现在计算布局中。我没有添加自定义CSS,所以我只使用默认的Tailwind提供的类,据我所知,不应该有右侧的边距。

这是父元素,正如您所看到的,它没有会影响子元素的填充或边距。

英文:

I am trying to make just a simple CV page, using Nuxt, Vue3 and TailwindCSS. When my browser is full-screen, everything looks fine, and it all fits in well. However, if I got anything outside of full-screen, there is a margin for no explicable reason on the right-side of the page in my main body part of the application. (Please overlook the horrible design, it's still in progress)

As displayed below, there is a margin on the right side of the element, but shouldn't be and its not showing in the computed layout even. I have no custom CSS added, so I am only using the default Tailwind-supplied classes, as far as I can tell, there should be no right-side margin. Unexplained right-side margin when page not full screen – Nuxt/Tailwinds

This is the parent element, which as you can see has no padding or margins that would affect the child.
Unexplained right-side margin when page not full screen – Nuxt/Tailwinds

Here is my default.vue, where the "content" elements are inserted (in the <slot /> tag)


<template>
    <div class="container flex p-4 flex-col h-screen overflow-hidden bg-slate-200">
        <div class="pb-2 bg-gradient-to-r from-red-500 via-green-500 to-purple-500">
            <header class="bg-slate-200 pb-2">
                <nav>
                    <ul class="flex justify-end gap-5">
                        <NuxtLink to="skills" class="rounded-lg border-black border-solid border-2
                                p-3">
                            <li>Key Skills & Interests
                            </li>
                        </NuxtLink>
                        <NuxtLink to="education" class="rounded-lg border-black border-solid
                                border-2 p-3">
                            <li>Education</li>
                        </NuxtLink>
                        <NuxtLink to="experience" class="rounded-lg border-black border-solid
                                border-2 p-3">
                            <li>Experience</li>
                        </NuxtLink>
                        <NuxtLink to="about" class="rounded-lg border-black border-solid
                                border-2 p-3">
                            <li>A Little Bit About Me</li>
                        </NuxtLink>
                    </ul>
                </nav>
            </header>
        </div>

        <slot />
    </div>
</template>

答案1

得分: 1

Tailwind中的容器类不会自动应用任何水平填充或自动居中。将mx-auto类(将左边距和右边距都设置为自动)添加到第一个div将解决这个问题。

英文:

Container class in tailwind doesn't apply any horizontal padding or self-center automatically. Adding mx-auto class (which sets margin-left and margin-right to auto) to the first div will solve the problem.

huangapple
  • 本文由 发表于 2023年2月14日 18:45:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75446726.html
匿名

发表评论

匿名网友

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

确定