skip to Main Content

As said in title just want to make my image appear side by side to the text in the "title" element

<!doctype html>
<html>
 <head>
 <style>
 .logo {
    box-shadow: 0px 0px 5px white;
    border: 1px solid #cccccc;
    display: inline-block;
    width: 30%;
  
  }

.main{
    width: 100%;
    padding: 20px;
   

}
.element{
    background-color:#3c3B37;
    }
.title {
  display: inline-block;
  overflow: hidden;
  margin-left: 50px;
  border: 1px solid #cccccc;
  background: linear-gradient(90deg, #cccccc, white);
  
  
  
}
.title p {
  margin: 6px;
}
 </style>
 </head>
 <body>


 <div class="main">
 <div class="element">
 <img class="logo" src="img_snow.jpg" alt="snow" />
 <div class="title"> <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 pub
 </p></div>

 </div>
 <div class="element">
 <img class="logo" src="img_forest.jpg" alt="forest" />
 <div class="title"> <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 pub
 </p></div>
 </div>
 <div class="element">
 <img class="logo" src="img_mountains.jpg" alt="mountains" />
 <div class="title"> <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.
2
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 pub
 </p></div>
 </div>

 </div>
 </body>
</html>

here’s the output I’m getting
enter image description here

tried using display in-block to make the images in the "logo" element appear in rows side by side to the text in element "title" but instead seperated them into two different inline-blocks

2

Answers


  1. Try this:

    Just modified below code

    .element{
     display:flex;         // Just added display:flex
     background-color:#3c3B37;
     }
    
    <!doctype html>
    <html>
     <head>
     <style>
     .logo {
        box-shadow: 0px 0px 5px white;
        border: 1px solid #cccccc;
        display: inline-block;
        width: 30%;
      
      }
    
    .main{
        width: 100%;
        padding: 20px;
       
    
    }
    .element{
        display:flex;
        background-color:#3c3B37;
        }
    .title {
      display: inline-block;
      overflow: hidden;
      margin-left: 50px;
      border: 1px solid #cccccc;
      background: linear-gradient(90deg, #cccccc, white);
      
      
      
    }
    .title p {
      margin: 6px;
    }
     </style>
     </head>
     <body>
    
    
     <div class="main">
     <div class="element">
     <img class="logo" src="https://picsum.photos/200/300" alt="snow" />
     <div class="title"> <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 pub
     </p></div>
    
     </div>
     <div class="element">
     <img class="logo" src="https://picsum.photos/200/300" alt="forest" />
     <div class="title"> <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 pub
     </p></div>
     </div>
     <div class="element">
     <img class="logo" src="https://picsum.photos/200/300" alt="mountains" />
     <div class="title"> <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.
    2
    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 pub
     </p></div>
     </div>
    
     </div>
     </body>
    </html>
    Login or Signup to reply.
  2. easiest way is to use float, that’s what it was built for!

    img {
      float: left;
      margin-right:10px;
    }
    <img src="https:\placeholder.com50">
    <p>Abrysvo made by Pfizer, approved 5/31/23 for adults 60 and older. Approved for pregnant women 8/21/23. Abrysvo is not an adjuvanted vaccine but it is bivalent, protecting against RSV types A and B.
    Both vaccines are administered intramuscularly.
    Similar side effects of headache, muscle pain, fatigue, injection site pain with both vaccines. </p>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search