html - 为什么边距会影响我的内联块 div 是否会使用 flex-start 对齐到顶部?
问题描述
我只是在学习 css 和 html,我想更好地理解事情。
在内联块中显示 3 个 div 时,我想将它们全部对齐到 flexbox 部分的顶部。看起来像“align-items: flex-start;” 是应该这样做的代码,但 div 没有反应。我正在尝试不同的东西,一旦我添加了“margin:1vmax”,它就起作用了;到 div 属性。为什么没有它就行不通?这里的基本原理是什么?
section{
background:cadetblue;
padding: 20px 20px;
display: flex;
flex-direction: row;
align-items: flex-start;
}
div{
background:black;
color: white;
height:auto;
width: 25%;
padding: 0.5em 2em;
margin:1vmax;
text-align: justify;
text-justify:inter-word;
}
解决方案
Hey there is nothing wrong in the code you didn't added any content in the div's so that's why you are not able to see the difference.
<section>
<div></div>
<div> Your reducer function's returned value is assigned to the accumulator, whose value is remembered across each iteration throughout the array and ultimately becomes the final, single resulting value.</div>
<div> sfsdfsfs s sf sf s s saf sa saf</div>
</section>
section{
background:cadetblue;
padding: 20px 20px;
display: flex;
flex-direction: row;
align-items: flex-start;
}
div{
background:black;
color: white;
height:auto;
width: 25%;
padding: 0.5em 2em;
margin:1vmax;
text-align: justify;
text-justify:inter-word;
}
check here:https://jsbin.com/yevipowusi/edit?html,css,js,output
推荐阅读
- c - 影响 char 上的移位运算符
- python - 我找到了一个掩码检测程序,想知道是否可以用其他东西替换 tensorflow 库
- r - R 包开发 - 如何处理包安装时的 C 库链接错误
- javascript - 如何根据选中的单选按钮禁用某些复选框?
- postgresql - 'DISABLE TRIGGER ALL' 是否也会禁用 Postgres 中的域检查?
- javascript - 通过道具将功能从类组件编辑状态传递到基于功能的组件不起作用
- identityserver4 - IdentityServer4 Windows 身份验证缺少回调实现
- java - Kafka Consumer 中更好的错误处理方式
- javascript - 如何在 vue 中全局配置 vee-validate?
- firebase - 如何从 Firebase 存储中获取可公开访问的 URL?