如何在弹性列中添加一个元素,而不会影响其他项目的位置?

发布于 2025-01-22 04:43:05 字数 1909 浏览 1 评论 0原文

我不会添加p喜欢 this 。 我可以添加它,但是当我使用保证 - 将其放下时,它会影响上述元素,例如 。 我不知道该如何解决。 谢谢。

html。

<main>
        <section class="home">
            <div class="presentation">
                <p class="hello">HELLO THERE</p>
                <p>I'm Lautaro Rojas</p>
                <p>Web developer</p>
                <p class="scroll">SCROLL DOWN</p>
            </div>
            <div class="presentation-buttons">
                <button>LATEST PROJECTS</button>
                <button>MORE ABOUT ME</button>
            </div>
        </section>
    </main>

CSS:

main {
    width: 100%;
    height: 100%;

    .home {
        width: 100%;
        height: 100%;
        background-image: url("../img/bg.jpg");
        background-size: cover;
        display: flex;
        align-items: center;

        .presentation {
            width: 70%;
            height: 100%;
            display: flex;
            flex-flow: column;
            justify-content: center;
            align-items: center;
            gap: 5px;

            p {
                width: 50%;
                margin: 0;
                text-align: left;
                color: $WHITE;
                font-family: Merriweather-Regular;
                font-size: 70px;
                letter-spacing: 2px;
            }

            p[class="hello"] {
                font-size: 30px;
                color: $PINK;
            }

            p[class="scroll"] {
                margin-top:180px;
                font-size: 10px;
            }
        }
    }
}

I wan't to add a p like this.
I can add it, but when I use margin-top to put it down, it affects the elements above like this.
I don't know how to solve this.
Thank you.

HTML.

<main>
        <section class="home">
            <div class="presentation">
                <p class="hello">HELLO THERE</p>
                <p>I'm Lautaro Rojas</p>
                <p>Web developer</p>
                <p class="scroll">SCROLL DOWN</p>
            </div>
            <div class="presentation-buttons">
                <button>LATEST PROJECTS</button>
                <button>MORE ABOUT ME</button>
            </div>
        </section>
    </main>

CSS:

main {
    width: 100%;
    height: 100%;

    .home {
        width: 100%;
        height: 100%;
        background-image: url("../img/bg.jpg");
        background-size: cover;
        display: flex;
        align-items: center;

        .presentation {
            width: 70%;
            height: 100%;
            display: flex;
            flex-flow: column;
            justify-content: center;
            align-items: center;
            gap: 5px;

            p {
                width: 50%;
                margin: 0;
                text-align: left;
                color: $WHITE;
                font-family: Merriweather-Regular;
                font-size: 70px;
                letter-spacing: 2px;
            }

            p[class="hello"] {
                font-size: 30px;
                color: $PINK;
            }

            p[class="scroll"] {
                margin-top:180px;
                font-size: 10px;
            }
        }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回忆凄美了谁 2025-01-29 04:43:05

位置:绝对;是您的朋友...

<main>
        <section class="home">
            <div class="presentation">
                <p class="hello">HELLO THERE</p>
                <p>I'm Lautaro Rojas</p>
                <p>Web developer</p>
                <p class="scroll">SCROLL DOWN</p>
            </div>
            <div class="presentation-buttons">
                <button>LATEST PROJECTS</button>
                <button>MORE ABOUT ME</button>
            </div>
        </section>
    </main>

main {
    width: 100%;
    height: 100%;

    .home {
        width: 100%;
        height: 100%;
        background-image: url("../img/bg.jpg");
        background-size: cover;
        display: flex;
        align-items: center;

        .presentation {
            width: 70%;
            height: 100%;
            display: flex;
            flex-flow: column;
            justify-content: center;
            align-items: center;
            gap: 5px;
            position: relative;
            p {
                width: 50%;
                margin: 0;
                text-align: left;
                color: $WHITE;
                font-family: Merriweather-Regular;
                font-size: 70px;
                letter-spacing: 2px;
            }

            p[class="hello"] {
                font-size: 30px;
                color: $PINK;
            }

            p[class="scroll"] {
                margin-top:180px;
                font-size: 10px;
                position: absolute;
            }
        }
    }
}

position: absolute; is your friend...

<main>
        <section class="home">
            <div class="presentation">
                <p class="hello">HELLO THERE</p>
                <p>I'm Lautaro Rojas</p>
                <p>Web developer</p>
                <p class="scroll">SCROLL DOWN</p>
            </div>
            <div class="presentation-buttons">
                <button>LATEST PROJECTS</button>
                <button>MORE ABOUT ME</button>
            </div>
        </section>
    </main>

main {
    width: 100%;
    height: 100%;

    .home {
        width: 100%;
        height: 100%;
        background-image: url("../img/bg.jpg");
        background-size: cover;
        display: flex;
        align-items: center;

        .presentation {
            width: 70%;
            height: 100%;
            display: flex;
            flex-flow: column;
            justify-content: center;
            align-items: center;
            gap: 5px;
            position: relative;
            p {
                width: 50%;
                margin: 0;
                text-align: left;
                color: $WHITE;
                font-family: Merriweather-Regular;
                font-size: 70px;
                letter-spacing: 2px;
            }

            p[class="hello"] {
                font-size: 30px;
                color: $PINK;
            }

            p[class="scroll"] {
                margin-top:180px;
                font-size: 10px;
                position: absolute;
            }
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文