css - div 的 HTML-CSS 位置问题

标签 css html

我遇到了一个小问题,我测试的任何东西似乎都不起作用。

我的 HTML:

<div id="parent">
    <div id="top_parent">Top_background
        <div id="top">Top_Picture</div></div>
    <div id="content">Here comes random stuff<div>
        </div>

        <div id="bottom">Footer</div>

CSS:

#top_parent {
    background:#f00;
    height:100px;
}

#top{
    background:#0f0;
    float:right;
    position:relative;   
    height:100px;
    width:50%;
}
#content{
    top:-50px;
    background:#00f;
    <!--   position:relative;-->
    height:100px;
    width:80%;
    margin:auto;
}
#parent{
    background:#000;
    height:350px;
    width:100%; 
}

#bottom {
    height: 50px;
    background:#ff0;
    bottom:0px;
    <!--position:absolute; -->
    <!--position:relative; -->
}

现在我的问题是,页脚不会在 parent div 下,它停留在内容区域中。我做错了什么?

jsF 链接:my source

感谢您的帮助。

最佳答案

你还没有关闭这个div:

<div id="content">Here comes random stuff<div>

应该是:

<div id="content">Here comes random stuff</div>

如果你缩进你的 div,你可以很容易地看到:

<div id="parent">
  <div id="top_parent">Top_background
    <div id="top">Top_Picture</div>
  </div>
  <div id="content">Here comes random stuff<div> <!-- Can see the problem -->
</div>
<div id="bottom">Footer</div>

关于css - div 的 HTML-CSS 位置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3424175/

相关文章:

html - 如何修复移动的背景图像不会出现故障?

javascript - 清除 $destroy 上的指令作用域变量

javascript - 单击选项卡时,卡片选项卡与文本不对应?

javascript - jQuery DatePicker 不显示

html - 动态表格上的交替颜色

html - 100% 高度,居中的人造列,右列有粘性页脚

javascript - 突出显示图像 map 上的区域

jquery - FullCalendar 标题按钮垂直

iPhone 显示屏宽度

css - 如何使用 vuetify2 使所有 v-card 等高