CSS正文宽度100% [英] CSS body width 100 percent

查看:40
本文介绍了CSS正文宽度100%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是CSS新手,在理解以下代码的工作方式时遇到问题:

I am new to CSS and I have a problem understanding how the following piece of code works:

body {
width: 100%;
height: 100%;
}

我了解到,当您指定 width:100%时.

I understand that when you specify width: 100%.

元素的总宽度将为其包含块的100%.包含块的正文是html,但是我的问题是html的大小是多少?

The element's total width will be 100% of it's containing block. The body containing block is html, but my question is what is the size of the html?

HTML的大小取决于用户监视器的分辨率?

如果是这种情况,那么当我创建一个站点并且我占用户百分比时,所有元素的大小会根据监视器的分辨率而有所不同吗?

If this is the case then when I create a site and I user percent all the elements size will vary depending on the monitor resolution?

我不确定我是否完全理解该概念,因此将不胜感激.谢谢!

I am not sure if I fully understand the concept so any help will be greatly appreciated. Thanks!

推荐答案

HTML元素实际上是 viewport (浏览器窗口可见区域), body 元素是实际的页面内容.

The HTML element is effectively the viewport (browser window visible area) the body element is the actual content of the page.

有关此内容的更多信息:

  1. html和body元素是父/子关系中不同的块级实体.

  1. The html and body elements are distinct block-level entities, in a parent/child relationship.

html元素的高度和宽度由浏览器窗口控制.

The html element's height and width are controlled by the browser window.

这是html元素(默认情况下)具有:auto:溢出,导致在需要时显示滚动条.

It is the html element which has (by default) overflow:auto, causing scrollbars to appear when needed.

body元素(默认情况下)是position:static,这意味着它的定位子元素相对于html定位元素的坐标系.

The body element is (by default) position:static, which means that positioned children of it are positioned relative to the html element's coordinate system.

在几乎所有现代浏览器中,从页面边缘开始的内置偏移都是通过body元素上的边距而不是填充来应用的在html元素上.

In almost all modern browsers, the built-in offset from the edge of the page is applied through a margin on the body element, not padding on the html element.

HTML

HTML根元素(< html> )表示HTML或XHTML的根文档.所有其他元素必须是该元素的后代.

The HTML root element (<html>) represents the root of an HTML or XHTML document. All other elements must be descendants of this element.

正文

HTML正文(< body> )元素表示HTML的主要内容文档.文档中只有一个元素.

The HTML Body (<body>) element represents the main content of an HTML document. There is only one element in a document.

这篇关于CSS正文宽度100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆