-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Use width instead of maxWidth after resizing image #8683
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
Comments
@88250 另外我建议思源直接支持在设置里设置图片的最大默认宽度(实际值或百分比), 这个限制图片宽度的需求有很多人提了,之前我用代码片段实现,最近发现失效了, 所以官方能支持的话就省事了 |
默认是没有 style 属性的,只有手动调整过图片大小才会有。 |
另外,如果支持设置默认宽度,不同设备上应该无法自适应。之前考虑过 #5097 |
这个可以弄成本地设置, 不同设备间相互独立 |
没失效啊我还可以限制默认最大宽度。 |
@chenshinshi 代码片段发一下我试试 |
.b3-typography img, .protyle-wysiwyg img { |
@chenshinshi 这个是直接作用于 img元素的,我之前试过, 如果你把 400px 换成百分比,比如30% ,就会出现问题,如下图,图片两边会出现空白 |
我不太清楚你想达到的效果,我使用这段代码还搭配了图片居左等设置。 |
@chenshinshi 你把400px换成 百分比, 就能发现问题了 |
1 similar comment
请问最终是能实现这样设置了吗?怎样设置? |
@pisceswb 可以的,下面代码片段是百分比宽度的,把30%改成111px就是固定宽度了;
-----更新, |
一直不明白,为什么这么多人需求的插入图片后自动调整图片大小的功能咋就怎么也实现不了。。。。 |
感谢回复,不是想限制图片的最大宽度,是想实现插入新图片后,图片的宽度能够默认设置成33%。不用每次都手动调整 |
@pisceswb 上面的代码就可以实现你的需求,粘贴图片后默认宽度30%,手动缩放后最大宽度能超过30% |
@88250 @Vanessa219 手动缩放图片宽度时修改的是元素的max-width属性, 而通过图片右键菜单"宽度"修改的是元素width属性, 能不能统一 一下? 由于这个差异导致我通过代码片段设置图片最大宽度时(设置max-width)不能同时能够手动缩放+图片右键菜单缩放,只能二选一 |
统一为 width,还麻烦看一下是否可以了? |
@pisceswb max-width 改为 width 试试,这个不是每个人都有这样的需求,只能自定义 |
@Vanessa219 这会不会造成页面宽度较小时图片无法完整显示❓ |
可以的~ |
应该不会,还有个 max-width:100% 的样式 |
可用了,非常感谢! @Vanessa219 @iamqiz |
Is there an existing issue for this?
Can the issue be reproduced with the default theme (daylight/midnight)?
Could the issue be due to extensions?
Describe the problem
在使用下面的css代码片段限制图片最大宽度时, 发现不会生效,但是给元素手动加上 style属性之后才能生效(即便为空值)
元素如下

所以建议给这个元素默认加上 style属性,空值即可,
顺便请教一下,为什么加个style之后才会生效?
Expected result
1
Screenshot or screen recording presentation
No response
Version environment
Log file
1
More information
No response
The text was updated successfully, but these errors were encountered: