【发布时间】:2017-12-05 18:32:15
【问题描述】:
好的,使用 flex 将图像(紫色)和内容(黄色)并排对齐。但是,我在两者之间获得了额外的空间,并且正在将图像扔到右侧。
应该是这样的:
- 图像应该在黄色 div 旁边的蓝色 div 内
- 黄色 div 的宽度应为 60%(这些是弹性项目)
我已经检查了填充和边距,但它对我不起作用。有什么想法吗?
这里是html
<div class="sec-1">
<h2>Introducing 'Keeva' world's smartest assistant.</h2>
<div class="flex-box">
<div>
<p class="sales-copy">Keeva smartphone app helps you organize your work schedule, meetings, project deadlines and much more.</p>
<!-- Download Buttons -->
<img class="download-btns" src="img/playstore-1.png">
<img class="download-btns" src="img/iphone-1.png">
</div>
<!-- Phone 0 image -->
<img class="phone-img" src="img/iphone-cut.png" alt="phone image">
</div>
</div>
CSS
@media screen and (min-width: 599px) {
.sec-1 h2 {
font-size: 1.2em;
background-color: green;
}
.sec-1 p {
font-size: 1.1em;
width: 50%;
background-color: yellow;
}
.sec-1 .phone-img {
position: relative;
top: 10%;
left: 30%;
background-color: purple;
}
.download-btns {
position: relative;
right: 25%;
background-color: orange;
}
.sec-1 .sales-copy {
width: 50%;
}
.flex-box {
display: flex;
justify-content: flex-end;
}
}
【问题讨论】:
-
这是一个未完成的小提琴。调整按钮 img 大小,因为它们当前设置为拉伸到容器宽度/高度的 100%。 jsfiddle.net/Hastig/u3pth5zs