Partager via


align-items property

Specifies the alignment value (perpendicular to the layout axis defined by the IHTMLCSSStyleDeclaration3::flexdirection property) of flex items in the flex container.

Note   As of Internet Explorer 11 the Microsoft vendor prefix ("-ms-") version of this property is no longer supported. Instead use the non-prefixed name align-items, which is preferred for better standards compliance and future compatibility.

 

This property is read/write.

 

Syntax

HRESULT put_align-items(
  [in]  DOMString val
);

HRESULT get_align-items(
  [out] DOMString **ptr
);

Property values

Type: DOMString

String format

stretch | flex-start | flex-end | center | baseline

CSS information

Applies To flex containers
Media visual
Inherited no
Initial Value stretch

Standards information

Remarks

Prior to IE11, this property was known as -ms-flex-align. For more information on these compatibility changes, see Flexible box ("Flexbox") layout updates.

Typically, the main axis follows the same direction as text—for example, if the text in your flexbox runs left to right, the main axis is the horizontal axis.

Be aware that these are IHTMLCurrentStyle2::writingMode and IHTMLRuleStyle2::direction dependent keywords. The starting and ending edges of the flex container and flex items depend on the layout direction. For instance, for a left-to-right layout, the starting edge is the left edge of the flex container, for a top-to-bottom layout the starting edge is the top edge and so on. Likewise, the ending edge of a flex item is the right edge in a left-to-right layout, the bottom edge in a top-to-bottom layout, and so on.

The image below shows all of the values for the IHTMLCSSStyleDeclaration3::align-items property.

Examples

In this example showing the IHTMLCSSStyleDeclaration3::align-items property, the flex container contains three flex items.

<div id="flexContainer">
   <div id="item1">1</div>
   <div id="item2">2</div>
   <div id="item3">3</div>
</div>

The following example sets IHTMLCSSStyleDeclaration3::align-items to center. In this example, each flex item is centered between the leading and trailing edges of the flex container, and the remaining space, perpendicular to the layout axis, is evenly distributed before and after each flex item.

#flexContainer {
   height: 100px;
   border: 1px solid #949494;
   display: flex;
   flex-direction: row;
   align-items: center;
}
#item1 {
   background: #66CC33;
   width: 100px;
}
#item2 {
   background: #0099FF;
   width: 100px;
}
#item3 {
   background:#66CC33;
   width: 100px;
}

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll