【发布时间】:2015-01-02 23:36:46
【问题描述】:
我需要为移动网站修复横向,所以我使用@media (orientation: portrait) {}。但是我有一个问题我找不到解决方案:使用身体变换后 - 子项显示在框外。下面有一个完整的例子。您可以保存它并使用移动仿真在 FF 或 chrome 中运行(右键单击页面,然后“检查元素”,然后更改仿真类型)。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Sample</title>
<style>
* {margin: 0; paddin: 0}
html {position: relative; height: 100%}
body {background: #ccc; position: relative; width: 100%; height: 100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; padding-bottom: 30px}
.box {background: #777; position: relative; width: 100%; height: 100%}
@media (orientation: portrait) {
body {
-webkit-transform: rotate(90deg);
-webkit-transform-origin: left top;
transform: rotate(90deg);
transform-origin: left top;
}
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
因此,想法是以纵向模式显示.box,就像它在横向模式中一样 - 覆盖在带有右填充的浅灰色主体上。这是图像示例:http://screencloud.net/v/EOXO
【问题讨论】:
-
媒体查询仅在满足其条件时才对内容进行样式设置,它们不会强制布局。所以如果页面的宽度大于高度,就会应用
orientation:portraitCSS。 -
我知道这一点,我的问题是关于另一个麻烦。当我使用
rotate (90)时,内容框正在远离可见区域,所以我在问如何强制它显示。
标签: css transform css-transforms