CSS Tutorial
CSS Advanced
CSS Responsive
CSS Grid
CSS Flex-Responsive
Responsive Flexbox
Media queries can be used to create different layouts for different screen sizes and devices.
HTML
				
					The "flex-direction: row;" stacks the flex items horizontally (from left to right).
The "flex-direction: column;" stacks the flex items vertically (from top to bottom).
Resize the browser window to see that the direction changes when the 
screen size is 800px wide or smaller.
  1
  2
			
		CSS
				
					* {
  box-sizing: border-box;
}
.flex-container {
  display: flex;
  flex-direction: row;
  font-size: 30px;
  text-align: center;
}
.flex-item-left {
  background-color: #f1f1f1;
  padding: 10px;
  flex: 50%;
}
.flex-item-right {
  background-color: dodgerblue;
  padding: 10px;
  flex: 50%;
}
/* Responsive layout - makes a one column-layout instead of two-column layout */
@media (max-width: 800px) {
  .flex-container {
    flex-direction: column;
  }
} 
				
			
		Output
The "flex-direction: row;" stacks the flex items horizontally (from left to right).
The "flex-direction: column;" stacks the flex items vertically (from top to bottom).
Resize the browser window to see that the direction changes when the screen size is 800px wide or smaller.
Another method is by changing the percentage of the flex property of the flex items to make different layouts for different screen sizes. The flex-wrap: wrap; needs to be included on the flex container for this example to work:
HTML
				
					In this example, we change the percentage of flex to create different layouts for different screen sizes.
Resize the browser window to see that the direction changes when the 
screen size is 800px wide or smaller.
  1
  2
			
		CSS
				
					* {
  box-sizing: border-box;
}
.flex-container {
  display: flex;
  flex-wrap: wrap;
  font-size: 30px;
  text-align: center;
}
.flex-item-left {
  background-color: #f1f1f1;
  padding: 10px;
  flex: 50%;
}
.flex-item-right {
  background-color: dodgerblue;
  padding: 10px;
  flex: 50%;
}
/* Responsive layout - makes a one column-layout instead of a two-column layout */
@media (max-width: 800px) {
  .flex-item-right, .flex-item-left {
    flex: 100%;
  }
} 
				
			
		Output
In this example, we change the percentage of flex to create different layouts for different screen sizes.
Resize the browser window to see that the direction changes when the screen size is 800px wide or smaller.
Responsive Website using Flexbox
Using flexbox to make a responsive website, that has flexible navigation bar and flexible content:
HTML
				
					
  Resize the browser window to see the responsive effect.
  My Website
  With a flexible layout.
  
    About Me
    Photo of me:
    Image
    Some text about me in culpa qui officia deserunt mollit anim..
    More Text
    Lorem ipsum dolor sit ame.
    Image
    Image
    Image
  
  
    TITLE HEADING
    Title description, Dec 7, 2017
    Image
    Some text..
    Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.
    
    TITLE HEADING
    Title description, Sep 2, 2017
    Image
    Some text..
    Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.
  
  Footer
 
				
			
		CSS
				
					* {
  box-sizing: border-box;
}
/* Style the body */
body {
  font-family: Arial;
  margin: 0;
}
/* Header/logo Title */
.header {
  padding: 60px;
  text-align: center;
  background: #1abc9c;
  color: white;
}
/* Style the top navigation bar */
.navbar {
  display: flex;
  background-color: #333;
}
/* Style the navigation bar links */
.navbar a {
  color: white;
  padding: 14px 20px;
  text-decoration: none;
  text-align: center;
}
/* Change color on hover */
.navbar a:hover {
  background-color: #ddd;
  color: black;
}
/* Column container */
.row {  
  display: flex;
  flex-wrap: wrap;
}
/* Create two unequal columns that sits next to each other */
/* Sidebar/left column */
.side {
  flex: 30%;
  background-color: #f1f1f1;
  padding: 20px;
}
/* Main column */
.main {
  flex: 70%;
  background-color: white;
  padding: 20px;
}
/* Fake image, just for this example */
.fakeimg {
  background-color: #aaa;
  width: 100%;
  padding: 20px;
}
/* Footer */
.footer {
  padding: 20px;
  text-align: center;
  background: #ddd;
}
/* Responsive layout - when the screen is less than 700px wide, make the two columns stack on top of each other instead of next to each other */
@media screen and (max-width: 700px) {
  .row, .navbar {   
    flex-direction: column;
  }
} 
				
			
		Output
Resize the browser window to see the responsive effect.
My Website
With a flexible layout.
About Me
Photo of me:
Some text about me in culpa qui officia deserunt mollit anim..
More Text
Lorem ipsum dolor sit ame.
TITLE HEADING
Title description, Dec 7, 2017
Some text..
Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.
TITLE HEADING
Title description, Sep 2, 2017
Some text..
Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.
