Problems encountered when applying box-shadow for text background across multiple lines

Lately, I've become accustomed to using box-shadow to add backgrounds to text headings. I've been employing a little trick of applying a box-shadow to a span element within h1 tags in order to create a unique "background with padding" highlight effect for headings that span multiple lines. The background aligns to the end of the span instead of the whole heading block element, resulting in a neat look as shown below.

https://i.sstatic.net/lMiW2.png

h1.highlight span {
        box-shadow: 0 0 0 16px #fff000;
        background-color: #fff000;
        line-height: 1.6;
        box-decoration-break: clone;
    }

<h1 class="highlight"><span>Highlight text<br />goes here</span></h1>

However, recently I've observed that this technique no longer produces the desired effect. The box-shadow breaks when the heading extends to a second line, as demonstrated here: https://codepen.io/georgiacobrien/pen/LYBbJge

My question is twofold - first, does anyone know why this is now rendering differently? And secondly, is there a better method to achieve a similar effect for headings that span multiple lines?

Answer №1

It appears that this is a peculiar behavior specific to Chrome and Webkit browsers. Previously, I've had success using box-decoration-break: clone; without any prefixes in Chrome, but now it seems necessary to include the webkit prefix (-webkit-box-decoration-break: clone;) for it to function properly. It's strange, but that's just how it is!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What could be causing my AngularJs routing and animation to bypass the second redirection?

Recently started working with Angular and experimenting with routing and animations to manage my page transitions. I followed a helpful guide that helped me set everything up. I encountered a few issues: When trying to link back to the landing page (home ...

What is the process of incorporating a select form within a component?

I am currently working on creating a user registration form. Once the form is filled out and the submit button is clicked, I need the values from the form to be displayed in a specific <p id="data></p> component. Can anyone assist me with this ...

The background image set using Bootstrap is displayed across all pages on my website

Here is the code I've been working on: html, body { background: url("media/images/maishahotbgimg.jpg") repeat; The background image is currently showing only on the homepage. How can I make it appear on all pages of my website? ...

in Vue.js, extract the style of an element and apply it to a different element

Currently, I am using VUE.js 2 in my project. Here is my website's DOM structure: <aside :style="{height : height()}" class="col-sm-4 col-md-3 col-lg-3">...</aside> <main class="col-sm-8 col-md-9 col-lg-9" ref="userPanelMainContents" ...

Modify the CSS of the hidden value within a select type input field

Is it possible to make the "Select Month" placeholder text red while keeping the options in black? I am currently using the hidden attribute as part of my JavaScript functionality. The goal is to only change the color of the default placeholder value. & ...

Is there a way to create animated image pixelation without relying on canvas, simply using CSS?

Pixelation can be achieved in CSS by following these steps: Set background-image to a very small image (50px or 100px). Apply image-rendering: pixelated on the element. This will give you the desired pixelated effect. Now, I am interested in animating ...

Creating PDFs using Puppeteer in the presence of `link` tags

On my website, students have the ability to create their own notes using a RichText editor where the content can be quite complex. I want to provide them with an option to download these notes as a PDF file. To achieve this, I am planning to use the "puppe ...

View complex response objects in Postman as easily digestible tables

I am interested in displaying the data provided below as a table using Postman Tests. The table should have columns for product, price, and quantity, with Items listed in rows. It's important to note that there may be multiple shippingGroups within th ...

Having trouble populating two linked html dropdowns with JSON data using jQuery?

My attempt to populate two HTML selects with JSON data is resulting in an error: Uncaught TypeError: country.map is not a function when trying to populate the cities. Can anyone point out the issue with the code? $(document).ready(function() { let $co ...

Concealing jQueryUI tooltip upon clicking a "target=_blank" link

I have implemented jQuery to display tooltips for all links on my webpage that include a 'details' attribute. $(function() { $tooltip = $(document).tooltip({ show: false, track: true, ...

What is the optimal method for saving a dynamic webpage as an object?

In my current project, I am developing a PHP application that utilizes MySQL for the database. One of the features I want to include is a site builder using AJAX to load and store dynamic page content. The goal is to allow users to make changes to the site ...

Issues with CSS transitions not functioning properly following the use of toggleClass()

I recently implemented a toggle-menu feature, which you can see in action on this demo. To enhance the toggle-menu, I added a CSS transition effect to div.nav-menu, utilizing max-height:0; and increasing it to max-height:480px;. However, after clicking t ...

A trio of versatile sections within a box, one designed to accommodate text overflow

Trying to create a CSS layout where three texts are placed side by side without wrapping, but once the first text is too long, it needs to be truncated. Check out the image below for more details. Methods I have attempted so far: Floated positioning of ...

Set the styling of a div element in the Angular template when the application is first initialized

I have a question about this specific div element: <div class="relative rounded overflow-clip border w-full" [style.aspect-ratio]="media.value.ratio"> <img fill priority [ngSrc]="media.value.src || ftaLogo" ...

Width of the `div` element is expanding

I'm encountering an issue where a div container is automatically stretching to the full width of the page, instead of adjusting to fit the content within it. Below is the HTML code snippet: <!doctype html> <html> <!-- Head --> <h ...

A layout featuring two columns: the right column has a fixed width, while the left column is fluid

I am in need of a simple solution: 2 columns with the right column having a fixed size. Despite searching on stackoverflow and Google, I have not been able to find a working answer that fits my specific context. The current approach is as follows: div.con ...

Nuxt: Issue with Head function affecting title and meta tags

I need to customize the titles and meta descriptions of different pages on my Nuxt website. However, I am struggling to make it work using the head() method as indicated in the documentation. For example, in my contact.vue file: export default class Cont ...

What is the best method to select a sibling element by its class name and then conceal it using solely Javascript?

Here is the HTML structure I am working with: <div id="xyz"> </div> <div class="content"> </div> I am looking to hide the element with a class named content based on the sibling element ID, which is xyz. In jQue ...

How can Chrome's display:none latency be eliminated?

My Chrome extension is designed to alter a third-party web page by removing a button and adding two new HTML elements. The process involves observing the URL of the current tab and executing an HTML injection if it matches the specified regex pattern. Desp ...

Styling for 'checked' state within an ngFor iteration

Each checkbox in my list is assigned to a different department, with each department having its own color. When a box is unchecked, only the border is in the color of the department. When checked, the background changes to the assigned color https://i.ssta ...