有没有办法根据屏幕尺寸自动调整 MediaWiki 图像的大小?
MediaWiki pictures can be set to a certain size with simple formatting.
However, tables will resize on the fly depending on the browser / screen size.
Can images be made to resize like tables?
(Images inside tables does not work!)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我有同样的问题,从上面的答案(现在它们在下面)中看到,你不能有几张具有不同相对尺寸的图片。所以我写了一个mediawiki扩展允许这样做: http://mediawiki.org/wiki/Extension:AdaptiveThumb
I had the same question and saw from the answers above (now they are below) that you cannot have several pics with different relative sizes. So I wrote a mediawiki extension allowing this: http://mediawiki.org/wiki/Extension:AdaptiveThumb
随着浏览器大小的调整而动态调整大小:
将下一行放在 css 文件的开头: .\skins\common\shared.css
每个可调整大小的图像将放置在
在这里阅读更多内容: http://www.mediawiki.org/wiki/Help_talk:图像
Dynamic resizing as the browser is resized:
Put the next line at the begining of the css file: .\skins\common\shared.css
Each resizable image will be placed inside a
<div></div>
Read more here: http://www.mediawiki.org/wiki/Help_talk:Images
你可以设置一个CSS hack。
Mediawiki 允许您包含一些变量,例如 alt-text,在该变量中包含特殊字符串,例如
w100
或resizeable
将允许您使用 CSS 定位元素:请注意因为你在 CSS 中使用
alt
来做一些不应该使用的事情,并且!important
(因为 MW 将大小设置为元素样式),所以这是尽可能避免并且应该避免作为最后手段使用。You could set up a CSS hack.
Mediawiki allows you to include some variables like alt-text, including in that variable a special string such as
w100
orresizeable
will allow you to target the element with CSS:Do note that since you are using
alt
for things it's not meant to be used and!important
in the CSS (because MW sets the size as an element style), this is to be avoided as much as possible and meant to be used as last resort.简而言之,不,没有简单的方法可以做到这一点。可以想象,它可以用一堆繁琐的 Javascript 来完成,但我不知道有人尝试过这个,而且实现起来并不简单。
In short, no, there is no easy way to do this. It could conceivably be done with a bunch of fiddly Javascript, but I'm not aware of anybody having tried this and the implementation would not be trivial.
简短的回答是否定的。长答案是,您必须编写可以确定用户屏幕分辨率并将其存储在 cookie 中的 JavaScript。这很可能必须在 common.js 中完成,因此除了十亿分之一的用户之外从未访问过该网站并设法直接导航到具有动态大小图像的页面(我希望您不会在主页上放置类似的内容),当他们访问该网站时,该信息已经存在页。然后,页面可以使用这些变量将大小设置为
{{#expr:(文件高度 * 您希望其占据的屏幕百分比)*(屏幕高度)}}x{{#expr:(文件宽度* 您希望它占据的屏幕百分比)*(屏幕宽度)}}px
。我的 wiki 的主持人说他正在编写一个新的扩展,该扩展可能能够作为我想要制作的部分。如果您在我之前发现了其他内容,请更新这篇文章,以便我可以看到它。谢谢。 :D
The short answer is no. The long answer is that you would have to write JavaScript that can determine the user's screen resolution and store it in a cookie.. This would have to be done most likely in common.js so that with the exception of the one in a billion user that has never been to the site and manages to navigate directly to the page with the dynamically sized image (I hope you're not going to put something like that on your main page), that information will already be there when they get to the page. The page could then use those variables to set the size to be
{{#expr:(File height * % of screen you want it to take)*(screen height)}}x{{#expr:(File width * % of screen you want it to take)*(screen width)}}px
. The host of my wiki says he is in the process of writing a new extension that may be able to do that as part of a request for a<div style="overflow-x: scroll; width: {{#expr:(File width * % of screen you want it to take)*(screen width)}}px;">
section I want to make. If you find something else before me, please update this post so I can see it. Thanks. :D