Implemented text-shadow on a text element utilizing the -webkit-background-clip property

Is there a way to add a drop shadow on text and make the part of the shadow that's inside the text disappear or go behind the background image?

.mask {
  background-image: radial-gradient(purple, gold);
  background-size: cover;
  mix-blend-mode: luminosity;
  background-repeat: no-repeat;
  -webkit-background-clip: text;
  color: rgba(254, 185, 90, .3);
  font-size: 4em;
  font-family: impact;
  font-weight: bold;
}

/*
The issue with adding shadow is that it covers the background:
*/

.withShadow {
  text-shadow: 1px 1px 1px black;
}
<span class="mask">My Text</span>
<span class="mask withShadow">My Text</span>

When adding shadow, most of it appears inside the transparent text. Is there a CSS or Javascript solution to eliminate the shadow inside the text?

Thank you!

Answer №1

A potential solution could involve avoiding the use of text-shadow and utilizing -webkit-text-stroke instead:

.overlay {
  background-image: radial-gradient(blue, green);
  background-size: contain;
  mix-blend-mode: overlay;
  background-repeat: no-repeat;
  -webkit-background-clip: text;
  color: rgba(120, 230, 80, .5);
  font-size: 3em;
  font-family: sans-serif;
  font-weight: normal;
}

.withBorder {
  -webkit-text-stroke: 2px white;
}
<span class="overlay">Sample Text</span>
<span class="overlay withBorder">Sample Text</span>

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

Exploring VueJS: How to retrieve a specific value from an array within JSON data obtained from an API request?

Currently, I am creating a blog completely from scratch with both front and backend components that communicate through an API I developed. Below is the JSON output of the API: { "status": true, "posts": [ { ...

Is there a method to retrieve fresh data in HTML without the need to restart the server?

I am encountering an issue with my node.js express server. I have an audio file that is being recorded every 5 seconds on my Raspberry Pi with the same name. The problem arises when I try to play this audio file on my website, which refreshes every 10 seco ...

Vue.js: Issue with updating list in parent component when using child component

I'm encountering an issue when utilizing a child component, the list fails to update based on a prop that is passed into it. When there are changes in the comments array data, the list does not reflect those updates if it uses the child component < ...

Ways to access JSON data in JavaScript

I'm experiencing difficulty accessing the JSON data provided below. My approach involves utilizing the JavaScript AJAX success function, and when attempting alerts with the following code, $.ajax({ type:'GET', url:myURL, success : function ...

Accept only requests from my Chrome extension

I have successfully set up a NodeJS server with Express on DigitalOcean. My Chrome extension is able to make GET calls to the server without any issues. However, I am looking to enhance the security of the middleware below: // Add headers app.use(function ...

I'm looking for a clear explanation of the concepts of null and undefined, particularly in terms of single, double, and triple equals. Does anyone have a thorough explanation, or

Why does null equal undefined in one comparison but not in another? When comparing using ==, undefined is equal to null. true However, when using !==, undefined is not equal to null. true This means that undefined and null are not strictly equal. ...

Commencement of timeline utilizing amchart's gantt feature

I am currently utilizing the Gantt chart feature in Amchart. The chart segments are organized based on dates. I am looking to specify a specific initial location for the chart's navigator between two dates, rather than having it applied across the en ...

What is the best way to incorporate a sidebar menu in an HTML webpage?

I am interested in creating a sidebar menu for my website using either HTML, CSS, or JavaScript. The W3 Schools website has a side menu that I find appealing and would like to create something similar. ...

Performing numerous asynchronous MongoDB queries in Node.js

Is there a better way to write multiple queries in succession? For example: Space.findOne({ _id: id }, function(err, space) { User.findOne({ user_id: userid }, function(err, user) { res.json({ space: space, user: user}); }); }); It can g ...

Do all descendants consistently trigger rerenders?

Recently, I was exploring the React new documentation here, where I came across this interesting piece of information: The context value mentioned here is a JavaScript object with two properties, one being a function. Whenever MyApp re-renders (for examp ...

React and MobX - Creating a confirmation popup when a user attempts to leave the current page

I have a similar code snippet that includes: import React from 'react'; import PropTypes from 'prop-types'; import { Prompt } from 'react-router-dom'; const ConfirmationDialog = (props) => { if (props.navigatingAway) { ...

Prevent one individual cell in a table from dictating the overall table width

A B A B A X A B In a contained block with a fixed width of 400px, there is a table. When the browser width drops below 421px, the width of the containing block changes to 95%. The cells labeled "A" and "B" contain simple text. There is one cel ...

firefox is experiencing lag issues with react-spring and framer-motion

Encountering an issue with two animation libraries, react-spring and framer-motion. Attempting to create a basic animation that triggers upon the component's initial visibility (simplified version). <motion.div initial={{x: -25, opacity: 0}} anima ...

What is the best way to ensure the text in my paragraph div is aligned to the left and displays in a vertical line?

I am struggling to align the words in my paragraph to the left in a straight line, instead of the zig-zag placement they currently have. Any guidance on achieving this would be greatly appreciated. /* Styling for tablet-sized screen*/ @media (min-width ...

Implementing a FadeOut effect for the clicked link

When clicking on each link, I want the same link to fadeOut() after clicking on the ok button in the myalert() function. If clicked on cancel, it should not fadeOut(). How can I achieve this using the myalert() function? For example: http://jsfiddle.net/M ...

Experiencing difficulties with parsing JSON data and storing values in a database

I received a JSON response from the server and need help saving the values in a MySQL database using PHP. Can someone please assist me with this? {"fields":[{"label":"Do you have a website?","field_type":"website","required":false,"field_options":{}," ...

The ul element is not being properly styled by the CSS pseudoclass :checked

I recently attempted to create a responsive navigation bar using a YouTube tutorial that utilizes a checkbox to display and hide the menu on smaller screens. Despite meticulously following the tutorial and testing different browsers such as Chrome, Edge, a ...

Styling dates in React

How can I properly display the date in the correct format? I'm seeing the date displayed incorrectly on the screen as 32/03/2020, but the 32nd day doesn't exist. Below is the correct date format displayed in the image. I'm new to Reactjs, ...

Preserving the status of your AngularJS application

Can the state of an AngularJS app be preserved using Angular local storage? I am developing an information-based app with a substantial amount of content, and I want to save the user's current "location" so that when they reopen the app later, it open ...

Attempted to load Angular multiple times

I recently developed an app using the Yeoman scaffolded app (specifically, the Angular Fullstack generator). While grunt serve works perfectly fine, I encountered a problem when running grunt build which results in the distribution locking up memory. This ...