简体   繁体   中英

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

Currently, this is what it looks like: https://jsfiddle.net/r8zgokeb/1/ However, I am trying to place another small image underneath the text as well, but i want it to start right underneath the text. Therefore, the image underneath the text should not go past the bottom of the left image.

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;
}

Here is a simple code (not flex, but float of first 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>

And 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;
}

Hi think this is onw of the way to do

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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