CSS Box Decoration Break - Printable Version +- QP School (https://qomplainerzschool.lima-city.de) +-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3) +--- Forum: CSS3 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=5) +--- Thread: CSS Box Decoration Break (/showthread.php?tid=5194) |
CSS Box Decoration Break - Qomplainerz - 07-26-2023 Description: The box-decoration-break property allows you to control how backgrounds, borders, and box shadows behave when an element is broken across multiple lines. Example: <!DOCTYPE html> <html> <head> <title>CSS Box Decoration Break Example</title> <style> .decorated-text { background-color: lightblue; padding: 10px; border: 2px solid red; box-shadow: 5px 5px 5px grey; box-decoration-break: clone; /* OR use 'slice' value for different effect */ /* box-decoration-break: slice; */ } </style> </head> <body> <p class="decorated-text">This is a long text that wraps across multiple lines and the box decoration remains consistent.</p> </body> </html> Explanation: In this example, the .decorated-text paragraph has a background color, padding, border, and box shadow applied to it. By default, when text wraps across multiple lines, the box decorations are repeated for each line. The box-decoration-break: clone property ensures that the box decorations remain consistent even when the element breaks across lines. |