How To Add Box Shadow Effect In Website Using CSS

Take a look at the screenshot below:

Without Box Shadow CSS Effect
Without Box Shadow CSS Effect

There are three columns, each one of them contains one image and one paragraph. After adding few lines of CSS take a look at below screenshot. Which one looks better?

Drop Box Effect Comparison Screenshot
Drop Box Effect Comparison Screenshot

Second one right! Because information is so much clearer.

This effect can be achieved using CSS.

 

How To Add Box Shadow Effect Using CSS:

 

Step – 1: 

Wrap your content into div tag

<div class=”bs”></div> [bs means Box Shadow]

 

Step – 2: 

Go to WordPress Dashboard > Appearance > Customize > Additional CSS – Copy & paste the below CSS. Note: Alternatively you can also use any plugin to add custom CSS into your theme. Both methods will give the same result.

Hit Save and you are good to go. But if you want to customize or want to dive deep into code let me explain how this effect is achieved.

First Line:

This line creates a border around the div tag which in my case is a rectangle.

1px : width of the border. You can increase the value according to your requirement.

solid : border style. You can choose other border options like:

dotted – Defines a dotted border
dashed – Defines a dashed border
solid – Defines a solid border
double – Defines a double border
groove – Defines a 3D grooved border. The effect depends on the border-color value
ridge – Defines a 3D ridged border. The effect depends on the border-color value
inset – Defines a 3D inset border. The effect depends on the border-color value
outset – Defines a 3D outset border. The effect depends on the border-color value
none – Defines no border
hidden – Defines a hidden border

#DDD : Color of the border.

 

Second Line:

Did you notice round corners of the border? Those are because of this line. Increasing the value in pixels will make corners more round. You can adjust it according to your requirement. You can also adjust the value of each corner by defining it separate like:

 

Third Line:

It adds little shadow to the content. You may need to increase value in order to make it more noticeable. But it’s okay. We will add little effect later.

 

By adding this CSS your content will look like this –

Box Shadow Effect Using CSS
Box Shadow Effect Using CSS

Now in order to take this effect to next level, let’s add some hover effect so that it can look like this-

Box Shadow Hover Effect Example
Box Shadow Hover Effect Example

How to add hover effect to an element:

Above effect can be achieved using CSS-

This code will increase box-shadow value & a smooth transition on hovering the mouse on that element.

You have to play around a little bit in order to make that effect fit according to your need. Possibilities are endless.

In comment section share how you have used this effect. Subscribe & Share it with you friends.

Prabhjot Singh

Prabhjot Singh

Share this post

Share on facebook
Share on linkedin
Share on twitter
Share on reddit
Share on whatsapp
Share on telegram
Share on email

More To Explore