根据窗口大小调整页面元素的大小
问题: 我的客户希望我为他的产品创建一个启动网页,以便页面上不应该有滚动,任何浏览器或窗口尺寸。
疑问:使用CSS和Javascript可以实现这一点吗?
一些早期诊断:这可能有点类似于这个或this 但不同之处在于我想以特定比例调整每个元素的尺寸,而不仅仅是调整父 DIV 的高度。
所以,声明:我需要根据(当前窗口大小和参考)之间的比率来更改每个元素(图像、div、文本...所有)的尺寸窗口大小)。也许 Javascript 可以解决这个问题?
问题:如何做到这一点?
Problem:
My Client wants me to create a launch webpage for his product such that there should be no scroll on the page, be any browser or window dimensions.
Doubt: Is this possible using CSS and Javascript?
Some Early Diagnosis: This might be a little similar to this or this but the difference is that I want to resize the dimensions of each and every element in a particular ratio and not just adjust the height of a parent DIV.
So, the statement: I need to change the dimensions of each and every element (images, divs, text ... all) based on a ratio between the (current window size and a reference window size). Perhaps Javascript might have a cure for this?
Question: How to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将
和
的
height
和width
设置为100%
、溢出
到隐藏
并使用left
、top
、width
和height
的百分比 elements:这些百分比是相对于包含块而言的,在本例中是
。
更新:回答另一个问题:目前几乎不支持背景图像的缩放。当 CSS 3
background-size
< /a> 属性取得进展(请参阅此表),事情会变得更容易。现在,看看这个答案(是的,这意味着:更多标记)。Just set the
height
andwidth
of<html>
and<body>
to100%
,overflow
tohidden
and use percentages forleft
,top
,width
andheight
of elements:These percentages are relative to the containing block, which is, in this case
<body>
.Update: To answer another question: scaling of background images is almost not supported yet. When the CSS 3
background-size
property gains ground (see this table), things will be easier. For now, have a look at this answer (yes, that means: more markup).