css - 在顶部对齐图标而不偏移高度

标签 css

我正在尝试将顶部的相机图标直接对齐在 it's as easy as 标题的正下方。但是,当我增加标题下方的文本量时,它会下推其他组件。

<h2>Its As Easy As ...</h2>
<div style={{margin: '10px 0', display: 'inline-block'}}> //wrapper for all 3 

    // Icon with title component
    <div style={{display: 'inline-block', margin: '20px 10px', width: '200px'}}>
      <div style={{margin: '0 0 10px'}}>
        <FontAwesome name="camera" size="4x"/>
      </div>
      <div>
        <h3 style={{margin: '10px 0'}}>{title}</h3>
        <div>{desc}</div>
      </div>
    </div>
    ...repeat 2 more for the others
</div>

我在 desc 属性中传递了一些文本,当该文本很长时,它会将其他组件向下推。

我尝试设置固定高度,但这只会增加组件的整体高度。

如何对齐图标,使 desc 字段中的长文本不影响其他组件的高度?

enter image description here

最佳答案

您可以尝试让您的顶级 div 具有以下...

<div style={{margin: '10px 0', display: 'flex', alignItems: 'start', justifyContent: 'center'}}>

关于css - 在顶部对齐图标而不偏移高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45760152/

相关文章:

css - 在 2 列中 Bootstrap 固定宽度的图像

css - Safari 5.17 中不显示背景图片

html - 如何相对于父 div 定位叠加层?

javascript - 在哪里声明长 ng 样式的属性 Angularjs

javascript - 输入字段内带有删除按钮的徽章,如 stackoverflow

用于切换图像切换按钮类的Javascript

html - 修复一行表格的右边框线

html - 可扩展的 CSS 命名和子类化

CSS - 在 wordpress 网站上下拉菜单时将图标动画化为 'rotate'

javascript - 内容更改后如何使 onload 脚本再次工作