- 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-clip Property
CSS mask-clip property can take various values to specify how the mask should be clipped relative to the element's box.
Possible Values
content-box − The mask is clipped to the outer edge of the element's content box.
padding-box − The mask is clipped to the outer edge of the element's padding box.
border-box − The mask is clipped to the outer edge of the element's border box.
fill-box − The mask is clipped to the object bounding box, including the padding and border.
stroke-box − The mask is clipped to the stroke (border-area) bounding box.
view-box − The nearest SVG viewport is considered as a reference box. SVG elements with a viewBox attribute have their content placed at the origin of the coordinate system defined by the viewBox, and the size / dimensions of the reference box is set to the width and height specified in the viewBox attribute.
no-clip − The mask is not clipped; it extends beyond the element's box.
Applies to
All elements. In SVG, it applies to container elements excluding the <defs> element and all graphics elements
Syntax
<geometry-box> Values
mask-clip: content-box; mask-clip: padding-box; mask-clip: border-box; mask-clip: fill-box; mask-clip: stroke-box; mask-clip: view-box;
Keyword Values
mask-clip: no-clip;
CSS mask-clip - content-box
The following example demonstrates that the -webkit-mask-clip: content-box property clips mask the outer edge of the element's content box, without considering padding and border −
<html> <head> <style> .mask-container { width: 100px; height: 100px; background-color: gold; margin: 10px; border: 20px solid red; padding: 20px; -webkit-mask-image: url(images/book.png); -webkit-mask-size: 100% 100%; -webkit-mask-clip: content-box; mask-image: url(images/book.png); mask-size: 100% 100%; mask-clip: content-box; } </style> </head> <body> <div class="mask-container"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </div> </body> </html>
CSS mask-clip - padding-box
The following example demonstrates that the -webkit-mask-clip: padding-box property clips mask to the padding box of the element, without considering border −
<html> <head> <style> .mask-container { width: 100px; height: 100px; background-color: gold; margin: 10px; border: 20px solid red; padding: 20px; -webkit-mask-image: url(images/book.png); -webkit-mask-size: 100% 100%; -webkit-mask-clip: padding-box; mask-image: url(images/book.png); mask-size: 100% 100%; mask-clip: padding-box; } </style> </head> <body> <div class="mask-container"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </div> </body> </html>
CSS mask-clip - border-box
The following example demonstrates that the -webkit-mask-clip: border-box property clips mask to the border box of the element, including padding and border −
<html> <head> <style> .mask-container { width: 100px; height: 100px; background-color: gold; margin: 10px; border: 20px solid red; padding: 20px; -webkit-mask-image: url(images/book.png); -webkit-mask-size: 100% 100%; -webkit-mask-clip: border-box; mask-image: url(images/book.png); mask-size: 100% 100%; mask-clip: border-box; } </style> </head> <body> <div class="mask-container"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </div> </body> </html>
CSS mask-clip - fill-box
The following example demonstrates that the -webkit-mask-clip: fill-box property clips mask to the content box element, without the padding and border −
<html> <head> <style> .mask-container { width: 100px; height: 100px; background-color: gold; margin: 10px; border: 20px solid red; padding: 20px; -webkit-mask-image: url(images/book.png); -webkit-mask-size: 100% 100%; -webkit-mask-clip: fill-box; mask-image: url(images/book.png); mask-size: 100% 100%; mask-clip: fill-box; } </style> </head> <body> <div class="mask-container"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </div> </body> </html>
CSS mask-clip - stroke-box
The following example demonstrates that the -webkit-mask-clip: stroke-box property clips mask to the stroke-box (border-area) of the image element, including the padding and border −
<html> <head> <style> .mask-container { width: 100px; height: 100px; background-color: gold; margin: 10px; border: 20px solid red; padding: 20px; -webkit-mask-image: url(images/book.png); -webkit-mask-size: 100% 100%; -webkit-mask-clip: stroke-box; mask-image: url(images/book.png); mask-size: 100% 100%; mask-clip: stroke-box; } </style> </head> <body> <div class="mask-container"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </div> </body> </html>
CSS mask-clip - view-box
An SVG mask is used to hide parts of an image or shape based on the shape of another image or shape.
The following example demonstrates that the mask shape is a circle in the middle of the SVG element, and the masked element is a rectangle that covers the entire SVG element −
<html> <head> <style> .mask-container { width: 300px; height: 200px; position: relative; } svg { width: 100%; height: 100%; } rect { fill: yellow; } .mask-rectangle { mask: url(#maskViewbox); -webkit-mask-clip: view-box; } </style> </head> <body> <div class="mask-container"> <svg viewBox="0 0 150 100"> <mask id="maskViewbox" maskUnits="objectBoundingBox" maskContentUnits="objectBoundingBox"> <rect x="0" y="0" width="1" height="1"/> <circle cx="0.5" cy="0.5" r="0.4"/> </mask> <rect x="0" y="0" width="100%" height="100%" class="mask-rectangle"/> </svg> </div> </body> </html>
CSS mask-clip - no-clip
The following example demonstartes how -webkit-mask-clip: no-clip property prevents mask image from clipping −
<html> <head> <style> .mask-container { width: 100px; height: 100px; background-color: gold; margin: 10px; border: 20px solid red; padding: 20px; -webkit-mask-image: url(images/book.png); -webkit-mask-size: 100% 100%; -webkit-mask-clip: no-clip; mask-image: url(images/book.png); mask-size: 100% 100%; mask-clip: no-clip; } </style> </head> <body> <div class="mask-container"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </div> </body> </html>
To Continue Learning Please Login
Login with Google