简体   繁体   中英

React component with dangerouslySetInnerHTML, contain CSS

I have a React component that renders this element:

<div dangerouslySetInnerHTML={{__html: this.props.htmlString}}/>

It works fine, and the html is being rendered. However, the issue that I'm having is that my client code has CSS in place, which is reaching into the component that I'm rendering from this.props.htmlString . Is there a way to prevent my client CSS code from being applied to this component?

您必须以CSS中的元素为目标,并覆盖您不想应用的样式。

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