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 janvier 2020.
* Some parts of this feature may have varying levels of support.
Expérimental: Il s'agit d'une technologie expérimentale.
Vérifiez attentivement le tableau de compatibilité des navigateurs avant de l'utiliser en production.
La propriété margin-inline-start
définit la marge logique appliquée au début des éléments en ligne, selon le mode d'écriture, la directionalité et l'orientation du texte. Selon les valeurs utilisées pour writing-mode
, direction
, and text-orientation
, elle peut correspondre à margin-top
, margin-right
, margin-bottom
ou margin-left
.
Exemple interactif
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 id="default-example">
<div id="container">
<div class="col">One</div>
<div class="col transition-all" id="example-element">Two</div>
<div class="col">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;
}
Cette propriété est à rapprocher de margin-block-start
, margin-block-end
et de margin-inline-end
qui définissent les autres marges appliquées à l'élément.
Syntaxe
/* Valeurs de longueur */
/* Type <length> */
margin-inline-start: 10px; /* Une longueur absolue */
margin-inline-start: 1em; /* Une longueur relative à la taille du texte */
margin-inline-start: 5%; /* Une largeur relative à la
largeur du bloc englobant */
/* Valeurs avec un mot-clé */
margin-inline-start: auto;
/* Valeurs globales */
margin-inline-start: inherit;
Valeurs
La propriété margin-inline-start
peut prendre les mêmes valeurs que la propriété margin-left
.
Définition formelle
Valeur initiale | 0 |
---|---|
Applicabilité | identique à margin |
Héritée | non |
Pourcentages | dépend du modèle en couches |
Valeur calculée | si spécifié par une longueur, la valeur absolue correspondante; si spécifié par un pourcentage, la valeur telle que spécifiée; sinon, auto |
Type d'animation | une longueur |
Syntaxe formelle
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
Exemples
>CSS
div {
background-color: yellow;
width: 120px;
height: 120px;
}
.exemple {
writing-mode: vertical-lr;
margin-inline-start: 20px;
background-color: #c8c800;
}
HTML
<div>
<p class="exemple">Texte d'exemple</p>
</div>
Résultat
Spécifications
Specification |
---|
CSS Logical Properties and Values Level 1> # margin-properties> |
Compatibilité des navigateurs
Loading…
Voir aussi
-
Les propriétés physiques correspondantes :
margin-inline-end
writing-mode
direction
text-orientation