Day 22: flexbox

 flex-diection:

flex-wrap: wrap;

justify-content: flex-start;


  1. Flexbox property :
  • Inline-flex : 
  • To make a flex container as an inline-level flex element, use the following syntax : 

container 

{

 display: inline-flex;

}

Using inline-flex, an element is displayed on the same line as the others. Since it follows the height and width of the line of which it is a part, specifying any height and width parameters will be useless, whereas display:flex, takes up the entire available width.

Example :

       
       

1. Using display:inline-flex (takes up limited width)

2. Using display: flex (takes up entire available width)




Other flex properties to explore :

    1. Flex-direction : Defines direction of flex items present inside the flex container.

Values :

      1. row
      2. row-reverse
      3. column
      4. column-reverse

Example :

Flex-direction : column-reverse

gives the following output :

Code :

    <!DOCTYPE html>

    <html>

    <head>

    <style>

        .container {

        displayinline-flex;

        flex-directioncolumn-reverse;

        background-colorrgb(220165165);

        padding10px;

        }

       

        .item {

        background-colorrgba(2552552550.8);

        border1px dashed rgba(631872000.8);

        text-aligncenter;

        padding20px;

        font-size30px;

        }

    </style>

    </head>

    <body>

   

    <div class="container">

    <div class="item">flex item 1</div>

    <div class="item">flex item 2</div>

    <div class="item">flex item 3</div>  

    <div class="item">flex item 4</div>

    <div class="item">flex item 5</div>

    <div class="item">flex item 6</div>  

    <div class="item">flex item 7</div>

    <div class="item">flex item 8</div>

    <div class="item">flex item 9</div>  

    </div>

   

    </body>

    </html>

 



Try out the various other values for flex-direction and observe the output.

 

  1. Flex-wrap : wraps the items as per the value assigned to flex-wrap property.

 Values to try :

    1. nowrap
    2. wrap
    3. wrap-reverse

3. Justify-content : 

    Values to try :

    1. flex-start
    2. flex-end
    3. start
    4. end
    5. left
    6. right
    7. center
    8. space-between
    9. space-around
    10. space-evenly

 


Comments

Popular posts from this blog

else-if condition in if-else statements: Concatenation in JavaScript :

Day 9: CSS - Font Formate

Day 28: CSS Animation, CSS Transition Animation Box size