Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 缩小浏览器窗口时,Div高度增加_Html_Css - Fatal编程技术网

Html 缩小浏览器窗口时,Div高度增加

Html 缩小浏览器窗口时,Div高度增加,html,css,Html,Css,当我将浏览器窗口的大小缩小到屏幕的一半时,主容器div的高度会增加,您必须滚动到页脚 我不想发生这种事。我尝试使用最大高度,但它使div消失 有人能帮我吗?谢谢 HTML代码: <!DOCTYPE html> <html lang="en-US"> <head> <meta charset="UTF-8" /> <link href="css/stylesheet.css" type="text/css

当我将浏览器窗口的大小缩小到屏幕的一半时,主容器div的高度会增加,您必须滚动到页脚

我不想发生这种事。我尝试使用最大高度,但它使div消失

有人能帮我吗?谢谢

HTML代码:

<!DOCTYPE html>
<html lang="en-US">
    <head>
        <meta charset="UTF-8" />
        <link href="css/stylesheet.css" type="text/css" rel="stylesheet" />
        <title>Aduro Pictures</title>
    </head>
    <body>
        <header>
            <div id="logo_home">
                <a href="index.html" title="Home"><img id="logo" src="images/logo.jpg" alt="logo"></a>
            </div>
            <nav>
                <ul>
                    <li><a class="nav_link" id="about" href="about.html" title="About">About</a></li>
                    <li><a class="nav_link" id="short_films" href="short_films.html" title="Short Films">Short Films</a></li>
                    <li><a class="nav_link" id="cast_crew" href="cast_crew.html" title="Cast/Crew">Cast/Crew</a></li>
                    <li><a class="nav_link" id="gallery" href="gallery.html" title="Gallery">Gallery</a></li>
                    <li><a class="nav_link" id="links" href="links.html" title="Links">Links</a></li>
                    <li><a class="nav_link" id="contact_us" href="contact_us.html" title="Contact Us">Contact Us</a></li>
                </ul>
            </nav>
        </header>
        <div id="main_wrapper">
            <div id="video_container">
                <iframe width="560" height="315" src="https://www.youtube.com/embed/EuIXJIp8f6U" frameborder="0" allowfullscreen></iframe>
            </div>
            <div id="image_container">
                <div id="gradient"></div>
            </div>
            <div id="main_container"></div>
        </div>
        <footer>
            <p class="copyright">Copyright &copy; 2016.</p>
        </footer>
    </body>
</html>

谢谢

在css中,高度为920px。我有一种感觉,div的大小没有增加……只是你的窗口变小了,但是你的div仍然是920px,所以你必须向下滚动才能看到整个div区域

如果您希望div区域在窗口中保持完全可见,可以尝试以下方法

而不是将高度固定为920px。去掉那个。使div高度为100%。然后将上边距和下边距设置为一个合理的数字,如3em,以便它舒适地适合窗口区域。如果将左侧和右侧设置为固定尺寸,则可能需要对其执行相同的操作

如果窗口缩小得太小,您可能还希望将div设置为最小高度,这样它就不会看起来很时髦

我不确定这是否是你想要实现的,但我希望这会有所帮助

body {
    margin: 0px;
    font-size: 62.5%;
    padding: 0px;
    }

header {
    width: 100%;
    height: 90px;
    background-color: #000000;
    }

#logo_home {
    position: relative;
    float: left;
    left: 5%;
    width: 20%;
    top: 7.5px;
    }

#logo {
    height: 75px;
    width: 300px;
    }

nav {
    position: relative;
    float: right;
    right: 5%;
    width: 35%;
    height: 50px;
    top: 20px;
    }

ul {
    margin-top: 0px;
    margin-bottom: 0px;
    position: relative;
    top: 17.5px;
    }

li {
    display: inline-block;
    margin-left: 2.5%;
    margin-right: 2.5%;
    position: relative;
    list-style-type: none;
    padding-top: 0px;
    }

.nav_link {
    font-family: 'PT-Sans', sans-serif;
    color: #FFFFFF;
    font-size: 1.2em;
    text-transform: uppercase;
    text-decoration: none;
    }

.nav_link:link {
    color: #ffffff;
    }

.nav_link:visited {
    color: #ffffff;
    }

.nav_link:hover {
    color: #dddddd;
    }

#main_wrapper {
    height: 1500px;
    width: 100%;
}

#video_container {
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 30px; 
    height: 0; 
    overflow: hidden;
    z-index: 5;

}

#video_container iframe, #video_container object, #video_container embed {
    position: absolute;
    top: 100px;
    left: 17.5%;
    width: 65%;
    height: 65%;
    box-sizing: border-box;
}

#image_container {
    position: absolute; 
    top: 90px; 
    left: 0px; 
    width: 100%; 
    height: 580px; /*pic ain't 580px in height*/
    background: url('../images/background5.jpg') no-repeat;
}

#gradient {
    position: absolute; 
    top: 0px; 
    left: 0px; 
    width: 100%; 
    height: 580px;
    background: transparent linear-gradient(to bottom, rgba(29, 29, 29, 0.65) 0px, #1D1D1D 100%) repeat scroll 0% 0%; 
}

#main_container {
    background-color: #1d1d1d;
    background-repeat: no-repeat;
    height: 920px;
    position: absolute;
    width: 100%;
    top: 670px;

}

footer {
    background-color: #000000;
    height: 50px;
    width: 100%;
    margin: 0px;
    top: 0px;
    position: relative;

    }

.copyright {
    color: white;
    font-family: 'PT-Sans', sans-serif;
    font-size: 1.2em;
    position: relative;
    text-align: center;
    top: 15px;
    margin: 0px;
    padding: 0px;
    }