# Images and text display inline or flex

**URL:** <https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397>\
**Category:** General\
**Created:** [March 12, 2020, 7:24pm UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397 "2020-03-12T19:24:00Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![deedee](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/deedee/32/127358_2.png) [@deedee](https://forum.freecodecamp.org/u/deedee)\
**Post date:** [March 12, 2020, 7:24pm UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/1 "2020-03-12T19:24:00Z")

</div>

What i have is this:

 ![image](https://global.discourse-cdn.com/freecodecamp/original/3X/f/5/f583321ff896736ac08807ed3a24092b2b39fd65.jpeg)  
The css:

```auto
.flex_songs {
  display: flex;
  align-content: space-between;
  justify-content: flex-start;
}

```

Another example of things not going my way:  
 ![image](https://global.discourse-cdn.com/freecodecamp/original/3X/1/f/1fd9860d5512f054eb0d9e63a0b26ec60574b389.png)  
What i want:

 ![image](https://global.discourse-cdn.com/freecodecamp/original/3X/6/d/6de950574197d361d25e11cac010dc7de9fafd89.png)

How do i get the image and text to align to one side while having space between the image and text while having the text align at the center of the image? Cause at time goes on, i plan on having another list but with buttons to be aligned on the same line as the text.

---

<div class="post-metadata">

**Author:** ![Madalena.design](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/madalena.design/32/114308_2.png) [@Madalena.design](https://forum.freecodecamp.org/u/Madalena.design)\
**Post date:** [March 12, 2020, 7:31pm UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/2 "2020-03-12T19:31:53Z")

</div>

Hello @deedee

It would be best to post the full code to have a better understanding. However, I do notice that in your code, there isn’t a `flex-direction` property being defined (row or column). Whether this may help is yet to be known.

---

<div class="post-metadata">

**Author:** ![JulHelm](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/julhelm/32/136312_2.png) [@JulHelm](https://forum.freecodecamp.org/u/JulHelm)\
**Post date:** [March 12, 2020, 8:05pm UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/3 "2020-03-12T20:05:49Z")

</div>

I think that a two column grid would be easier for what you want here. If you want to stick with flexbox try to put the logos and the names into two  
Separate divs that both use flex. See code below but use start end on top.

```auto

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
  box-sizing: border-box;
}

.row {
  display: flex;
}

/* Create two equal columns that sits next to each other */
.column {
  flex: 50%;
  padding: 10px;
  height: 300px; /* Should be removed. Only for demonstration */
}
</style>
</head>
<body>

<h2>Two Equal Columns</h2>

<div class="row">
  <div class="column" style="background-color:#aaa;">
    <h2>Column 1</h2>
    <p>Some text..</p>
  </div>
  <div class="column" style="background-color:#bbb;">
    <h2>Column 2</h2>
    <p>Some text..</p>
  </div>
</div>

</body>
</html>

```

---

<div class="post-metadata">

**Author:** ![deedee](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/deedee/32/127358_2.png) [@deedee](https://forum.freecodecamp.org/u/deedee)\
**Post date:** [March 12, 2020, 8:38pm UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/4 "2020-03-12T20:38:31Z")

</div>

what do you mean by full code? Is the css not enough?

---

<div class="post-metadata">

**Author:** ![deedee](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/deedee/32/127358_2.png) [@deedee](https://forum.freecodecamp.org/u/deedee)\
**Post date:** [March 12, 2020, 8:43pm UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/5 "2020-03-12T20:43:34Z")

</div>

this is the code for the one with the pink background

```auto
 <TableCell className={styles.flex_songs}>
                      <Image
                        src={song.track.album.images[0].url}
                        rounded
                        size="mini"
                      />
                      <p>{song.track.name} </p>
 </TableCell>

```

---

<div class="post-metadata">

**Author:** ![deedee](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/deedee/32/127358_2.png) [@deedee](https://forum.freecodecamp.org/u/deedee)\
**Post date:** [March 12, 2020, 8:53pm UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/6 "2020-03-12T20:53:16Z")

</div>

I used your suggestion:

 ![image](https://global.discourse-cdn.com/freecodecamp/original/3X/a/4/a478cc783e104c9ef119fd8063093a1d3776dcf9.jpeg)

How do i get the text closer to the pic, like in this pic:

 ![image](https://global.discourse-cdn.com/freecodecamp/original/3X/6/d/6de950574197d361d25e11cac010dc7de9fafd89.png)

Padding right does not work

---

<div class="post-metadata">

**Author:** ![JulHelm](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/julhelm/32/136312_2.png) [@JulHelm](https://forum.freecodecamp.org/u/JulHelm)\
**Post date:** [March 12, 2020, 9:06pm UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/7 "2020-03-12T21:06:38Z")

</div>

Try `flex: 0 0 xxxpx; ` in the left column div to servitude to xxxpx width.  
If you just want the logos to the right try align-items : flex-end or justify-content : flex-end. Whichever helps 😉

---

<div class="post-metadata">

**Author:** ![JulHelm](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/julhelm/32/136312_2.png) [@JulHelm](https://forum.freecodecamp.org/u/JulHelm)\
**Post date:** [March 13, 2020, 5:40am UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/8 "2020-03-13T05:40:44Z")

</div>

Why does padding right not work? Any idea? 😉

---

<div class="post-metadata">

**Author:** ![deedee](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/deedee/32/127358_2.png) [@deedee](https://forum.freecodecamp.org/u/deedee)\
**Post date:** [March 17, 2020, 11:57pm UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/9 "2020-03-17T23:57:46Z")

</div>

i have no idea. Maybe cause the div or container the image and text are in has no specific width but a width that resizes according to content? Please help. Thank you.

---

<div class="post-metadata">

**Author:** ![psychometry](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/psychometry/32/79114_2.png) [@psychometry](https://forum.freecodecamp.org/u/psychometry)\
**Post date:** [March 18, 2020, 2:53am UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/10 "2020-03-18T02:53:22Z")

</div>

Best guess is your left column(image) also has the width of 50%. So it is taking of 50% of the row automatically. Padding doesn’t work because your text is already left justified and the padding right is not squeezing your text anywhere.

Your browser’s dev tool does a perfectly good job of giving you all the dimensions of your elements, including padding and margins. Do make use of it when you run into issues such as this. A lot of times it gives you far more information that will help you resolve the problem then us guess blindly without seeing your source code.

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [March 18, 2020, 5:22am UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/11 "2020-03-18T05:22:49Z")

</div>

Something like this?  
[https://codepen.io/lasjorg/pen/ExjRXjo](https://codepen.io/lasjorg/pen/ExjRXjo)

---

<div class="post-metadata">

**Author:** ![deedee](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/deedee/32/127358_2.png) [@deedee](https://forum.freecodecamp.org/u/deedee)\
**Post date:** [March 24, 2020, 9:29pm UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/12 "2020-03-24T21:29:18Z")

</div>

Can you explain where you got this?

```auto
<svg class="like liked" viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1">
      <path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"></path>
    </svg>

```

Thank you

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [March 24, 2020, 9:44pm UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/13 "2020-03-24T21:44:13Z")

</div>

The SVG is from [Feather](https://feathericons.com), I just copied the SVG code from the site.

1. Right-click the icon you want and click Inspect.

2. In the Elements tab, right-click the SVG element and from the menu select Copy, from the submenu select Copy outerHTML.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 7:32pm UTC](https://forum.freecodecamp.org/t/images-and-text-display-inline-or-flex/358397/14 "2021-06-01T19:32:31Z")

</div>

Closed on June 1, 2021, 7:32pm UTC


