How To Define Variables In Media Queries Using CSS

admin_img Posted By Bajarangi soft , Posted On 07-11-2020

In CSS Media queries are used to display fontsize for specified window screen .SO today we discuss how to define variable in media query.

How To Define Variables In Media Queries Using CSS

Complete Code For Defining Variables In Media Queries Using CSS

<!DOCTYPE html>
<html>
<head>
    <title>How To Define Variables In Media Queries Using CSS</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
</head>

<style>

    :root {
        --blue: #1e90ff;
        --pink: #df9fbf;
        --white: #ffffff;
        --green: #408000;
    }

    body {
        background-color: var(--pink);
    }

    h2 {
        border-bottom: 2px solid var(--blue);
    }

    .bg_container {
        color: var(--blue);
        background-color: var(--white);
        padding: 15px;
        font-size: var(--fontsize);
    }

    @media screen and (min-width: 450px) {
        .bg_container {
            --fontsize: 50px;
        }
    }
</style>

<body>
<br/><br/>
<div class="container">
    <br>
    <div class="text-center">
        <h1 id="color" style="color: white;">Variables In Media Queries Using CSS</h1>
    </div>
    <br>
    <div class="bg_container bg-con">
        <h2>Lorem Ipsum</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam semper diam at erat pulvinar, at pulvinar
            felis blandit.</p>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam semper diam at erat pulvinar, at pulvinar
            felis blandit.</p>
    </div>
</div>
</body>
</html>

Related Post