Tradução em progresso.

A propriedade CSS align-self alinha itens-flex da linha flex alvo, sobreescrevendo o valor align-items. Se alguma dos eixos das margens do dado item está estabelecido como auto, então align-self é ignorado.

A propriedade não se aplica a caixas block-level, ou células de tabela.

Sintaxe

/* valores de palavras-chave */ 
align-self: auto; 
align-self: normal; 

/* Alinhamento de posicionamento */ 
/* align-self não recebe valores left e right */
align-self: center; /* Coloca o item em torno do centro */ 
align-self: start; /* Coloca o item no início */ 
align-self: end; /* Coloca o item no fim */ 
align-self: self-start; /* Alinha o item flush no início */ 
align-self: self-end; /* Alinha o item flush no fim */ 
align-self: flex-start; /* Coloca o item flex no início */ 
align-self: flex-end; /* Coloca o item flex no fim */ 

/* Alinhamento a partir da baseline */ 
align-self: baseline; 
align-self: first baseline; 
align-self: last baseline; 
align-self: stretch; /* Estica itens de tamanho 'auto' para encaixar no container */ 

/* Alinhamento com Oveflow */ 
align-self: safe center; 
align-self: unsafe center; 

/* Valores globais */ 
align-self: inherit; 
align-self: initial; 
align-self: unset;

Valores

auto
O valor align-items é originado do valor de seu pai.
normal
O efeito dessa palavra-chave depende do modo de layout em que nos encontramos:
  • Em layouts absolutamente posicionados, a palavra-chave se comporta como start em caixas absolutamente posicionadas replaced, e como stretch em caixas absolutamente posicionadas all other.
  • Em posição estática de layouts absolutamente posicionados, a palavra-chave se comporta como stretch.
  • Para itens-flex, a palavra-chave se comporta como stretch.
  • Para itens-grid, essa palavra-chave leva ao comportamento similar ao de stretch, com exceção de caixas com aspect ratio ou tamanhos intrínsecos onde se comportam como start.
  • A propriedade não se aplica para caixas block-level, e para células de tabela.
self-start
Alinha os itens de maneira a mesclar a borda do alinhamento do container correspondente com o lado inicial do item no eixo.
self-end
Alinha os itens de maneira a mesclar a borda do alinhamento do container correspondente com o lado final do item no eixo.
flex-start
A borda da margem inicial do item flex é mesclada com a borda inicial da linha.
flex-end
A borda da margem fim do item flex é mesclada com a borda fim da linha.
center
A caixa-margem do item flex é centralizada ao longo da linha no eixo transversal. Se o tamanho do item é superior to container flex, então ele irá transbordar de maneira equivalente em ambas direções.
baseline
first baseline

last baseline
Specifies participation in first- or last-baseline alignment: aligns the alignment baseline of the box’s first or last baseline set with the corresponding baseline in the shared first or last baseline set of all the boxes in its baseline-sharing group.
The fallback alignment for first baseline is start, the one for last baseline is end.
stretch
Caso o tamanho combinado dos itens ao longo do eixo transversal seja menor do que o tamanho do container de alinhamento, e caso o tamanho do item segue o estilo auto, seu tamanho cresce igualmente (mas não proporcionalmente), enquanto que ainda respeitando as restrições impostas por max-height/max-width (ou a funcionalidade equivalente), de maneira que o tamanho combinado de todos itens tamanho-auto preencha exatamente o container de alinhamento ao longo do eixo transversal.
safe
Caso o tamanho do item supere o alinhamento do container, o item é alinhado como se o modo de alinhamento fosse start.
unsafe
Independente dos tamanhos relativos do item e do alinhamento do container, o valor do alinhmento dado é mantido.

Sintaxe formal

auto | normal | stretch | <baseline-position> | <overflow-position>? <self-position>

where
<baseline-position> = [ first | last ]? baseline
<overflow-position> = unsafe | safe
<self-position> = center | start | end | self-start | self-end | flex-start | flex-end

Exemplo

HTML

<section>
  <div>Item #1</div>
  <div>Item #2</div>
  <div>Item #3</div>
</section>

CSS

section {
  display: flex;
  align-items: center;
  height: 120px;
  background: beige;
}

div {
  height: 60px;
  background: cyan;
  margin: 5px;
}

div:nth-child(3) {
  align-self: flex-end;
  background: pink;
}

Resultado

Especificações

Especificação Status Comentário
CSS Box Alignment Module Level 3
The definition of 'align-self' in that specification.
Rascunho atual Atualiza para últimas definições de sintaxe.
CSS Flexible Box Layout Module
The definition of 'align-self' in that specification.
Candidata a Recomendação Definição inicial.

Initial valueauto
Aplica-se aflex items, grid items, and absolutely-positioned boxes
Inheritednão
Midiavisual
Computed valueauto computes to itself on absolutely-positioned elements, and to the computed value of align-items on the parent (minus any legacy keywords) on all other boxes, or start if the box has no parent. Its behavior depends on the layout model, as described for justify-self. Otherwise the specified value.
Animation typediscrete
Canonical orderthe unique non-ambiguous order defined by the formal grammar

Compatibilidade de navegador

Suporte em Flex layout

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 36
Full support 36
Partial support 29
Notes
Notes Older versions of the specification treat absolute positioned children as though they are a 0 by 0 flex item. Later specification versions take the children out of the flow and set their positions based on align and justify properties. Chrome implements the new behavior beginning with Chrome 52.
Full support 21
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Edge Full support 12Firefox Full support 20
Notes
Full support 20
Notes
Notes Before Firefox 27, only single-line flexbox is supported.
No support 18 — 20
Disabled
Disabled From version 18 until version 20 (exclusive): this feature is behind the layout.css.flexbox.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Full support 49
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Full support 48
Prefixed Disabled
Prefixed Implemented with the vendor prefix: -webkit-
Disabled From version 48: this feature is behind the layout.css.prefixes.webkit preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE Full support 11Opera Full support 12.1Safari No support NoWebView Android Full support 37
Full support 37
Partial support 4.4
Notes
Notes Older versions of the specification treat absolute positioned children as though they are a 0 by 0 flex item. Later specification versions take the children out of the flow and set their positions based on align and justify properties. Chrome implements the new behavior beginning with Chrome 52.
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Chrome Android Full support 36
Full support 36
Partial support 29
Notes
Notes Older versions of the specification treat absolute positioned children as though they are a 0 by 0 flex item. Later specification versions take the children out of the flow and set their positions based on align and justify properties. Chrome implements the new behavior beginning with Chrome 52.
Full support 25
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Edge Mobile Full support Yes
Full support Yes
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Firefox Android Full support YesOpera Android No support NoSafari iOS No support NoSamsung Internet Android ?
start and endChrome ? Edge ? Firefox Full support YesIE ? Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
left and rightChrome ? Edge ? Firefox Full support 52IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 52Opera Android ? Safari iOS ? Samsung Internet Android ?
baselineChrome ? Edge ? Firefox Full support YesIE ? Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support YesOpera Android ? Safari iOS ? Samsung Internet Android ?
first baseline and last baselineChrome ? Edge ? Firefox Full support 52IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 52Opera Android ? Safari iOS ? Samsung Internet Android ?
stretchChrome ? Edge ? Firefox Full support 52IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 52Opera Android ? Safari iOS ? Samsung Internet Android ?
safe and unsafeChrome No support NoEdge No support NoFirefox Full support 63IE No support NoOpera No support NoSafari ? WebView Android ? Chrome Android ? Edge Mobile No support NoFirefox Android Full support 63Opera Android ? Safari iOS ? Samsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

Suporte em Grid layout

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 57Edge Full support 16Firefox Full support 52IE Partial support 10
Prefixed Notes
Partial support 10
Prefixed Notes
Prefixed Implemented with the vendor prefix: -ms-
Notes IE10 and 11 have the property -ms-grid-column-align which acts in a similar way to align-self.
Opera Full support 44Safari Full support 10.1WebView Android Full support 57Chrome Android Full support 52Edge Mobile Full support YesFirefox Android Full support 52Opera Android Full support 44Safari iOS Full support 10.3Samsung Internet Android Full support 6.2

Legend

Full support  
Full support
Partial support  
Partial support
See implementation notes.
See implementation notes.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

Veja também

Etiquetas do documento e colaboradores

Colaboradores desta página: rbuzatto
Última atualização por: rbuzatto,