gpt4 book ai didi

html - div显示表格行单元格布局结构简单但不起作用

转载 作者:行者123 更新时间:2023-11-28 03:12:19 25 4
gpt4 key购买 nike

编辑:添加了一个演示图像,其中包含我如何需要网站布局设计的示例

我需要一个简单的 3 列布局表,就像演示中的下图一样,但它不起作用。我上传了一张我需要的图片和一个演示结果。这是带有CSS的代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>title</title>
</head>

<body>


<div style="display:table;width:100%;height:100%:min-width:1000px;">

<div style="display:table-row">
<div style="display:table-cell;width:100%;min-width:1000px;height:23px;min-height:23px;"> only 1 TD 100% width only 23 height </div>
</div>

<div style="display:table-row">
<div style="display:table-cell;width:200px;min-width:200px;height:77px;min-height:77px;"> left 200 px width </div>
<div style="display:table-cell;width:100%;min-width:800px;height:77px;min-height:77px;"> middle 100% of screen width </div>
<div style="display:table-cell;width:200px;min-width:200px;height:77px;min-height:77px;"> right 200 px width</div>
</div>

<div style="display:table-row">
<div style="display:table-cell;width:200px;min-width:200px;height:100%;min-height:100%;"> left 200 px width but height 100% </div>
<div style="display:table-cell;width:100%;min-width:800px;height:100%;min-height:100%;"> middle 100% of screen width but height 100% </div>
<div style="display:table-cell;width:200px;min-width:200px;height:100%;min-height:100%;"> right 200 px width but height 100% </div>
</div>


<div style="display:table-row">
<div style="display:table-cell;width:100%;min-width:1000px;height:12px;min-height:12px;"> only 1 TD 100% width only 12px height </div>
</div>

</div>




</body>
</html>

这是一张我需要它看起来像的图片 enter image description here

这里有一个 fiddle 演示 https://jsfiddle.net/yzr3v04u/

如果 CSS 表格是 future 并且可以编辑并放置在我想要的任何地方,为什么不能按我想要的方式工作?

图像演示中我需要的任何其他方法有什么想法吗?

最佳答案

给你。请不要使用表格来构建网站布局,在响应式(移动设备)设计方面这是不好的做法,请改用 CSS。

如果您希望您的列高低于页面底部,可以使用名为 Viewport-Percentage (or Viewport-Relative) Lengths 的新 CSS3 测量单位。

您需要做的就是将 height: 100vh; 添加到您的 CSS .content-wrapper

.header {
width: 100%;
height: 21px;
background-color: orange;
}
.sub-header {
width: 100%;
height: 79px;
background-color: brown;
}
.content-wrapper {
width: 100%;
height: 100vh;
}
.left-column {
display: inline;
float: left;
width: 200px;
height: 100%;
background-color: purple;
}
.middle-column {
display: inline;
float: none;
height: 100%;
background-color: white;
}
.right-column {
display: inline;
float: right;
width: 200px;
height: 100%;
background-color: purple;
}
.footer {
width: 100%;
height: 12px;
background-color: pink;
}
<div class="header"></div>
<div class="sub-header"></div>
<div class="content-wrapper">
<div class="left-column">1</div>
<div class="middle-column">2</div>
<div class="right-column">3</div>
</div>
<div class="footer"></div>

关于html - div显示表格行单元格布局结构简单但不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30057135/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com