google+javascriptbanktwitter@js_bankfacebook@jsbankrss@jsbank






Awesome Box Shading Skill with CSS only In this tutorial, the author will guide you how to create awesome box shade with CSS only. This is a full-detailed instructions and a cool demo. Please go to the full post page for awesome web experiment.


Label: box shading skill, rounded CSS boxes, CSS box rounded, CSS layout boxes, CSS shading

Generate your business videos by AI with voice or just text



Your first FREE AI Video App! Automate Your First AI Video. Create Your Professional Video In 5 Minutes By AI No Equipment Or Video Editing Skill Requred. Effortless Video Production For Content Marketers.
Free UNLMITED AI Video App in Your Hand

Here is a fun technique to add shading to your web pages using only CSS with PNG images, without using JavaScript, Flash, server-side scripting, or Photoshop, and remain totally independent from colors and textures.

Try it demo. Download the source

Background

Most shading techniques suffer the drawback of the core technology they use:

  1. Photoshop: images must be individually styled for each pattern combination
  2. Javascript: CPU intensive

The main issue with Photoshop techniques comes from the time spent creating images, and from the complexity of the code to keep tack of them. For each color/teture combination, 8 images (4 corners and 4 edges) are required.

One technique called �sliding door� reduces these elements to 6, but requires larger images:

A new approach

Our technique is based on the same basic idea used in 3D rendering engines which separate textures from shading. Here is an example showing the difference between shades + textures, and shades only:

The first step is to create the shade PND images. Simply use a mask to hide the box content (see the included files):

To optimize this technique, we can reduce the top and bottom elements� width, and the left and right elements� height to one pixel.

To use on a web page, we simply create a box element normally, wrap it in a �shade� container and add the required elements.

For the most complex case:

<div class='shade'>

 <div class='box'>
  <!-- content -->
 </div>

 <div class='TL' />
 <div class='T' />
 <div class='TR' />
 <div class='L' />
 <div class='C' />
 <div class='R' />
 <div class='BL' />
 <div class='B' />
 <div class='BR' />

</div>

For fixed-with boxes, such as page containers, we only require 3 elements (top, center, and bottom):

<div class='shade'>

 <div class='box'>
  <!-- content -->
 </div>

 <div class='T' />
 <div class='C' />
 <div class='B' />

</div>

Likewise, fixed-height boxed such as title containers only require 3 elements (left, center, and right):

<div class='shade'>

 <div class='box'>
  <!-- content -->
 </div>

 <div class='L' />
 <div class='C' />
 <div class='R' />

</div>

You do not have to create the shade element, you can just apply the shade class to an existing one. The only purpose of the shade element is to serve as a wrapper and an anchor for absolute positioning.

Fore each shading element, we define a negative margin (here 10 px) to accommodate the shade and use a negative z-positioning to place the shade below the content of the box.

.shade {
 position:relative;
}
.shade .TL, .shade .T, .shade .TR,
.shade .L, .shade .C, .shade .R,
.shade .BL, .shade .B, .shade .TB {
 position:absolute;
 z-index: -1;
 top:-10px;
 left:-10px;
 right:-10px;
 bottom:-10px;
}
.shade .TL {
 background: url(s/tl.png) no-repeat left top;
}
...

As always, the best way to fully understand a technique is to look at a demo, or to download the source. Next time, we will look at a Drupal theme which implements this technique.

Cheers!

JF

AIVideo-App.com
Generate your business videos by AI with voice or just text

chatGPTaz.com
Talk to ChatGPT by your mother language

AppAIVideo
Your first FREE AI Video App

Deepfake Video
Deepfake AI Video Maker

Deepfake
Deepfake AI Video Maker

AI Deep Fake
Deepfake AI Video Maker

AIvidio
AI Video Mobile Solutions

AIvideos
AI Video Platform & Solutions

AIvedio
AI Video App Maker

Artificial General Intelligence
Ai and higher level Artificial General Intelligence (AGI)

Artificial General Intelligence
Ai and higher level Artificial General Intelligence (AGI)

Faceswap AI Online
Swap Faces Video, Photo & GIFs Instantly with Powerful AI Tools - Faceswap AI Online FREE

Faceswap AI Online
Swap Faces Video, Photo & GIFs Instantly with Powerful AI Tools - Faceswap AI Online FREE

Faceswap AI Online
Swap Faces Video, Photo & GIFs Instantly with Powerful AI Tools - Faceswap AI Online FREE

Powerful AI Presentation PPT Maker for FREE
Build an impressive presentation with our free online AI presentation app

Your next top AI Assistant
Claude AI, developed by Anthropic

Your next top AI Assistant
Claude AI, developed by Anthropic

Temu Free $500 for New Users
Claim Free Temu $500 Credit via Affiliate & Influencer Program

Free TikTok Ads Credit
Master TikTok Ads for Your Business Marketing

Dall-E-OpenAI.com
Generate creative images automatically with AI

chatGPT4.win
Talk to ChatGPT by your mother language

First AI Product from Elon Musk - Grok/UN.com
Speak to Grok AI Chatbot with Your Language

Tooly.win
Open tool hub for free to use by any one for every one with hundreds of tools

GateIO.gomymobi.com
Free Airdrops to Claim, Share Up to $150,000 per Project

iPhoneKer.com
Save up to 630$ when buy new iPhone 16

Buy Tesla Optimus Robot
Order Your Tesla Bot: Optimus Gen 2 Robot Today for less than $20k

JavaScript by day


Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web