css - flex-basis: column,wrap 应该发生什么?
问题描述
我正在试验 css,特别是这个 HTML:
<!doctype html>
<html class="no-js" lang="en">
<head>
</head>
<body>
<header>
<div class="child">
<h1>Some random text</h1>
</div>
<ul class="child">
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">Contact</a></li>
</ul>
<div class="child">
<input type="text" name="search" id="search">
</div>
</header>
</body>
</html>
这个CSS:
html, body {
height:100%;
background:#1c1c1c;
width:200%;
}
header {
display:flex;
background:#000;
padding-top:18px;
justify-content:space-around;
flex-flow: column wrap;
}
wrap
使用 flex 方向时似乎没有效果:列。应该发生什么?如果我减小浏览器的垂直尺寸(意味着项目不适合),那么项目是否应该分成两列?如果我将浏览器的垂直尺寸减小到最小,那么会出现一个垂直滚动条?
我在这里阅读了 flex-wrap 的文档:https ://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap并且我看过这里:https ://css-tricks.com/片段/css/a-guide-to-flexbox/。我所看到的任何地方似乎都假设您在包装时使用的是行的弯曲方向。如果指定了列的弯曲方向,我找不到关于应该发生什么的解释。
解决方案
#example-element {
border: .75em solid;
padding: .75em;
width: 40%;
float: left;
display: flex;
flex-flow: column wrap;
}
#example-element>div {
background-color: rgba(0,0,255,.2);
border: 3px solid #00f;
width: 60px;
margin: 10px;
}
.short {
background-color: tomato;
height: 200px;
}
.tall{
background-color: aquamarine;
height: 400px;
}
<div id="example-element" class="transition-all short">
<div>Item One</div>
<div>Item Two</div>
<div>Item Three</div>
<div>Item Four</div>
<div>Item Five</div>
<div>Item Six</div>
</div>
<div id="example-element" class="transition-all tall">
<div>Item One</div>
<div>Item Two</div>
<div>Item Three</div>
<div>Item Four</div>
<div>Item Five</div>
<div>Item Six</div>
</div>
推荐阅读
- python - 编写几个 PDE 方程并在 FiPy 中求解
- javascript - Javascript 仅在 html 上执行一个 window.onload 触发器资源
- tensorflow - 如何获取深度学习模型的输出激活值?
- r - 重新分类 rgee 中的图像像素(谷歌地球引擎中的 R 库)?
- python - pymc3 中的错误“模块‘pymc3’没有属性”
- java - 错误:从 Java 项目调用 kotlin 类时无法访问 KMappedMarker
- python - 迭代没有空格的单个字符串并在python中识别浮点数和整数
- android - 在 Firebase Auth 中合并 facebook 和 google 用户
- excel - 将第二个数据条目添加到 Excel 表中时,对象“范围”的 VBA 错误方法“_Default”失败
- websphere - 想要使用 IBM MQ 系列连接到 MQ - 而不是 JMS。我的应用程序将部署在 WAS 上,而 Q Manager 在另一个服务器上。我如何通过 conn 参数?