CSS Flexbox: Use the align-self Property

he final property for flex items is align-self. This property allows you to adjust each item's alignment individually, instead of setting them all at once. This is useful since other common adjustment techniques using the CSS properties float, clear, and vertical-align do not work on flex items.

align-self accepts the same values as align-items :flex-start,center,flex-end,stretch,baseline and will override any value set by the align-items property.
consider these boxes in flex container

<style>
  #box-container {
    display: flex;
    height: 500px;
    flex-direction:row;
    background: gray;

  }
  #box-1 {
    background-color: dodgerblue;
    height: 200px;
    width: 200px;
  }

  #box-2 {
    background-color: orangered;
    height: 200px;
    width: 200px;
  }
</style>

<br />
<div id="box-container">
<div id="box-1">
box1</div>
<div id="box-2">
box2</div>
</div>


box1
box2
Lets add the CSS property align-self to both #box-1 and #box-2. Give #box-1 a value of center and give #box-2 a value of flex-end.

box1
box2


<style>
  #box-container {
    display: flex;
    height: 500px;
} #box-1 { background-color: dodgerblue; align-self:center; height: 200px; width: 200px; } #box-2 { background-color: orangered; align-self:flex-end; height: 200px; width: 200px; } </style> <div id="box-container"> <div id="box-1"></div> <div id="box-2"></div> </div>
source

Comments

Popular posts from this blog

ES6 : 5 Prevent Object Mutation

ES6: 1 Explore Differences Between the var and let Keywords

CSS Grid: Reduce Repetition Using the repeat Function