html - 如何对齐 div 集合中的图像和按钮?
问题描述
我对CSS很糟糕。我正在尝试解决图像中捕获的问题。我的容器中的一个部分的文本量略少,导致在较小的设备上查看页面时看起来没有对齐。我试图让事情排列得更整齐,但我不知道如何做。
这是 Jade 中的代码:
extends base
block content
#marketing.container
.row
.3u
section
header
h2.titlething Sales & Marketing
p.subtitle
| In posuere eleifend odio. Quisque semper augue mattis maecenas
| ligula.
p
a(href='#')
img(src='images/pics13.jpg', alt='')
a.button(href='#') View Jobs
还有一些CSS:
.titlething {
margin-top: 1em;
margin-bottom: 0.2em;
}
/* Buttons */
.button {
position: relative;
display: inline-block;
margin-top: 0.5em;
padding: 0.5em 1.5em;
background: #e95d3c;
border-radius: 6px;
text-decoration: none;
text-transform: uppercase;
font-size: 1.1em;
color: #fff;
-moz-transition: color 0.35s ease-in-out, background-color 0.35s ease-in-out;
-webkit-transition: color 0.35s ease-in-out,
background-color 0.35s ease-in-out;
-o-transition: color 0.35s ease-in-out, background-color 0.35s ease-in-out;
-ms-transition: color 0.35s ease-in-out, background-color 0.35s ease-in-out;
transition: color 0.35s ease-in-out, background-color 0.35s ease-in-out;
cursor: pointer;
}
.button:hover {
background: #de3d27;
color: #fff !important;
}
#marketing {
position: relative;
justify-content: space-between;
}
#marketing header h2 {
font-size: 1.6em;
}
解决方案
可能最简单的解决方案是使标题高度始终相同。所以我的建议:
.titlething {
margin-top: 1em;
margin-bottom: 0.2em;
height: 4em;
}
当然,您需要调整高度参数以适合您的布局。
推荐阅读
- pipenv - Masonite 抛出 Invalid secret key 错误,即使在创建了密钥之后也是如此
- php - mysql 插入的 PHP 参数绑定(如果不存在)
- html - 如何以角度制作强制性网址输入字段?
- python - 在Python中创建包含n个重复项列表的数组
- android - 如何将 Amazon Alexa SDK 集成到 Android 应用程序?
- android - 更新为支持库版本 28.0.0-rc02 后,应用程序因“Error inflating class android.support.design.chip.Chip”而崩溃
- sql - 具有输入输出范围标识的存储过程
- python - 如何一次显示两个 Bokeh 对象?
- java - 如何提高执行时间的性能?他们有更好的方式来阅读这个文件吗?
- ios - IphoneX View 隐藏在 Tabbar 控制器的标签栏旁边