html - 带有换行符的 Flex HTML CSS 问题

标签 html css flexbox

我在下面有以下 css 属性,它在这里工作,但我无法让它在生产环境中工作。它迫使我添加“flex: 0 0 100%”。现在我的解决方案是设置 *{flex: 0 0 100%},我的假设是它与 flex-basis 有关。有人有更好的解决方案吗?

没有我的全局解决方案的屏幕截图渲染

enter image description here

使用我的全局解决方案呈现的屏幕截图 enter image description here

<style>
.flex-container, .flex-row {
  display: flex;
  flex: 0 0 100%;
  flex-wrap: wrap;
}

.flex-row {
  margin-bottom: 15px;
}

#my-account .warning-message {
  width: 100%;
  padding: 15px;
  border: 1px solid red;
  border-radius: 15px;
  -webkit-box-shadow:0 0 10px red; 
  -moz-box-shadow: 0 0 10px red; 
  box-shadow:0 0 10px red;
}
</style>
<div class="flex-row warning-message">
  <h2>No warnings!</h2>
  <p>This section will only load when a warning is picked up on the account, in the production environment</p>
</div>

最佳答案

您需要更改 flexbox 内容的方向。默认为 row,但您应该使用 column。请注意我是如何删除 100% 值并且内容仍然正确堆叠的。

.flex-container,
.flex-row {
  display: flex;
  flex-direction: column;
}

#my-account .warning-message {
  padding: 15px;
  border: 1px solid red;
  border-radius: 15px;
  -webkit-box-shadow: 0 0 10px red;
  -moz-box-shadow: 0 0 10px red;
  box-shadow: 0 0 10px red;
}

/* Ignore */
.flex-row h2,
.flex-row p {
  margin: 0;
}
<div id="my-account">
  <div class="flex-row warning-message">
    <h2>No warnings!</h2>
    <p>This section will only load when a warning is picked up on the account, in the production environment</p>
  </div>
</div>

关于html - 带有换行符的 Flex HTML CSS 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55053996/

相关文章:

javascript - 响应式 Div

javascript - 如何让 div 保持固定状态直到 jquery 激活

javascript - 单击 addClass 时的 jQuery 缩放

css - 简单的CSS高度问题

html - 如何减少圆内第一行和第二行之间的缩进?

html - 如果一个框高于其他框,如何使用 display flex 换行并删除空格

html - html中选择输入的问题

javascript - :hover reset the first animation when mouseout 上的第二个动画

html - Flex 元素不会收缩小于其内容

html - 我不明白为什么在 flexbox 中我的图像下方有一个空白区域