Skip to main content

Command Palette

Search for a command to run...

How to create a dynamic shadow using CSS.

Updated
1 min read
F
I am an Infrastructure and DevOps Engineer specializing in designing, building, and operating scalable, secure, and highly available cloud infrastructure. My core focus is on Microsoft Azure cloud platforms, Infrastructure as Code (IaC), and DevOps automation to support reliable production systems. I work across cloud infrastructure engineering, DevOps practices, and site reliability engineering (SRE) principles to ensure systems are resilient, observable, and optimized for performance, cost, and scalability. My experience includes designing and managing cloud environments across compute, networking, storage, identity, and security layers. I build Infrastructure as Code solutions using Terraform and Azure Resource Manager (ARM) templates to automate provisioning, configuration, and deployment of cloud resources. I am actively involved in improving system reliability through monitoring, logging, and incident response processes using tools such as Azure Monitor and cloud-native observability solutions. I also participate in on-call operations, production support, and incident management to ensure high availability of critical systems. Security is a core part of my engineering approach. I work with identity and access management (IAM), Azure Active Directory, and cloud security best practices to ensure infrastructure remains compliant, secure, and audit-ready in line with industry standards such as ISO 9001 and ISO 27001. I collaborate with cross-functional teams including software engineers, DevSecOps, and product teams to deliver infrastructure solutions for customer-facing applications and enterprise platforms. My technical interests and growth areas include: Cloud Infrastructure Engineering (Azure, AWS, GCP) Site Reliability Engineering (SRE) Platform Engineering Kubernetes & Container Orchestration Infrastructure as Code (Terraform, ARM) CI/CD Pipeline Automation Distributed Systems & System Design Cloud Security & Identity Management I am passionate about building systems that are not only scalable and efficient but also reliable and easy for engineers to use. I am continuously growing my expertise toward senior-level Infrastructure, SRE, and Platform Engineering roles, including global remote opportunities.

You can create a shadow similar to box-shadow but based on the colors of the element itself.

Brief Explanations:

  • position: relative on the element establishes a Cartesian positioning context for psuedo-elements.

  • z-index: 1 establishes a new stacking context.

  • ::after defines a pseudo-element.

  • position: absolute takes the pseudo element out of the flow of the document and positions it in relation to the parent.

  • width: 100% and height: 100% sizes the pseudo-element to fill its parent's dimensions, making it equal in size.

  • background: inherit causes the pseudo-element to inherit the linear gradient specified on the element.

  • top: 0.5rem offsets the pseudo-element down slightly from its parent.

  • filter: blur(0.4rem) will blur the pseudo-element to create the appearance of a shadow underneath.

  • opacity: 0.7 makes the pseudo-element partially transparent.

  • z-index: -1 positions the pseudo-element behind the parent but in front of the background.

Code Sample:

HTML

<div class="dynamic-shadow"></div>

CSS

.dynamic-shadow {
  position: relative;
  width: 10rem;
  height: 10rem;
  background: linear-gradient(75deg, #6d78ff, #00ffb8);
  z-index: 1;
}
.dynamic-shadow::after {
  content: '';
  width: 100%;
  height: 100%;
  position: absolute;
  background: inherit;
  top: 0.5rem;
  filter: blur(0.4rem);
  opacity: 0.7;
  z-index: -1;
}

Happy Coding!

More from this blog

Building Reliable Systems

93 posts

Insights on Infrastructure, DevOps, SRE, and building reliable systems at scale.