gpt4 book ai didi

html - Css3 列水平溢出

转载 作者:太空宇宙 更新时间:2023-11-03 18:09:31 26 4
gpt4 key购买 nike

我在尝试通过仅使用 HTML5/CSS3(不需要 JavaScript)获得所需的页面布局时遇到问题。

基本概念是...

  1. 带有页眉和正文的页面(静态)。
  2. 正文有几个“部分”,每个部分都有标题和正文(静态)。
  3. 这些部分从左到右流动(如果它们溢出,您水平滚动页面主体以查看这些部分)。
  4. 这些部分具有流动的高度和宽度(高度根据页面主体的大小调整,宽度根据内容调整或最小 300 像素)。
  5. 部分正文中的字段从上到下排列。当出现溢出时,溢出的字段应该移动到一个新的列并且部分主体应该动态扩展。如果它们溢出到新列,则不应分开(标签和输入应一起移动)。

注意:我目前正在 IE11 中进行测试,但最终该解决方案应该可以在最新的 Chrome/FF/IE/Safari 版本中运行。

当字段溢出到新列时,我似乎无法展开部分主体,同时仍保留列行为。

HTML:

<div class="container">
<div class="header">Header</div>
<div class="body">
<div class="section">
<div class="sectionheader">Section 1</div>
<div class="sectionbody">
<div class="field">
<label>Field 1</label>
<input type="text" />
</div>
<!-- NOTE: repeat field element to create 5 or more fields... -->
</div>
</div>
<!-- NOTE: repeat section element to create more sections... -->
</div>
</div>

CSS:

* {
box-sizing: border-box;
-moz-box-sizing: border-box;
}
html, body, .container {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
background-color: gray;
overflow: hidden;
}
.header {
height: 150px;
background-color: red;
}
.body {
position: absolute;
top: 150px;
bottom: 0;
left: 0;
right: 0;
white-space: nowrap;
vertical-align: top;
padding: 40px;
overflow-x: auto;
overflow-y: hidden;
}
.section {
min-height: 200px;
height: 100%;
border: 2px solid red;
margin-right: 40px;
display: inline-block;
min-width: 300px;
position: relative;
vertical-align: top;
}
.sectionheader {
height: 40px;
color: white;
font-size: 20pt;
padding-left: 5px;
}
.sectionbody {
white-space: normal;
border: 2px solid blue;
padding-top: 10px;
color: white;
height: calc(100% - 40px);
column-count: auto;
-webkit-column-count: auto;
column-width: 320px;
-webkit-column-width: 320px;
column-fill: auto;
-webkit-column-fill: auto;
}
.field {
margin: 0 10px 10px 10px;
width: 300px;
display: inline-block;
}
.field label {
font-size: 12px;
line-height: 20px;
display: block;
}
.field input {
width: 100%;
font-size: 16px;
line-height: 20px;
height: 40px;
padding-left: 5px;
}

这是 fiddle :http://jsfiddle.net/t7kQ4/7/

(拖动 handle 调整结果 Pane 的高度触发字段溢出)

最佳答案

这有帮助吗:http://jsfiddle.net/t7kQ4/10/

您需要删除您正在执行的计算并允许它是自动的。

section { 
height:auto;
}
.sectionbody {
height:auto;
}

关于html - Css3 列水平溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24006317/

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