skip to Main Content

How to set all devices middle on content
Demo Image Layout

3

Answers


  1. 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 class="align">
        <img src="img.png" alt="image-name" />
        <p>lorem ipsum</p>
    </div>
    

    Your css file

    .align {
        diaplay: flex;
    }
    
    Login or Signup to reply.
  2. Give a z-index and position your p tag absolutely as below. Html:

    <div class="container">
      <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;
    }
    
    Login or Signup to reply.
  3. <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 class="container">
      <div class="row">
        <div class="col-sm-12 col-md-6 col-lg-6">
          <img src="https://www.w3schools.com/w3css/img_snowtops.jpg" class="w-100">
        </div>
        <div class="col-sm-12 col-md-6 col-lg-6">
          <div class="card p-4">
            <div class="card-title">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>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search