Week 4 Complete
Week 4 Complete
• Responsive web design makes your web page look good on all devices.
• It uses the @media rule to include a block of CSS properties only if a certain
condition is true.
• A media query consists of a media type and an expression to check for certain
conditions of a particular media feature. The most commonly used media
feature is width.
Media Queries Examples
{
body {
background-color: lightblue;
}
}
Media Queries Examples (Example 1)
Media Queries Examples (Example 1)
Media Queries Examples 2
• Example 2:The following example shows a menu that will float to the left
of the page if the viewport is 480 pixels wide or wider (if the viewport is
less than 480 pixels, the menu will be on top of the content):
<!DOCTYPE html>
<html>
<head>
<style>
.flex-container {
display: -webkit-flex;
display: flex;
width: 400px;
height: 250px;
background-color: lightgrey;
}
Flexbox (Example continue)
.flex-item {
background-color: cornflowerblue;
width: 100px;
height: 100px;
margin: 10px;
}
</style>
</head>
<body>
<div class="flex-container">
<div class="flex-item">flex item 1</div>
<div class="flex-item">flex item 2</div>
<div class="flex-item">flex item 3</div>
</div>
</body>
</html>
Flexbox (Example out put)
Flexbox Properties
Property Description
flex-direction Specifies the direction of the flexible items inside a flex container
justify-content Horizontally aligns the flex items when the items do not use all available
space on the main-axis
align-items Vertically aligns the flex items when the items do not use all available
space on the cross-axis
flex-wrap Specifies whether the flex items should wrap or not, if there is not
enough room for them on one flex line
order Specifies the order of a flexible item relative to the rest of the flex items
inside the same container