CSS Properties: How to percentages are relative to the height or width of the image?
Solution:
HTML Code:
Explanation:
- This HTML document demonstrates how to use percentages as values for the border-image-slice property.
- The <div> element is styled with a border image sourced from the specified URL.
- border: 20px solid transparent; sets a transparent solid border with a width of 20 pixels for the <div> element.
- padding: 10px; adds 10 pixels of padding to the <div> element.
- border-image-slice: 20%; slices the border image into sections that are 20% of the image's height or width.
- border-image-repeat: round; sets the border image to be repeated and rounded.
- The text "border-image-slice: percentage" inside the <div> demonstrates border image slicing using a percentage value.
Live Demo:
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | No |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.