Flex changing positions on resizing window

1–2 minutes

read

Flex changing positions on resizing window

The main css code for the position changing is :

@media all and (min-width: 750px) {
 .nav {text-align:left;flex: 1 auto;order:1;}
 .article {flex:5 0px;order:2;}
 footer {order:3;}
}

JS FIDDLE LINK …. CLICK HERE TO CHECK

CSS

.container {
 display: flex; 
 flex-flow: row wrap;
 text-align: center;
}

.container > * {
 padding: 15px;
 flex: 1 100%;
}
header {background: black;color:white;}
footer {background: #aaa;color:white;}
.nav {background:#eee;}




.article {
 text-align: left;
}

.nav ul {
 list-style-type: none;
 padding: 0;
}
.nav ul a {
 text-decoration: none;
}




@media all and (min-width: 750px) {
 .nav {text-align:left;flex: 1 auto;order:1;}
 .article {flex:5 0px;order:2;}
 footer {order:3;}
}

Here order gives the position of respective header ,footer and main screen.

The @media rule is used in media queries to apply different styles for different media types/devices.

Media queries can be used to check many things, such as:

  • width and height of the viewport
  • width and height of the device
  • orientation (is the tablet/phone in landscape or portrait mode?)
  • resolution

Using media queries are a popular technique for delivering a tailored style sheet (responsive web design) to desktops, laptops, tablets, and mobile phones.

You can also use media queries to specify that certain styles are only for printed documents or for screen readers (mediatype: print, screen, or speech).

In addition to media types, there are also media features. Media features provide more specific details to media queries, by allowing to test for a specific feature of the user agent or display device. For example, you can apply styles to only those screens that are greater, or smaller, than a certain width.

 

Leave a comment