CSS inset() function
- Προηγούμενη σελίδα CSS hypot() συνάρτηση
- Επόμενη σελίδα CSS invert() συνάρτηση
- Επιστροφή στο προηγούμενο επίπεδο Εκπαιδευτικός Οδηγός Λειτουργιών CSS
Definition and usage
CSS inset()
Functions define a rectangle that maintains a specified inset distance from each side of the reference frame.
inset()
Functions usually with clip-path
Properties and shape-outside
Use the properties together.
Instance
Example 1
Clip two <div> elements to rectangles that maintain a specified inset distance from each side of the reference frame:
#blueDIV { float: left; width: 150px; height: 100px; background-color: lightblue; clip-path: inset(15px); } #pinkDIV { float: left; width: 150px; height: 100px; background-color: pink; clip-path: inset(5% 10% 15% 10% round 20px); }
Example 2
Using clip-path
and inset()
To achieve the animation effect:
#myDIV { width: 100px; height: 100px; background-color: coral; color: green; animation: mymove 5s infinite; clip-path: inset(10% round 20px); } @keyframes mymove { 50% {clip-path: inset(50% round 50px);} }
Example 3
combined use inset()
,clip-path
and shape-outside
:
#blueDIV { float: left; width: 150px; height: 100px; background-color: lightblue; clip-path: inset(45px 50px 15px 0 round 50px); shape-outside: inset(40px 40px 10px 0 round 50px); }
CSS syntax
inset(length-percentage round border-radius)
Value | Description |
---|---|
length-percentage | Required. 1 to 4 parameters (length or percentage), representing the offset from the top, right, bottom, and left of the reference frame. |
round border-radius | Optional. Specifies whether the embedded rectangle should have rounded corners. |
Technical details
Version: | CSS Shape Module Level 1 |
---|
Browser support
The numbers in the table represent the first browser version that fully supports this function.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
37 | 79 | 54 | 10.1 | 24 |
Related pages
Αναφορά:Παράμετρος CSS clip-path
Αναφορά:Η ιδιότητα shape-outside του CSS
Αναφορά:CSS circle() function
Αναφορά:CSS ellipse() συνάρτηση
Αναφορά:CSS polygon() συνάρτηση
- Προηγούμενη σελίδα CSS hypot() συνάρτηση
- Επόμενη σελίδα CSS invert() συνάρτηση
- Επιστροφή στο προηγούμενο επίπεδο Εκπαιδευτικός Οδηγός Λειτουργιών CSS