CSS Align Content Property Example [How To]

CSS Align Self Property Example [How To]

“How to write align-self property using css”?

The Align Self property is a sub property of “Flexible Box” and it is used to overrides the container's “align-items” property.


Align Content Property Accepts 5 different values and it will be the same as “align-items”.
1.      centre,
2.      flex-end,
3.      flex-start,  
4.      stretch and
5.      baseline

CSS Syntax:-

.align-self {
    width: 300px;
    height: 200px;
    border: 1px solid black;
    display: -webkit-flex; 
    -webkit-align-items: flex-start;
    display: flex;
    align-items: flex-start;
}

.align-self div {
    -webkit-flex: 1; 
    flex: 1;
}

.self {
    -webkit-align-self: center;
    align-self: center;
}

Exaample as,

<!DOCTYPE html>
<html>
<head>
<style> 
.align-self {
    width: 300px;
    height: 200px;
    border: 1px solid black;
    display: -webkit-flex; 
    -webkit-align-items: flex-start;
    display: flex;
    align-items: flex-start;
}

.align-self div {
    -webkit-flex: 1; 
    flex: 1;
}

.self {
    -webkit-align-self: center;
    align-self: center;
}
</style>
</head>
<body>

<div class="align-self">
  <div style="background-color:lightblue;" class="self">BLUE</div>  
    <div style="background-color:coral;">RED</div>
  <div style="background-color:lightgreen;">AND SO ON..</div>
</div>
</body>
</html>

The live demo Result,

BLUE
RED
AND SO ON..

ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Google Amazon and Flipkart Book Store!

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.
ASK Questions
SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book