div#content{
width: 100vw; // The width of this element is 100% of the viewports width
height: 100vh; // The height of this element is 100% of the viewport height
font-size: 1vmax; // You can fiddle with this to mame sure the font gets
// the size you want
}
2 回答
您无法独立缩放宽度和高度,但您可以使用CSS scale property模拟缩放效果,您可以将其独立应用于X轴和Y轴:
DEMO
不要忘记将变换原点指定为
0 0
,以便视口不会裁剪元素的顶部/左侧 .视口宽度 - 高度可能就是您需要的
如果希望元素保持其相对位置,则可以对
top
和left
css属性使用相同的规则虽然并非所有浏览器都支持此功能,但可以使用polyfill here以使其恢复到IE8