如何在小程序中控制rich-text里面内容的样式?

小程序 文章 2020-08-07 16:41 1185 0 全屏看文

AI助手支持GPT4.0

如何在小程序中控制rich-text里面内容的样式?How to control the style of the content in rich-text in the applet?

如何在小程序中控制rich-text里面内容的样式?

rich-text里面的标签宽度比较宽,相要在小程序中控制最大宽度为100%也就是屏幕的宽度 ,如何控制?想要把所有的比较大的宽度的标签 如section标签等的width都 给一个max-width:100%

Rich text inside the label width is relatively wide, in order to control the maximum width in the small program is 100%, that is, the width of the screen, how to control? You want to give a max width of 100% for all tags with larger width, such as section tags

回答:

上上签:

我是给p标签追加了一个类,图片的话最大宽度100%

搞文艺的猿:

看下你rich-text返回的是什么标签,比如有图片,我给图片加上一个richImg的class类名,然后再css定义richImg

兵:返回的是section标签
兵:内容是用秀米添加的 有的section里面还有嵌套的section标签
搞文艺的猿:小程序是不是不支持section标签 你用正则把section替换成view  然后加一个类名 设置最大长度100就ok
搞文艺的猿:好像支持的嘛 你给section加class试试
微喵网络:

css

max-width: 100%

-EOF-

AI助手支持GPT4.0