Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

图片样式统一支持自适应大小 #39

Closed
caiqiuxia opened this issue Oct 17, 2019 · 9 comments
Closed

图片样式统一支持自适应大小 #39

caiqiuxia opened this issue Oct 17, 2019 · 9 comments
Labels
question Further information is requested

Comments

@caiqiuxia
Copy link

新功能描述
图片样式统一支持自适应大小

应用场景
对图片数据不统一的处理

@jin-yufeng
Copy link
Owner

具体点?什么是统一支持自适应大小

@caiqiuxia
Copy link
Author

响应式样式
解决办法:tagStyle.img = "max-width:100%;max-height:100%;height:auto !important";
请看一下有问题吗?
再问一个问题,如何调试字体大小?

@jin-yufeng
Copy link
Owner

一般来说这样就可以,但是tagStyle的优先级是最低的,如果img标签的style属性中有height:1000px !important可能就失效了
可以把img-mode属性设置成widthFix,也是宽度不变,高度自适应(具体参考组件属性中的img-mode
至于字体大小,在style中设置font-size就可以了
如果要设置全局的字体大小,就直接在parser标签上加

<parser style="font-size:30px" />

@caiqiuxia
Copy link
Author

多谢多谢~

@caiqiuxia
Copy link
Author

image
你好,如何让小图片的宽度自适应屏幕宽度展示(宽度撑满屏幕),高度等比例缩放展示呢?

@jin-yufeng
Copy link
Owner

是对所有图片都这样吗?那就这样试一下

data:{
  tagStyle:{
    img: "width:100% !important;"
  }
}
<parser img-mode="widthFix" tag-style="{{tagStyle}}">

如果是对单张图片这样的话就在那个imgstyle属性里加上width:100%;height:auto

@caiqiuxia
Copy link
Author

您好,我以上说的可能不清楚,我再阐述一下问题:对于一篇文章,穿插几张图片,有的图片较大,有的图片较小。对于较大的图片,您组件中已经处理,现在是针对其中某一张较小的图片的处理方式。
期待结果:无论图片大小,都统一展示成宽度自适应屏幕,高度按照宽度等比例缩放。
您的方法“在那个img的style属性里加上width:100%;height:auto” 暂时实现不了较小图片按照屏幕宽度展示的效果。请问还有其他方式吗?

@jin-yufeng
Copy link
Owner

我试了以下是可以的呀
微信图片_20191018162102
上面那张是原大小,下面那张是加上width:100%;height:auto后的效果,你说的是这种效果吗?
另外你想实现的就是对所有图片生效,那就直接写在tag-style里呗,上面说的第一种也不行?

@caiqiuxia
Copy link
Author

抱歉,是我文件中有冲突。。。感谢,您耐心的解答💕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants