How to properly place several rows of text next to an image and indent it correctly

Viewed 22

So, I am just beginning to learn HTML and CSS and am working on a private project. What I am trying to achieve is this: https://imgur.com/a/kg1rE9U

The thing I struggle with is the first blue "box". More precisely, I just don't know how to properly format it like in the above picture (distance to the borders of the box, distance between image and text2 / text 3, ...). Not only does my code not work as intended (the distance between text2 and text3 is way too large for example), I also feel like I am doing it more complicated than it actually is.

HTML-Code so far is

<div class="standardfield", style="width: 100%;">
                        <p class ="standardfield", style="float:left;">
                            <span style="display:block; height: 20px;"></span>
                            <img src="image.png">
                        </p>
                        <p class ="standardfield", style="font-size: 40px; text-indent:20px;">
                            <span style="display:block; height: 20px;"></span>
                            <b>text2</b>
                        </p>
                        <div class="standardfield", style="font-size:20px; text-indent: 20px;"> 
                            text3 
                        </div>

while the CSS is

.standardfield {
            text-align:left;
            background-color: #D0DEED;
            color: #548DD1;
            }
1 Answers

You should use display:flex.

.wrapper {
  display: flex;
  flex-direction: row;
  width: 100%;
}

.bluebox {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-grow: 1;
  background-color: #D0DEED;
  color: #548DD1;
  padding: 10px;
  margin: 10px;
}

.text {
  padding-left: 10px;
  text-align: left;
}
<div class="wrapper">
  <div class="bluebox">
    <img src="https://www.gravatar.com/avatar/8679b0fa062922b9826d58315e6f0324?s=64&d=identicon&r=PG&f=1">
    <div class="text">
      <p><strong>text2</strong></p>
      <p>text3</p>
    </div>
  </div>
</div>

<div class="wrapper">
  <div class="bluebox">
    <img src="https://www.gravatar.com/avatar/8679b0fa062922b9826d25315e6f0324?s=64&d=identicon&r=PG&f=1">
    <div class="text">
      <p><strong>text2</strong></p>
      <p>text3</p>
    </div>
  </div>
  <div class="bluebox">
    <img src="https://www.gravatar.com/avatar/8679b0fa062955b9826d25315e6f0324?s=64&d=identicon&r=PG">
    <div class="text">
      <p><strong>some more text</strong></p>
      <p>text1</p>
      <p>text2</p>
      <p>text3</p>
    </div>
  </div>
</div>

Related