Search code examples
htmlcssangularservice

keep margin between text and image


In my code I use the service and retrieve data from the backend. I have code like this to retrieve the content.

<div class="body" *ngFor='let topic of topics | async'>
   <div [innerHTML]="topic.content"></div>
</div>

This topic.content have some text and image. What I want is keep margin between this text and image. But I have no idea to do that. Can someone help me on this.


Solution

  • Based on your comments, if you change that inner div to:

    <div class="splitter" [innerHTML]="topic.content"></div>
    

    then you can put in styles.css (global styles, not component's css file) something like:

    .splitter > img { 
        padding-left: 10px; 
    } 
    

    But I don't know how you styled the 'body' class of the parent div and if there's styling in the .content value itself, so you will need to play a bit with that .splitter class.