<length-percentage>
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
CSS <length-percentage>
数据类型表示一个值,该值可以是 <length>
或 <percentage>
。
语法
参考 <length>
和 <percentage>
的文档以具体了解该类型允许使用的语法。
形式语法
<length-percentage> =
<length> |
<percentage>
示例
length-percentage 示例
以下简单示例描述了使用 <length-percentage>
值的一些属性。
HTML
html
<p>你可以在很多地方使用百分比(percentage)和长度(length)值。</p>
CSS
css
p {
/* length-percentage 示例 */
width: 75%;
height: 200px;
margin: 3rem;
padding: 1%;
border-radius: 10px 10%;
font-size: 250%;
line-height: 1.5em;
/* 长度值示例 */
text-shadow: 1px 1px 1px red;
border: 5px solid red;
letter-spacing: 3px;
/* 百分比值示例 */
text-size-adjust: 20%;
}
结果
在 calc() 中使用
规范
Specification |
---|
CSS Values and Units Module Level 4 # mixed-percentages |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
<length-percentage> |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.