I'm creating an application to create blog posts and show them.
The content of blog, along with the image data is stored as a string as HTML content. Upon retrieval in my Angular app, I'm doing:
<div class="contentBox" [innerHTML]="post?.content"></div>
Now I'm trying to wrap my images to fit the screen when viewed in mobile view but it always gets scrolled right. ( shown in the image as well)
To stop scrolling I tried
img {
margin: auto;
max-width: 100%;
}
It works perfectly when I try it using Inspect Element but when I add it in my code , it doesn't work. I'm adding it like this:
.contentBox img {
margin: auto;
max-width: 100%;
}
How am I supposed to have this functionality working in my code?