python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
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

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions