inset-inline
CSS 属性 inset-inline
定义了元素的逻辑行首和行末偏移,并根据元素的书写模式、行内方向和文本朝向对应至实体偏移。根据 writing-mode
、direction
和 text-orientation
所定义的值,此属性对应于 top
和 bottom
,或者 right
和 left
属性。
尝试一下
属性构成
此属性为下列 CSS 属性的简写属性:
语法
/* 长度值 */
inset-inline: 3px 10px;
inset-inline: 2.4em 3em;
inset-inline: 10px; /* 应用于行首和行末 */
/* 包含块的宽度或高度的百分比 */
inset-inline: 10% 5%;
/* 关键词值 */
inset-inline: auto;
/* 全局值 */
inset-inline: inherit;
inset-inline: initial;
inset-inline: revert;
inset-inline: revert-layer;
inset-inline: unset;
取值
inset-inline
属性的取值与 left
属性相同。
形式定义
初始值 | as each of the properties of the shorthand:
|
---|---|
适用元素 | positioned elements |
是否是继承属性 | 否 |
Percentages | logical-width of containing block |
计算值 | as each of the properties of the shorthand:
|
Animation type | a length, percentage or calc(); |
形式语法
示例
设置行首和行末偏移
HTML
<div>
<p class="exampleText">示例文本</p>
</div>
CSS
div {
background-color: yellow;
width: 120px;
height: 120px;
}
.exampleText {
writing-mode: vertical-lr;
position: relative;
inset-inline: 20px 50px;
background-color: #c8c800;
}
结果
规范
Specification |
---|
CSS Logical Properties and Values Level 1 # propdef-inset-inline |
浏览器兼容性
BCD tables only load in the browser
参见
- 对应的实体属性:
top
、right
、bottom
和left
- 对应的实体简写属性:
inset
- 对应的块向简写属性:
inset-block
writing-mode
、direction
、text-orientation