You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

页面fotter内表格容器未显示,是否缺少CSS属性?

问题:Footer内的表格容器无法显示?原因及修复方案

让我帮你排查一下这个问题,你的代码里有几个关键错误,导致footer里的表格容器无法正常显示:

1. CSS选择器和HTML类名不匹配

你HTML里的图片容器用的类是image-div,但CSS里写的样式选择器却是.image-title——这就相当于给一个叫“张三”的人发了写给“李四”的指令,样式根本不会生效,表格单元格自然看不到。得把CSS里的.image-title改成.image-div才行。

2. Flex布局和Table布局冲突

你给#fotter设置了display: flex,但里面的#table-div用的是表格布局(display: table)。Flex容器的子元素默认会按照flex规则渲染,这会打乱表格的正常布局逻辑,直接导致表格没法正确显示。建议去掉#fotter的display: flex属性。

3. 图片路径有语法错误

#third的背景图片路径写成了url(third.jpg.),多了个末尾的点——浏览器会把这个当成无效路径,图片加载不出来,就算其他问题都修复了,这个单元格还是空的。

4. 表格单元格宽度设置不合理

你给#first设置了width: 100%,在表格布局里,这个单元格会直接撑满整个表格宽度,剩下三个单元格根本没地方显示,直接被挤没了。应该给四个单元格各设width: 25%,刚好填满整个表格宽度。

修复后的完整代码

修正后的CSS

* { padding: 0; margin: 0; }
body, html { height: 100%; }
/* 保留你其他无关的CSS代码 */
#fotter { 
  height: 30%; 
  background-image: url(bottom.jpg); 
  background-size: cover; 
  opacity: 0.6; 
  /* 去掉display:flex,避免和表格布局冲突 */
}
#fotter-title { 
  position: absolute; 
  bottom: 22%; 
  left: 45%; 
  font-size: 250%;
  /* 加个z-index确保标题在图片上方显示 */
  z-index: 1;
}
#table-div { 
  display: table; 
  width: 100%;  /* 让表格占满footer的宽度 */
  height: 100%; 
}
#row-div { display: table-row; height: 100%; }
/* 修正选择器为.image-div */
.image-div { 
  display: table-cell; 
  background-size: cover; 
  background-repeat: no-repeat; 
  width: 25%; /* 四个单元格各占25%,总和刚好100% */
  height: 100%; /* 让单元格占满行的高度 */
}
#first { background-image: url(first.jpg); }
#second { background-image: url(second.jpg); }
#third { background-image: url(third.jpg); /* 去掉末尾多余的点 */ }
#forth { background-image: url(forth.jpg); }

修正后的HTML

<div id="heading"></div>
<h1 id="heading-title">Hi, my name is Imanuel Sinwany</h1>
<div id="body-div">
  <div id="left-div">
    <div id="body-text">
      <p>...............</p>
      <p>...............</p>
    </div>
  </div>
  <div id="right-div"></div>
</div>
<div id="fotter">
  <div id="table-div">
    <div id="row-div">
      <div id="first" class="image-div"></div>
      <div id="second" class="image-div"></div>
      <div id="third" class="image-div"></div>
      <div id="forth" class="image-div"></div>
    </div>
  </div>
</div>
<h1 id="fotter-title">My Gallery</h1>

最后补充个小提示:如果你的页面还是看不到footer,检查一下body或html有没有设置overflow: hidden,这可能会把footer截断哦。

内容的提问来源于stack exchange,提问作者Hodiya Eyal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 14:17:28