- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试让我的 flexbox 在移动设备上调整大小和窗口大小。
对于我的生活,我不知道为什么它不起作用。随着浏览器的缩小, flexbox 应调整大小并环绕到下一行。
#flex-container {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: left;
width: 1000px;
height: 400px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
background-color: #fff;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
overflow: hidden;
}
#left-zone {
background: #fff;
height: 75%;
flex-grow: 0;
display: flex;
width: 350px;
align-items: center;
justify-content: left;
min-width: 0;
}
#left-zone .list {
display: flex;
list-style: none;
align-content: stretch;
flex-direction: column;
/* flex-grow: 1; */
flex: 1 1 calc(33.33% - 20px);
margin: 0;
padding: 0;
}
.item input {
display: none;
}
label {
display: block;
opacity: 0.5;
height: 50px;
text-align: center;
line-height: 50px;
}
label:hover {
opacity: 0.75;
cursor: pointer;
}
/* content slides in on the right side of the flexbox */
.content {
position: absolute;
left: 350px;
top: -400px;
width: 650px;
height: 400px;
-webkit-animation-duration: 0.75s;
animation-duration: 0.75s;
-webkit-animation-name: slideout;
animation-name: slideout;
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
/* p tag content in the right side of the flexbox */
.content p {
max-width: 50%;
text-align: center;
}
#middle-border {
background-color: #eee;
height: 75%;
flex-grow: 1;
max-width: 2px;
z-index: 0;
}
/* Right side of flexbox where the content slides in */
#right-zone {
background-color: #ff000070;
height: 100%;
flex-grow: 3;
}
/* ==========Styles only related to the animation slidein: IGNORE============*/
@-webkit-keyframes slidein {
0% {
top: -400px;
opacity: 0;
}
100% {
opacity: 1;
top: 0;
}
}
@keyframes slidein {
0% {
top: -400px;
opacity: 0;
}
100% {
opacity: 1;
top: 0;
}
}
@-webkit-keyframes slideout {
0% {
top: 0;
opacity: 1;
}
100% {
top: -400px;
opacity: 0;
}
}
@keyframes slideout {
0% {
top: 0;
opacity: 1;
}
100% {
top: -400px;
opacity: 0;
}
}
input:checked ~ .content {
-webkit-animation-duration: 0.75s;
animation-duration: 0.75s;
-webkit-animation-name: slidein;
animation-name: slidein;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
-webkit-animation-timing-function: cubic-bezier(0.455, 0.03, 0.515, 0.955);
animation-timing-function: cubic-bezier(0.455, 0.03, 0.515, 0.955);
}
body {
background: #eee;
font-family: Tahoma;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta charset="utf-8">
<title>Flex Test</title>
</head>
<body>
<div id="flex-container">
<div id="left-zone">
<ul class="list">
<li class="item">
<input type="radio" id="radio_strawberries" name="basic_carousel" checked="checked" />
<label class="label_strawberry" for="radio_strawberries">strawberry</label>
<div class="content content_strawberry">
<h1>strawberry</h1>
<p>The garden strawberry... blah blah</p>
</div>
</li>
<li class="item">
<input type="radio" id="radio_banana" name="basic_carousel"/>
<label class="label_banana" for="radio_banana">banana</label>
<div class="content content_banana">
<h1>banana</h1>
<p>A banana... blah blah</p>
</div>
</li>
<li class="item">
<input type="radio" id="radio_apple" name="basic_carousel"/>
<label class="label_apple" for="radio_apple">apple</label>
<div class="content content_apple">
<h1>apple</h1>
<p>The apple... blah blah</p>
</div>
</li>
<li class="item">
<input type="radio" id="radio_orange" name="basic_carousel"/>
<label class="label_orange" for="radio_orange">orange</label>
<div class="content content_orange">
<h1>orange</h1>
<p>The orange... blah blah</p>
</div>
</li>
</ul>
</div>
<div id="middle-border"></div>
<div id="right-zone"></div>
</div>
</body>
</html>
随着浏览器窗口分辨率变小,我想将右侧包裹在左侧下方,但我似乎无法弄清楚。
flexbox 右侧的内容被隐藏,并使用 CSS 关键帧从顶部简单地滑入。我猜这可能是个问题,因为 flexbox 右侧的内容 div 基本上是空的
感谢任何帮助
最佳答案
Michael_B 很好地解释了这里的问题。
除了他的回答,我只想说你也在使用绝对 .content
,所以你的 flexbox 不是一个“普通”的 flexbox。
顺便说一句,使用您的 HTML,我试图让它负责。诀窍是删除所有固定宽度。
Bootstrap 是一种可能的方法,但如果您已经开始工作,则可以仅使用 CSS 属性而不使用 javascript(正如您正在做的那样)完成它:CSS 拥有执行此操作的所有凭据,无需框架。这是我的想法。
我尽量不更改您的 HTML。我只删除了 <div id="middle-border"></div>
因为你可以在你的 #left-zone .list
中创建一个右边框在box-sizing
的帮助下属性(property)......和边界权利,自然而然;)
在您的 CSS 中,我用更简单的不透明度和 translateY 过渡更改了您的动画(我认为您必须在没有其他动画的情况下从 A 点转到 B 点,所以一个过渡就足够了,我认为)。但是,嗯,这不是使用动画的错误,我认为只是在这项工作中使用过渡更简单。
另一个重要的想法是使用 CSS 在 HTML 元素的默认样式中提供更好的跨浏览器一致性。为此,我使用了“normalize.css”:https://necolas.github.io/normalize.css/ )
这是代码,希望对你有帮助:
body {
background: #eee;
font-family: Tahoma;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
#flex-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
width: 100%; /* no fixed width */
min-height: 400px; /*add min-height for 1 column layout */
height: 100vh;
max-width: 1000px;
margin: auto;
background-color: #fff;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
overflow: hidden;
flex-direction: column;
position: relative;
}
#left-zone {
height: 50%;
flex: 0 0 auto;
display: flex;
width: 100%;
}
#left-zone .list {
display: flex;
list-style: none;
align-content: stretch;
flex-direction: column;
flex: 1 1 auto;
margin: auto;
padding: 0;
box-sizing: border-box;
}
.item input {
display: none;
}
label {
display: block;
opacity: 0.5;
height: 50px;
text-align: center;
line-height: 50px;
position: relative;
}
label:hover {
opacity: 0.75;
cursor: pointer;
}
/* content slides in on the right side of the flexbox */
.content {
position: absolute;
right: 0;
bottom: 0;
opacity: 0;
transform: translateY(100%);
height: 50%;
width: 100%;
transition: 0.5s ease-out;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
pointer-events: none;
}
/* p tag content in the right side of the flexbox */
.content p {
max-width: 50%;
text-align: center;
}
/* Right side of flexbox where the content slides in */
#right-zone {
background-color: #ff8f8f;
width: 100%;
flex: 1 0 auto;
height: 50%;
}
input:checked ~ .content {
transform: translateY(0%);
opacity: 1;
}
@media (min-width:480px){
#flex-container {
flex-direction: row;
min-height: auto;
height: 400px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
#left-zone .list {
border-right: 2px solid #cccccc;
}
.content {
width: 65%; /* no fixed width */
height: 100%;
pointer-events: auto;
transform: translateY(-100%);
}
#left-zone {
width: 35%; /* no fixed width */
}
#right-zone {
height: 100%;
width: 65%; /* no fixed width */
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css" rel="stylesheet">
<div id="flex-container">
<div id="left-zone">
<ul class="list">
<li class="item">
<input type="radio" id="radio_strawberries" name="basic_carousel" checked="checked" />
<label class="label_strawberry" for="radio_strawberries">strawberry</label>
<div class="content content_strawberry">
<h1>strawberry</h1>
<p>The garden strawberry... blah blah</p>
</div>
</li>
<li class="item">
<input type="radio" id="radio_banana" name="basic_carousel"/>
<label class="label_banana" for="radio_banana">banana</label>
<div class="content content_banana">
<h1>banana</h1>
<p>A banana... blah blah</p>
</div>
</li>
<li class="item">
<input type="radio" id="radio_apple" name="basic_carousel"/>
<label class="label_apple" for="radio_apple">apple</label>
<div class="content content_apple">
<h1>apple</h1>
<p>The apple... blah blah</p>
</div>
</li>
<li class="item">
<input type="radio" id="radio_orange" name="basic_carousel"/>
<label class="label_orange" for="radio_orange">orange</label>
<div class="content content_orange">
<h1>orange</h1>
<p>The orange... blah blah</p>
</div>
</li>
</ul>
</div>
<div id="right-zone"></div>
</div>
关于html - Flexbox 不会在浏览器调整大小时换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52974070/
我面临着让一个相当复杂的网络应用程序在 HTML/CSS 中工作的问题。我发现 flexbox 有很多问题,这似乎可以解决我的问题。我试图了解我做错了什么或 flexbox 的限制是什么。我只在 Ch
尝试扩展 FlexBox 容器内输入的宽度。我希望它与父容器具有相同的宽度。这是我的 view.xml:
尝试扩展 FlexBox 容器内输入的宽度。我希望它与父容器具有相同的宽度。这是我的 view.xml:
我有两个 flexbox,它们在高度变化时收缩,嵌套内容重叠。 如何防止这种情况? 最佳答案 just add flex-shrink:0 to your element and the flexbo
我对 FlexBoxes 有疑问 - 我想要 我想将页面的一个部分分成两部分(相同高度),例如每个 100 像素 这些部分之一(第 2 个)我想分成三个小部分(等高)100/3 = 33px 下面的代
我的内容布局由三个部分组成:页眉、内容和页脚。对于小型设备,我想保留此顺序,在桌面设备上,我想将页眉和页脚移至侧边栏。 使用 float 实现:http://codepen.io/anon/pen/j
我正在尝试实现以下布局: +---------+---------------------+ |legend | | +---------+
我在尝试使用 Flexbox 进行某些标记时遇到问题。我制作了这个代码笔来演示我的问题:http://codepen.io/anon/pen/QjbzJY?editors=110 我希望左侧的图像(.
我正在尝试获得一个看起来有点像这样的用户界面: 在图片中,假装带有“New York...”的顶部栏和“Book it”按钮是固定的,并且它们之间的内容是可滚动的。 到目前为止,我的 HTML 是这样
我尝试调整一些动态内容,使其适合要打印的标签。 标签有一行 (.symbolContainer),可以包含 0 个或多个图像。目标是在 .text 框的内容需要更多空间时缩小 .symbolConta
我是 Stack Overflow 的新手,我遇到了 flexbox 的问题。 我想使用 和 与 display: flex;其中 main 的每一行都有 2 列 height: 100%浏览器和页脚
我想创建一个带有部分的水平 slider 。 Section 1 Card 1 ... Section 2 Card 1 ... ...
在给定的代码中,我需要识别第一行的最后一个元素和最后一行的第一个元素。只是为了让它从各个 Angular 落变圆。我怎样才能做到这一点?我需要在这里提到的是,根据屏幕尺寸,列号以及第一行的最后一个元素
我花了一整天的时间来完成这项工作。虽然我可以使用一个 flex 盒,但当一个 flex 盒要包含另一个 flex 盒时就会变得很麻烦。 我试着按照这个问题的提示去做: Flexbox inside a
在我的测试中(以及我的其他 SO 问题的回答),当 flexbox 占用页面的整个宽度或具有固定宽度的父元素时,它可以很好地处理溢出文本。但是,如果具有动态宽度的 flexbox 在另一个动态宽度 f
我正在尝试让一个 flexbox 在 flexbox 内部工作。当第一个(包装)flexbox 工作时,里面的那个什么都不做。无论如何让这个工作? 我想要做的是有效地拥有两个粘性页脚,并且两者的高度都
我正在尝试使用 flexboxes 并想组合一个列和行容器。我的问题是: 为什么放置在列中的行元素没有跨越 flex 容器的整个宽度? 此处显示示例代码:js-fiddle HTML: /* CSS:
目标 我正在使用 SASS 开发一个基于 flexbox + calc() 的 grid system with gutters。 您可以像这样通过混合定义网格: .box { @inc
在IE11下运行时,下面的例子会在itemwrapper的底部添加空格元素。在开发控制台中检查时,此空间不归因于边距、填充或边框。测量子元素的高度似乎是一个问题,因为如果给它们一个固定的高度,那么空间
我的目标是在 Angular 5 项目中使用 ag-grid,并让网格占据 Flexbox 布局中的所有可用垂直空间。当网格包含在具有定义的像素高度的 div 中时,或者当 div 具有百分比高度但不
我是一名优秀的程序员,十分优秀!