如何保持< div>用户在页面上放大和缩小时的大小常量? [英] How to keep a <div> constant in size as the user zooms in and out on the page?
问题描述
有没有一个html / css / javascipt方式来维持一个< div>在一个恒定的大小面对用户的缩放页面和输出?也就是说,使用control-plus来增加文字大小,并使用control-minus来减少文字大小。
Is there an html / css / javascipt way to maintain a <div> at a constant size in the face of the user's zooming the page in and out? That is, using control-plus to increase text size and control-minus to reduce it.
EDIT:我想让< div>的 内容 保持相同的大小。
The kicker, I guess, is that I want the content of the <div> to stay the same size, too.
编辑:我的目标是(和目前)保持AdSense< div>不会扩展,实际内容。但是来找到(谢谢@thirtydot)有没有好的方法来做到这一点。答案,对我来说(谢谢@Neal!):给予< div> overflow:scroll,以牺牲其内容,而不是我试图显示的内容。
My goal was (and is) to keep an AdSense <div> from expanding so much as to obscure a lot of the real content on the page. But come to find out (thank you @thirtydot) there's really no good way to do this. The answer, for me (thank you @Neal!): give the <div> overflow:scroll so as to sacrifice its content rather than the content I'm trying to show.
推荐答案
没有什么好办法(读:可靠)。对不起,
There is no good way (read: reliable) to do this. Sorry.
您要求的基本上是要检测浏览器的缩放级别,这里有一个很好的答案(确认这是多么困难):
What you're asking for basically boils down to detecting the zoom level of the browser, and there's a great answer here (confirming just how difficult this is):
- How to detect page zoom level in all modern browsers?
如回答所述,有一种有点的跨浏览器疯狂的方式涉及使用Flash,但有缺点:
As stated in that answer, there is a "kinda" cross-browser crazy way involving the use of Flash, but there are downsides:
- 如果用户已加载您的页面闪。是的,这是太糟糕了,我说了两次。想想所有的iPhone / iPad。
< 使用Flash。
- It uses Flash.
- It's not reliable if the user loads your page already zoomed in.
- It uses Flash. Yes, this is so bad that I said it twice. Think of all those iPhones/iPads.
Anyway, it's here:
http://blog.sebastian-martens.de/2009/12/how-to-detect-the-browser-zoom-level-change-browser-zoo/
这篇关于如何保持< div>用户在页面上放大和缩小时的大小常量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!