滚动快照无法正确捕捉

如何解决滚动快照无法正确捕捉

我正在做一个个人项目,我在这个项目中使用了 scroll-snap

但由于某种原因,滚动快照有时会超出或落在页面的两个部分之间的尴尬位置

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@600&display=swap');

:root {
    --bg-color: rgb(33,32,41);
    --header-color: rgb(255,170,55);
    --color-white: white;
    --color-black: black;
}
* {
    Box-sizing: border-Box;
    margin: 0;
    padding: 0;
    
    scroll-behavior: smooth;
}
html{
    scroll-snap-type: y mandatory;
}
html,body {
    font-family: 'Titillium Web',sans-serif;
    background-color: var(--bg-color);
    color: var(--color-white);
    width: 100%;
}
body div {
    scroll-snap-align: start;
}






header {
    background: var(--header-color);
    position: fixed;
    top: 0;
    z-index: 10000;
    width: 100%;
}

header div {
    width: 80%;
    margin: 0 auto;
}
header div::after {
    content: '';
    display: table;
    clear: both;
}

header div img {
    position: absolute;
    float: left;

    margin: 0.6em;
}

nav ul {
    width: auto;
    float: right;

    margin: 2em;
}

nav ul li {
    display: inline-block;
    margin-left: 2em;
    font-family: 'Roboto',sans-serif;
}

nav ul li a {
    font-size: 1.5em;

    color: black;
    text-decoration: none;
    text-transform: uppercase;
}
nav ul li a:hover {
    color: rgb(93,93,93);
}






#about {
    display: flex;
    justify-content: center;
    align-items: center;

    width: clamp(750px,80%,100%);
    height: 100vh;

    margin: 0 auto;

    text-align: center;

    font-size: 1.5em;
}
#about p {
    display: inline;
    color: var(--header-color);
}
#about h1 {
    margin-bottom: 1em;
}





#invite {
    display: flex;
    justify-content: center;
    align-items: center;

    height: 100vh;

    margin: 0 auto;

    text-align: center;

    font-size: 1.5em;

    background-color: var(--header-color);
    color: var(--color-black);
}
#invite div {
    width: clamp(750px,100%);

}
#invite div h1 {
    margin-bottom: 2em;
}
#invite div button {
    width: 6em;
    height: 3em;

    background-color: rgba(0,0);
    color: var(--color-black);

    font-size: 1em;
    font-family: 'Roboto',sans-serif;
    text-transform: uppercase;
    
    border: 1px solid black;

    transition: 0.2s;
}
#invite button:hover {
    margin-top: 0.3em;
}
#invite button a {
    color: var(--color-black);
    text-decoration: none;
}





#contact {
    display: flex;
    justify-content: center;
    align-items: center;

    width: clamp(750px,100%);
    height: 100vh;

    margin: 0 auto;

    text-align: center;

    font-size: 1.5em;
}
#contact div h1 {
    margin-bottom: 1em;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <Meta http-equiv="X-UA-Compatible" content="IE=edge">
    <Meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>FoxoBot</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    
    <header>
        <div>
            <img src="files/logo.png" alt="logo" height="72em"> 

            <nav>
                <ul>
                    <li><a href="#about">About</a></li>
                <!--<li><a href="#showcase">showcase</a></li>-->
                    <li><a href="#invite">Invite</a></li>
                    <li><a href="#contact">contact</a></li>
                </ul>
            </nav>
        </div>
    </header>

    <div id="about">
        <div>
            <h1>About</h1>

            <p><p>FoxoBot</p> is a discord bot developed by Lappland and Ralkey.</p>
            <br>
            <p><p>FoxoBot</p> is a easy to use and a friendly bot for general,fun & administrative commands on discord</p>
            <br>
            <p><p>FoxoBot</p> is always in development and we also learn alot along the way</p>
        </div>
    </div>

<!--<div id="showcase">
    -- i dont have anything for showcase yet --
    </div>-->

    <div id="invite">
        <div>
            <h1>Invite FoxoBot to your server</h1>
            <button><a href="#" target="_blank">Invite!</a></button>
        </div>
    </div>
    
    <div id="contact">
        <div>
            <h1>Contact us</h1>

            <p>you can contact us throught discord.</p>
            <p>our tags are:</p>
            <p>Ralkey: blank</p>
            <p>Lappland: blank</p>
        </div>
    </div>
    
</body>
</html>

(我建议在整页中打开代码段)

经过无数次寻找解决方案后,我放弃并登陆这里

我希望你们中至少有一个能够帮助我

解决方法

您的问题似乎是您将 var limit,offset int marshalledOrders,err := cache.RedisClient.Get(ctx,constants.KOrders+" "+sessionData.UUID).Result() if err != nil { log.Println("redis get err",err) return nil,errors.New(constants.InternalServerError) } filteredOrders := gjson.Get(marshalledOrders,`#(status=="done")#`) var orders []*models.Order unmarshallErr := json.Unmarshal([]byte(filteredOrders.String()),&orders) if unmarshallErr != nil { log.Println("redis unmarshallErr",unmarshallErr) return nil,errors.New(constants.InternalServerError) } 应用于 scroll-snap-align: start; 内的每个 div,因此当您滚动它时,它会捕捉到页面中的每个 div。而您只想将其应用于 body 的第一个子级,或者在您的情况下您页面的每个部分。

所以我在下面的例子中所做的就是在你的 css 中将 body 更改为 body div。 您可以在此处查看有关大于号 css 的更多信息:What does the ">" (greater-than sign) CSS selector mean?

body > div
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@600&display=swap');

:root {
    --bg-color: rgb(33,32,41);
    --header-color: rgb(255,170,55);
    --color-white: white;
    --color-black: black;
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    
    scroll-behavior: smooth;
}
html{
    scroll-snap-type: y mandatory;
}
html,body {
    font-family: 'Titillium Web',sans-serif;
    background-color: var(--bg-color);
    color: var(--color-white);
    width: 100%;
}
body > div {
    scroll-snap-align: start;
}






header {
    background: var(--header-color);
    position: fixed;
    top: 0;
    z-index: 10000;
    width: 100%;
}

header div {
    width: 80%;
    margin: 0 auto;
}
header div::after {
    content: '';
    display: table;
    clear: both;
}

header div img {
    position: absolute;
    float: left;

    margin: 0.6em;
}

nav ul {
    width: auto;
    float: right;

    margin: 2em;
}

nav ul li {
    display: inline-block;
    margin-left: 2em;
    font-family: 'Roboto',sans-serif;
}

nav ul li a {
    font-size: 1.5em;

    color: black;
    text-decoration: none;
    text-transform: uppercase;
}
nav ul li a:hover {
    color: rgb(93,93,93);
}






#about {
    display: flex;
    justify-content: center;
    align-items: center;

    width: clamp(750px,80%,100%);
    height: 100vh;

    margin: 0 auto;

    text-align: center;

    font-size: 1.5em;
}
#about p {
    display: inline;
    color: var(--header-color);
}
#about h1 {
    margin-bottom: 1em;
}





#invite {
    display: flex;
    justify-content: center;
    align-items: center;

    height: 100vh;

    margin: 0 auto;

    text-align: center;

    font-size: 1.5em;

    background-color: var(--header-color);
    color: var(--color-black);
}
#invite div {
    width: clamp(750px,100%);

}
#invite div h1 {
    margin-bottom: 2em;
}
#invite div button {
    width: 6em;
    height: 3em;

    background-color: rgba(0,0);
    color: var(--color-black);

    font-size: 1em;
    font-family: 'Roboto',sans-serif;
    text-transform: uppercase;
    
    border: 1px solid black;

    transition: 0.2s;
}
#invite button:hover {
    margin-top: 0.3em;
}
#invite button a {
    color: var(--color-black);
    text-decoration: none;
}





#contact {
    display: flex;
    justify-content: center;
    align-items: center;

    width: clamp(750px,100%);
    height: 100vh;

    margin: 0 auto;

    text-align: center;

    font-size: 1.5em;
}
#contact div h1 {
    margin-bottom: 1em;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?