Open In App

CSS mask-position property

The mask-position property  sets the mask images within the mask positioning area by using the percentage or keywords values. There are always two values of mask-position (horizontal offset and vertical offset). If only one value is specified then the other one is assumed to be 50% or center.

Syntax:



mask-position: Keyword values
/* Or */
mask-position: position values
/* Or */
mask-position: Multiple values
/* Or */
mask-position: Global values

Property values: This property accepts values mentioned above and described below:

Example 1: Below example illustrates the mask-position property using position-values






<!DOCTYPE html>
<html>
<head>
    <style>
        .Container {
            border: 3px solid black;
            background-color: rgb(136, 255, 0);
            width: 30%;
            height: 30vh;
        }
 
        .geeks {
            width: 30%;
            height: 200px;
            background: green;
            border: 10px solid red;
            -webkit-mask-image:
                url("image.svg");
            -webkit-mask-repeat: no-repeat;
            mask-position: 0.2rem 30%;
        }
    </style>
</head>
 
<body>
    <div class="Container">
        <div class="geeks"></div>
    </div>
</body>
</html>

Output:

Example 2: Below example illustrates the mask-position property using keyword-values




<!DOCTYPE html>
<html>
<head>
    <style>
        .Container {
            border: 3px solid black;
            background-color: rgb(136, 255, 0);
            width: 30%;
            height: 30vh;
        }
 
        .geeks {
            width: 30%;
            height: 200px;
            background: green;
            border: 10px solid red;
            -webkit-mask-image:
                url("image.svg");
            -webkit-mask-repeat: no-repeat;
            mask-position: top;
        }
    </style>
</head>
 
<body>
 
    <div class="Container">
        <div class="geeks"></div>
    </div>
 
</body>
</html>

Output:

Browsers Supported:


Article Tags :