Flexbox:两列中的三个元素
我在一个LI项目中有三个元素:
<li>
<div class="on-offer">
<img src="#" />
<p>Title</p>
<a href="#">Link text</a>
</div>
</li>
我想使用Flexbox在左手图像中创建两个列,然后在右侧的段落和图像中创建两个列,但彼此之间的顶部。
到目前为止,我在SCSS中有:
.on-offer {
text-align:center;
display:flex;
flex-wrap:wrap;
justify-content:space-between;
p {
font-family:$serif;
font-style:italic;
font-weight:400;
color:#cc0000;
flex:1;
}
img {
width:50px;
height:auto;
display:block;
}
a {
display:block;
text-decoration:none;
color:$black;
font-family:$sans-serif;
flex:1;
}
}
有点有效。
创建了两个列,但是我无法获得段落和锚点彼此顶部。电子商务和发现单词是并排的,不像上图中的单词。
任何建议都将被感激地接受。
I have three elements in a li item:
<li>
<div class="on-offer">
<img src="#" />
<p>Title</p>
<a href="#">Link text</a>
</div>
</li>
and I would like to use Flexbox to create two columns, in the left hand the image and then the paragraph and image in the right hand side but on top of each other.
So far I have in my SCSS:
.on-offer {
text-align:center;
display:flex;
flex-wrap:wrap;
justify-content:space-between;
p {
font-family:$serif;
font-style:italic;
font-weight:400;
color:#cc0000;
flex:1;
}
img {
width:50px;
height:auto;
display:block;
}
a {
display:block;
text-decoration:none;
color:$black;
font-family:$sans-serif;
flex:1;
}
}
It kinda works.
Two columns are created, but I can't get the paragraph and anchor to sit top of each other. The words Ecommerce and discover are side by side and not like in the image above.
Any suggestions would be gratefully accepted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用FlexBox不可能,因为您无法重叠2个轴,您要在这里尝试进行。
要么使用
floats
或网格
布局类似:Its not possible with flexbox because you cant overlap 2 axes which you are trying to do here.
Either use
floats
orgrid
layout like: