diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/@media/orientation | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/css/@media/orientation')
-rw-r--r-- | files/zh-cn/web/css/@media/orientation/index.html | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/@media/orientation/index.html b/files/zh-cn/web/css/@media/orientation/index.html new file mode 100644 index 0000000000..d55e57ccb2 --- /dev/null +++ b/files/zh-cn/web/css/@media/orientation/index.html @@ -0,0 +1,94 @@ +--- +title: orientation +slug: Web/CSS/@media/orientation +tags: + - '@media' + - CSS + - 参考 +translation_of: Web/CSS/@media/orientation +--- +<div>{{cssref}}</div> + +<p><a href="/zh-CN/docs/CSS">CSS</a> <a href="/zh-CN/docs/Web/CSS/Media_Queries/Using_media_queries#Media_features">媒体属性</a><strong>屏幕方向</strong>(<strong><code>orientation</code></strong>)可用于测试视口 {{glossary("viewport")}}(或者对于<a href="/zh-CN/docs/Web/CSS/Paged_media">分页媒体</a>而言的页面框盒)的横纵方向。</p> + +<div class="note"> +<p><strong>注意:</strong>此属性不等价于<span class="syntaxbox"><em>设备</em></span>的屏幕旋转方向。在许多设备上,当屏幕方向为纵向时,打开软键盘将导致视口 viewport 的宽度大于高度,从而导致浏览器突然改用横向样式,而不是保持纵向。</p> +</div> + +<h2 id="语法">语法</h2> + +<p><code>orientation</code> 属性被指定为下列关键字值中的任意一个。</p> + +<h3 id="关键字值">关键字值</h3> + +<dl> + <dt><code>portrait</code></dt> + <dd>viewport 处于纵向,即高度大于等于宽度。</dd> + <dt><code>landscape</code></dt> + <dd>viewport 处于横向,即宽度大于高度。</dd> +</dl> + +<h2 id="例子">例子</h2> + +<h3 id="HTML">HTML</h3> + +<pre class="brush: html"><div>Box 1</div> +<div>Box 2</div> +<div>Box 3</div> +</pre> + +<h3 id="CSS">CSS</h3> + +<pre class="brush: css">body { + display: flex; +} + +div { + background: yellow; +} + +@media (orientation: landscape) { + body { + flex-direction: row; + } +} + +@media (orientation: portrait) { + body { + flex-direction: column; + } +}</pre> + +<h3 id="结果">结果</h3> + +<p>{{EmbedLiveSample("Example")}}</p> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">备注</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('CSS4 Media Queries', '#orientation', 'orientation')}}</td> + <td>{{Spec2('CSS4 Media Queries')}}</td> + <td>No change.</td> + </tr> + <tr> + <td>{{SpecName('CSS3 Media Queries', '#orientation', 'orientation')}}</td> + <td>{{Spec2('CSS3 Media Queries')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("css.at-rules.media.orientation")}}</p> |