簡體   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