繁体   English   中英

如何将图像放在不同图像旁边的文本下?

[英]How can i place image under text next to a different image?

目前,这是它的样子: https : //jsfiddle.net/r8zgokeb/1/但是,我还尝试在文本下方放置另一个小图像,但我希望它从文本下方开始。 因此,文本下方的图像不应超过左侧图像的底部。

HTML:

  <div class="image-txt-container">
      <img src="https://images4.alphacoders.com/206/thumb-350-20658.jpg">
      <h2>
        Text here
      </h2>
    </div>

CSS:

.image-txt-container {
  display:flex;
  align-items:center;
  flex-direction: row;
}

这是一个简单的代码(不是 flex,而是第一个 img 的浮动):

  <div class="image-txt-container">
   <img src="https://images4.alphacoders.com/206/thumb-350-20658.jpg">
   <h2>Text here</h2>
   <img src="https://images4.alphacoders.com/206/thumb-350-20658.jpg">
  </div>

和 CSS:

.image-txt-container {
width: 100%;
}

.image-txt-container img:first-child {
  float: left;
  padding-right: 40px;
  width: 450px;
}

.image-txt-container img:last-child{
  max-width: 50px;
}

嗨,认为这是一种方法

HTML

<div class="image-txt-container">
  <img src="https://images4.alphacoders.com/206/thumb-350-20658.jpg">
  <h2>
    Text here
  </h2>
  <img src="https://images4.alphacoders.com/206/thumb-350-20658.jpg">
</div>

CSS

.image-txt-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  grid-auto-flow: row;
}

.image-txt-container img:nth-child(3) {
  grid-column-start: 2;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM