Media Queries in CSS

 <!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="CSS/Media_Queries.css">
    <title>Media Queries</title>
</head>

<body>
    <div class="box" id="box-1">Mai ek iPhone hoon</div>
    <div class="box" id="box-2">Mai ek Tablet hoon</div>
    <div class="box" id="box-3">Mai ek desktop computer hoon</div>
    <div class="box" id="box-4">Mai ek widescreen computer hoon</div>
</body>

</html>




Below File is CSS/Media_Queries.css File.
.box {
    font-size: 72px;
    text-align: center;
    background-color: #ff0000;
    color: #ffffff;
    display: none;
}

@media (max-width: 500px) {
    #box-1 {
        display: block;
        color: #000000;
        background-color: #00ffff;
    }
}

@media (min-width: 300px) and (max-width: 500px) {
    #box-2 {
        display: block;
        background-color: #8a2be2;
    }
}

@media (min-width: 500px) and (max-width: 800px) {
    #box-3 {
        display: block;
        color: #000000;
        background-color: #ffff00;
    }
}

@media (min-width: 800px) {
    #box-4 {
        display: block;
        background-color: #008000;
    }
}













Comments