javascript - 如何在部分标签中并排对齐图像和文本 div?
问题描述
尽管屏幕大小,我需要这两个 div ,文本和图像并排。我希望它们彼此之间的距离相等。
div 并排对齐就好了。问题是当我进入桌面时,距离增加了,我该如何阻止它?
#welcome {
display: flex;
justify-content:center'
align-items: center;
}
.flex-child:first-child {
margin-right: 40px;
}
<div>
<section id="welcome" className="flex">
<div className="welcome-text">
<h2 className="mainTitle">Nutrition Integrated<br /><span>Data.</span><span>Insight.</span><span>Integrated.</span></h2>
<p className="welcome-para">Get access to our huge range of credit and debit cards that allows you to send unlimited transactions without getting charged any fees!.</p>
<button>Free Demo</button>
<button>Sign Up </button>
</div>
<div className="welcome-img">
<img src={SI} alt="SI"></img>
</div>
</section>
</div>
解决方案
如果你想在所有屏幕尺寸下保持相同的距离,你可以这样做:
#welcome {
display: flex;
justify-content: center;
align-items: center;
}
.welcome-text {
margin-right: 40px;
}
40px
它们将具有与所有屏幕尺寸相同的距离。
推荐阅读
- questdb - 有没有办法改变 QuestDB 中列的类型?
- java - Java 问题:一个子类的构造函数中的计算会影响另一个子类实例的字段
- javascript - Slick Slider (+ ACF) 所有图像高度相同
- angular - Angular Universal Express 预渲染使用错误的路径 src/src 而不仅仅是 src/
- java - 如何在自定义注释中选择性地使用注释
- security - Twitter 上的身份验证和会话如何工作?
- python - 不明白 RuntimeError 的原因:在当前进程完成之前尝试启动一个新进程
- azure - Azure NSG 阻止到 docker 容器的流量
- javascript - 我应该在反应打字稿中将什么类型传递给我的 imageIcon 道具?
- java - JBOSS 7 上 servlet 和 JSP 之间的通信