简体   繁体   中英

How to show <img> tag inside the <p> tag

I am building an app with Ionic, in which some codes are associated with some images, Now, in my post, which are from database, contains any of those codes, replace the particular code with the respective image in the <p> tag.

For example: in my post if (#mountain#) is found then the respective image associated with (#mountain#) is shown instead of the code.

Is it possible for you to add a CSS class/ID to the <p> tags?

Then you could add a class to the tag for each post with the keyword you are using and then use a CSS background image to show the correct image for that post.

So if you add a class to your <p class="MyClass"> you can then target an image/ div inside of there with CSS.

An easier way for you may be to add a class to the image tag, so <p class="MyClass">

Then you can update the src attribute of the image using CSS as follows:

.MyClass{ content:url("http://YOURIMAGE.jpg"); }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM