- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Selectors
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS Masking - mask-border-width Property
The CSS property mask-border-width sets the width of an element's mask border.
The mask-border-width CSS property can be specified as one, two, three, or four values. Following rules are in consideration while applying the value:
If one value is specified, the same width is applied to all four sides.
If two values are specified, the first width is applied to the top and bottom and the second width to the left and right sides, respectively.
If three values are specified, the first width is applied to the top, the second width to the left and right sides, and the third width to the bottom side, respectively.
If four values are specified, the widths are applied to the top, right, bottom, and left sides, in the order that is specified (clockwise).
Possible values
The CSS property mask-border-width can have one of the following values:
<length-percentage>: The mask border's width is specified as a <length> or a <percentage> value, where percentages are relative to the width of the border area in case of horizontal offsets and height of the border area in case of vertical offsets. Negative values are not valid.
<number>: The mask border's width is specified as a multiple of the corresponding border-width. Negative values are not valid.
auto: The intrinsic width or height of the corresponding mask-border-slice is set as the width of the mask border. In case the image does not have intrinsic dimension, the corresponding border-width is used.
Applies to
All HTML elements. And in case of SVG, it applies to the container element excluding the <defs> element and all graphics elements
Syntax
mask-border-width = [ <length-percentage> | <number> | auto ]{1,4}
Note: The chromium-based browsers support the old version of this property mask-box-image-width with a prefix, i.e., -webkit.
-webkit-mask-border-width = 20px;
CSS mask-border-width - One Value
The following example demonstrates the use of the CSS property mask-border-width, where an image is passed as the mask border and a width value is specified, which sets the width of the mask border on all the four sides.
<html> <head> <style> .with-mask { -webkit-mask-box-image-source: url("images/logo.png"); -webkit-mask-box-image-slice: 20 fill; /* slice */ -webkit-mask-box-image-width: 10px; /* width */ -webkit-mask-box-image-outset: 2px; /* outset */ -webkit-mask-box-image-repeat: repeat; /* repeat */ mask-border-source: url("images/logo.png"); mask-border-slice: 20 fill; /* slice */ mask-border-width: 10px; /* width */ mask-border-outset: 2px; /* outset */ mask-border-repeat: repeat; /* repeat */ } </style> </head> <body> <h1>The mask-border-width Property</h1> <h3>With mask-border-width</h3> <div class="with-mask"> <img src="images/scenery2.jpg" alt="mask border image" width="500" height="300"> </div> <h3>Without mask-border-width</h3> <img src="images/scenery2.jpg" alt="mask border image" width="500" height="300"> </body> </html>
CSS mask-border-width - Two Values
The following example demonstrates the use of the CSS property mask-border-width, where an image is passed as the mask border and two values are passed for width, which sets the width of the top and bottom side by 10px and that of left and right sides by 20px.
<html> <head> <style> .with-mask { -webkit-mask-box-image-source: url("images/logo.png"); -webkit-mask-box-image-slice: 20 fill; /* slice */ -webkit-mask-box-image-width: 10px 20px; /* width */ -webkit-mask-box-image-outset: 2px; /* outset */ -webkit-mask-box-image-repeat: repeat; /* repeat */ mask-border-source: url("images/logo.png"); mask-border-slice: 20 fill; /* slice */ mask-border-width: 10px 20px; /* width */ mask-border-outset: 2px; /* outset */ mask-border-repeat: repeat; /* repeat */ } </style> </head> <body> <h1>The mask-border-width Property</h1> <h3>With mask-border-width</h3> <div class="with-mask"> <img src="images/scenery2.jpg" alt="mask border image" width="500" height="300"> </div> <h3>Without mask-border-width</h3> <img src="images/scenery2.jpg" alt="mask border image" width="500" height="300"> </body> </html>
CSS mask-border-width - Three Values
The following example demonstrates the use of the CSS property mask-border-width, where an image is passed as the mask border and three values are passed for width, which sets the width of the top side by 10%, left and right sides by 20px and that of bottom side by 10%.
<html> <head> <style> .with-mask { -webkit-mask-box-image-source: url("images/logo.png"); -webkit-mask-box-image-slice: 20 fill; /* slice */ -webkit-mask-box-image-width: 10% 20px 10%; /* width */ -webkit-mask-box-image-outset: 2px; /* outset */ -webkit-mask-box-image-repeat: repeat; /* repeat */ mask-border-source: url("images/logo.png"); mask-border-slice: 20 fill; /* slice */ mask-border-width: 10% 20px 10%; /* width */ mask-border-outset: 2px; /* outset */ mask-border-repeat: repeat; /* repeat */ } </style> </head> <body> <h1>The mask-border-width Property</h1> <h3>With mask-border-width</h3> <div class="with-mask"> <img src="images/scenery2.jpg" alt="mask border image" width="500" height="300"> </div> <h3>Without mask-border-width</h3> <img src="images/scenery2.jpg" alt="mask border image" width="500" height="300"> </body> </html>
CSS mask-border-width - Four Values
The following example demonstrates the use of the CSS property mask-border-width, where an image is passed as the mask border and four values are passed for width, which sets the width of all the sides by 10px.
<html> <head> <style> .with-mask { -webkit-mask-box-image-source: url("images/logo.png"); -webkit-mask-box-image-slice: 20 fill; /* slice */ -webkit-mask-box-image-width: 10px 10px 10px 10px /* width */ -webkit-mask-box-image-outset: 2px; /* outset */ -webkit-mask-box-image-repeat: repeat; /* repeat */ mask-border-source: url("images/logo.png"); mask-border-slice: 20 fill; /* slice */ mask-border-width: 10px 10px 10px 10px; /* width */ mask-border-outset: 2px; /* outset */ mask-border-repeat: repeat; /* repeat */ } </style> </head> <body> <h1>The mask-border-width Property</h1> <h3>With mask-border-width</h3> <div class="with-mask"> <img src="images/scenery2.jpg" alt="mask border image" width="500" height="300"> </div> <h3>Without mask-border-width</h3> <img src="images/scenery2.jpg" alt="mask border image" width="500" height="300"> </body> </html>
To Continue Learning Please Login
Login with Google