Home > OS >  How to align text to the right side of an img left side fully responsive set
How to align text to the right side of an img left side fully responsive set

Time:02-15

How to set all devices middle on content Demo Image Layout

CodePudding user response:

Use flexbox. Wrap the image and the text in a <div> and set the display property of that <div> to flex

Your html file

<div >
    <img src="img.png" alt="image-name" />
    <p>lorem ipsum</p>
</div>

Your css file

.align {
    diaplay: flex;
}

CodePudding user response:

Give a z-index and position your p tag absolutely as below. Html:

<div >
  <img src="img.jpg" alt="">
  <p>Your text</p>
</div>

And css:

.container {
    position: relative;
    width: 800px;
}
img {
    width: 100%;
}
p {
    z-index: 5;
    position: absolute;
    margin: 50px;
    top: 0;
}

CodePudding user response:

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"/>
You can easily handle it by using bootstrap 3,4,5 version. 
Check Bootstrap Documentation: https://getbootstrap.com/docs/4.6/layout/grid/
Example, 
<br>
<div >
  <div >
    <div >
      <img src="https://www.w3schools.com/w3css/img_snowtops.jpg" >
    </div>
    <div >
      <div >
        <div >Title</div>
        <p>
          Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
        </p>
      </div>
    </div>
  </div>
</div>

  • Related