CSS align-self 属性 在弹性容器、div中设置元素位置

 2022-05-29    492  

CSS align-self 属性 在弹性容器、div中设置元素位置

实例

CSS align-self 属性 在弹性容器、div中设置元素位置

把弹性元素内的项目之一居中对齐:

#myBlueDiv {
  align-self: center;
}

定义和用法

align-self 属性指定弹性容器内所选项目的对齐方式。

注意:align-self 属性将覆盖弹性容器的 align-items 属性。

默认值: auto
继承:
动画制作: 不支持。请参阅:动画相关属性。
版本: CSS3
JavaScript   语法: object.style.alignSelf="center"

CSS 语法

align-self: auto|stretch|center|flex-start|flex-end|baseline|initial|inherit;

属性值

描述
auto 默认。元素继承其父容器的   align-items 属性,如果没有父容器,则为 "stretch"。
stretch 定位元素以适合容器。
center 元素位于容器的中央。
flex-start 元素位于容器的开头。
flex-end 元素位于容器的末端。
baseline 元素被定位到容器的基线。
initial 将此属性设置为其默认值。参阅 initial。
inherit 从其父元素继承此属性。参阅 inherit。


红色
蓝色
有更多内容的绿色 div

  •  标签:  
  • css
  •  

原文链接:https://77isp.com/post/1020.html

=========================================

https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。