网站在窗口调整大小时无法向下滚动?

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

Website wont scroll down when window resizes?

问题

我的网站在窗口调整大小时无法滚动到页面的其他内容。这是我正在使用的CSS。当屏幕较小时,它不会让我滚动以查看更多文本。

:root {
    font-size: 1.2rem;
    font-family: 'Times New Roman', Times, serif;
}
html {
    overflow: scroll;
}
body {
    font-family: Arial, Helvetica, sans-serif;
    flex-direction: row;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: gainsboro;
    display: grid;
    margin: 0px;
    padding: 0px;
    display: flex;
}
.image {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 55vw;
    max-width: 40vw;
    background: url('signup.jpeg') no-repeat;
    background-size: cover;
    background-size: 55vw 100vh;
    background-repeat: no-repeat;
    flex-grow: 3;
}
.container2 {
    margin-top: 10px;
    margin-right: 100px;
    overflow: scroll;
}
<!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>Sign Up Form</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="image">
        <div class="header">
            <h1></h1>
        </div>
    </div>
</body>
</html>
英文:

My website won't scroll down to the other contents of the page when the window resizes. Here is the CSS I am using. It won't let me scroll down to see my text. Ive added my CSS and html code. I'm trying to make this page but as soon as the screen is smaller it wont make me scroll down to see more of my text.

:root {
    font-size: 1.2rem;
    font-family: &#39;Times New Roman&#39;, Times, serif;
}
html {
    overflow: scroll;
    
}
body {
    font-family: Arial, Helvetica, sans-serif;
    flex-direction: row;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: gainsboro;
    display: grid;
    margin: 0px;
    padding: 0px;
    display: flex;
}
.image{
    display: flex;
    justify-content: center;
    align-items: center;
    width: 55vw;
    max-width: 40vw;
    background: url(&quot;signup.jpeg&quot;) no-repeat; 
    background-size: cover;
    background-size: 55vw 100vh;
    background-repeat: no-repeat;
    flex-grow: 3;  
} 
.container2{  
    margin-top: 10px;
    margin-right: 100px;
    overflow: scroll;
}

    &lt;!DOCTYPE html&gt;
    &lt;html lang=&quot;en&quot;&gt;
    &lt;head&gt;
        &lt;meta charset=&quot;UTF-8&quot;&gt;
        &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
        &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
        &lt;title&gt;Sign Up Form&lt;/title&gt;
        &lt;link rel=&quot;stylesheet&quot; href=&quot;styles.css&quot;&gt;
    &lt;/head&gt;

    &lt;body&gt;
    
        &lt;div class=&quot;image&quot;&gt;
            
            &lt;div class=&quot;header&quot;&gt;
                
                &lt;h1&gt;&lt;/h1&gt; 
            
            &lt;/div&gt; 
        &lt;/div&gt;
&lt;/html&gt;

</details>


# 答案1
**得分**: 2

以下是翻译好的部分:

"that overflow:hidden in body is prevent the body from scrolling.. remove that you are good to go." 

中文翻译:
"body 中的 overflow:hidden 阻止了页面的滚动。移除它,你就可以正常滚动了。"

"here is updated code snippet"

中文翻译:
"下面是更新后的代码片段"

请注意,代码部分不需要翻译,只提供翻译好的文本。

<details>
<summary>英文:</summary>

that overflow:hidden in body is prevent the body from scrolling.. remove that you are good to go.

here is updated code snippet

&lt;!-- begin snippet: js hide: false console: true babel: false --&gt;

&lt;!-- language: lang-css --&gt;

    :root {
        font-size: 1.2rem;
        font-family: &#39;Times New Roman&#39;, Times, serif;
    }
    html {
        overflow: scroll;
        
    }
    body {
        font-family: Arial, Helvetica, sans-serif;
        flex-direction: row;
        width: 100vw;
        height: 100vh;
        background-color: gainsboro;
        display: grid;
        margin: 0px;
        padding: 0px;
        display: flex;
    }
    .image{
        display: flex;
        justify-content: center;
        align-items: center;
        width: 55vw;
        max-width: 40vw;
        background: url(&quot;https://marketplace.canva.com/EAD2962NKnQ/2/0/1600w/canva-rainbow-gradient-pink-and-purple-virtual-background-_Tcjok-d9b4.jpg&quot;) no-repeat; 
        background-size: cover;
        background-size: 55vw 100vh;
        background-repeat: no-repeat;
        flex-grow: 3;  
    } 
    .container2{  
        margin-top: 10px;
        margin-right: 100px;
        overflow: scroll;
    }

&lt;!-- language: lang-html --&gt;

        &lt;html lang=&quot;en&quot;&gt;
        &lt;head&gt;
            &lt;meta charset=&quot;UTF-8&quot;&gt;
            &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
            &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
            &lt;title&gt;Sign Up Form&lt;/title&gt;
        &lt;/head&gt;

        &lt;body&gt;
        
            &lt;div class=&quot;image&quot;&gt;
                
                &lt;div class=&quot;header&quot;&gt;
                    
                    &lt;h1&gt;hello&lt;/h1&gt; 
                
                &lt;/div&gt; 
            &lt;/div&gt;
    &lt;/html&gt;

&lt;!-- end snippet --&gt;



</details>



huangapple
  • 本文由 发表于 2023年6月30日 04:39:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76584471.html
匿名

发表评论

匿名网友

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

确定