Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.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 页脚位于窗口底部,而不是页面。我做错了什么?_Html_Css - Fatal编程技术网

Html 页脚位于窗口底部,而不是页面。我做错了什么?

Html 页脚位于窗口底部,而不是页面。我做错了什么?,html,css,Html,Css,我查过类似的问题,没有一个决议适合我的问题。 我有一个浮动,它可以推过页面,当我加载页脚时,它将位于网页最初结束的底部,然后向下滚动。 救命啊 更新: 我已经把灯拆了 位置:固定 ,并尝试了其他一些事情。 我尝试的其他任何东西最终都会坐在窗口底部的页脚上,并且能够简单地滚动过去。 还有其他建议或代码编辑可以尝试吗 此外,我还对“不使用负边距”感到好奇,因为这是我用来构建它的大部分内容。我怎样才能在不完全抛弃我所拥有的东西的情况下,用其他东西来重组它?谢谢 html: 抱歉,代码的组织肯定会更好。

我查过类似的问题,没有一个决议适合我的问题。 我有一个浮动,它可以推过页面,当我加载页脚时,它将位于网页最初结束的底部,然后向下滚动。 救命啊

更新: 我已经把灯拆了

位置:固定

,并尝试了其他一些事情。 我尝试的其他任何东西最终都会坐在窗口底部的页脚上,并且能够简单地滚动过去。 还有其他建议或代码编辑可以尝试吗

此外,我还对“不使用负边距”感到好奇,因为这是我用来构建它的大部分内容。我怎样才能在不完全抛弃我所拥有的东西的情况下,用其他东西来重组它?谢谢

html:


抱歉,代码的组织肯定会更好。我还在学习

只需删除
位置:绝对来自页脚的CSS规则,这将把它放入常规文档流中

您还可以删除位置设置
底部
左侧
,然后-如果没有相对、绝对或固定位置,则这些设置没有意义


最后,如果您没有完全意识到负
边距设置会产生什么影响,请不要使用负
边距设置。(也就是说,移动它们的元素,可能与其他元素重叠。

我很震惊,你的问题在类视图1上,在css上,你有

.view1{
利润上限:-600px

}

正如Johannes所指出的,这是你的
位置:绝对
,有两种方法可以克服它,要么完全删除它(Johannes指出),要么添加
位置:相对
对于父项,
页脚
也未正确关闭

还有一些提示,请始终尝试确保父元素包含子元素,并且可以使用
位置
浮动
(如果使用浮动,则也可以将
溢出:隐藏
浮动
)添加到父元素,而不是使用边距)

这里是帮助您的链接


具有绝对位置的元素相对于具有相对位置的第一个父元素进行定位。因此,如果子元素具有绝对位置、父位置静态和祖父母位置相对,则子元素将相对于祖父母进行定位。在您的情况下,如果body元素具有相对位置,则footer(带position absolute)将自身定位在body元素的底部。

在选择器的页脚中,您只需将位置从绝对更改为相对。如下所示:

#footer {
            position: relative;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30px;
            background-color: #333;
        clear: both;
        }

div
元素在
footer
中未正确关闭该类与footer无关,也不是问题所在。Side not,
position:center;
无效现在它位于页面的中心(因为窗口底部将其定位在那里),我向下滚动过去。不幸的是,删除该位置没有帮助
<head>
<meta charset="utf-8" />
<link href = "../Design/Designwork.css" type="text/css" rel="Stylesheet">
<title>Interactive Site</title>

</head>
    <body>

        <header>
            <div id="navbar">
                    <ul>
                        <li><a href="#">Forum</a></li>
                        <li><a href="#">Videos</a></li>
                        <li><a href="#">Products</a></li>
                        <li><a href="#">More</a></li>
                    </ul>
            </div>
            <div id="textlogo">
                <h2><a type="logo" href="#">Gamers Forum</a></h2>
            </div>
        </header>
        <div class="square">Hi, I'm your console</div>
        <div class="square2"></div>

        <div class="view1"></div>
    </div>
        <footer>
        <div id="footer">

        </footer>
        </div>
    </body>
</html>
        header {
background-color: hsl(0, 67%, 37%);
padding: 10px 40px;
width: 90%;
margin: auto;
background-position: fixed;

    }

    #navbar {
display: inline;
        font-family: webfont, sans-serif;
word-spacing: 45px;
    }

    li {
    display: inline-block;}

    a {
        color: white;
        text-decoration: none;
        font-size: 40px;
        letter-spacing: 2px;
        color: white; 
        font-weight: 200px;
    }
        #navbar, li, a {
            text-indent: 60px;
        text-align: right;}


        h2 {
        font-family: futurblock, sans-serif !important;
        font-size: 30px !important;
        letter-spacing: 0em !important;
        margin-top: -65px;
        color: white;
        font-weight: 250px;
        }

        body {
        background-color: #336666;
        margin: 0 auto;}

    a #logo {
    color: black !important;}

    a:hover {
        color: black;
    font-style: italic;}

    a:active {
        color: yellow;
    font-style: none;}

    .center {
    margin: 0 auto;}

    .square {
        width: 65%;
    background-color: #993333;
    margin: 0 auto;
    position: center;
    margin-top: 75px;
    margin-right: 250px;
    padding-bottom: 45%;
    box-shadow: 0 0 15px #000;}



        .square2 {
            width: 40%;
            padding-bottom: 40%;
            background-color: #333;
            position: center;
            margin-top: -820px;
            margin-left: 650px;
            box-shadow: 0 0 10px #000;
        }



        .square {
            font-family: ivyjournal, sans-serif;
            font-size: 50px;
            font-weight: 5em;
            text-indent: 350px;
            vertical-align: text-bottom;
            color: #333;
            text-shadow: 1px 1px #000;

        }

        .view1 {
            width: 450px;
            padding-bottom: 10%;
            background-color: #fff;
            position: center;
            margin: 0 auto;
            margin-top: -600px;
            margin-right: 650px;
            height: 200px;
            box-shadow: 0 0 5px #000;


        }

            #footer {
                position: absolute;
                bottom: 0;
                left: 0;
                width: 100%;
                height: 30px;
                background-color: #333;
            clear: both;

            }
#footer {
            position: relative;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30px;
            background-color: #333;
        clear: both;
        }