Movatterモバイル変換


[0]ホーム

URL:


  1. 面向开发者的 Web 技术
  2. CSS:层叠样式表
  3. CSS 参考
  4. Properties
  5. margin-inline-start

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in EnglishAlways switch to English

margin-inline-start

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2020年1月⁩.

* Some parts of this feature may have varying levels of support.

margin-inline-startCSS 属性定义元素的逻辑行首外边距,根据元素的书写模式、行内方向和文本朝向映射为实体的外边距。它根据writing-modedirectiontext-orientation 属性的值对应于margin-topmargin-rightmargin-bottommargin-left 属性。

尝试一下

margin-inline-start: 20px;writing-mode: horizontal-tb;
margin-inline-start: 20px;writing-mode: vertical-rl;
margin-inline-start: 20%;writing-mode: horizontal-tb;direction: rtl;
<section>  <div>    <div>One</div>    <div>Two</div>    <div>Three</div>  </div></section>
#container {  width: 300px;  height: 200px;  display: flex;  align-content: flex-start;  justify-content: flex-start;}.col {  width: 33.33%;  border: solid #ce7777 10px;  background-color: #2b3a55;  color: white;  flex-shrink: 0;}#example-element {  border: solid 10px #ffbf00;  background-color: #2b3a55;  unicode-bidi: bidi-override;}

语法

css
/* <length> 值 */margin-inline-start: 10px; /* 绝对长度 */margin-inline-start: 1em; /* 相对于文字大小 */margin-inline-start: 5%; /* 相对于最近区块容器的宽度 *//* 关键词值 */margin-inline-start: auto;/* 全局值 */margin-inline-start: inherit;margin-inline-start: initial;margin-inline-start: revert;margin-inline-start: unset;

这个属性与margin-block-startmargin-block-endmargin-inline-end 属性相关,它们均定义元素的其他边距。

margin-inline-start 属性接受与margin-left 属性相同的值。

形式定义

初始值0
适用元素same asmargin
是否是继承属性
Percentagesdepends on layout model
计算值if specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise,auto
动画类型alength

形式语法

margin-inline-start =
<'margin-top'>

<margin-top> =
<length-percentage>|
auto|
<anchor-size()>

<length-percentage> =
<length>|
<percentage>

<anchor-size()> =
anchor-size([<anchor-name>||<anchor-size>]? ,<length-percentage>?)

<anchor-name> =
<dashed-ident>

<anchor-size> =
width|
height|
block|
inline|
self-block|
self-inline

示例

设置逻辑行首外边距

HTML

html
<div>  <p>示例文本</p></div>

CSS

css
div {  background-color: yellow;  width: 120px;  height: 120px;}.exampleText {  writing-mode: vertical-lr;  margin-inline-start: 20px;  background-color: #c8c800;}

结果

规范

Specification
CSS Logical Properties and Values Level 1
# margin-properties

浏览器兼容性

参见

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp