Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to connect the shadow of the box diagonally?

Tags:

html

css

I am trying to create a box like this. I am using the box-shadow property. I have tried to skew but the whole box skews

enter image description here I want to make the shadow to connect diagonally to the box. I am not getting to connect the shadow of the box diagonally to the box. Please suggest me.

#one {
  width: 400px;
  height: 200px;
  background-color: yellow;
  box-shadow: -10px 10px black;
  margin: 10% 0 10% 10%;
  transform: rotate(1.5deg) translateX(10px) translateY(15px) skewX(4deg) skewY(-4deg);
}
<body>
  <div id="one">
  </div>
</body>
like image 994
user Avatar asked Dec 21 '15 06:12

user


1 Answers

You don't need to use any transform method to achieve this. All you have to do is use box-shadow

This is the structure of box-shadow

box-shadow: [horizontal offset] [vertical offset] [blur radius] [optional spread radius] [color];

where you are suppose to change the [horizontal offset] and [vertical offset]

Here is how you should do

PS: Do the proper adjustments until you get desired output.

.box {
  width: 300px;
  margin: 50px auto;
  height: 100px;
  background: red;
  box-shadow: -1px 0px 0px #000, -0px 1px 0px #000, -2px 1px 0px #000, -1px 2px 0px #000, -3px 2px 0px #000, -2px 3px 0px #000, -4px 3px 0px #000, -3px 4px 0px #000, -5px 4px 0px #000, -4px 5px 0px #000, -6px 5px 0px #000, -5px 6px 0px #000, -7px 6px 0px #000, -6px 7px 0px #000, -8px 7px 0px #000, -7px 8px 0px #000, -9px 8px 0px #000, -8px 9px 0px #000, -10px 9px 0px #000, -9px 10px 0px #000, -11px 10px 0px #000, -10px 11px 0px #000, -12px 11px 0px #000, -11px 12px 0px #000, -13px 12px 0px #000, -12px 13px 0px #000, -14px 13px 0px #000, -13px 14px 0px #000, -15px 14px 0px #000, -14px 15px 0px #000, -16px 15px 0px #000, -15px 16px 0px #000, -17px 16px 0px #000, -16px 17px 0px #000, -18px 17px 0px #000, -17px 18px 0px #000, -19px 18px 0px #000, -18px 19px 0px #000, -20px 19px 0px #000, -19px 20px 0px #000, -21px 20px 0px #000, -20px 21px 0px #000, -22px 21px 0px #000, -21px 22px 0px #000, -23px 22px 0px #000, -22px 23px 0px #000, -24px 23px 0px #000, -23px 24px 0px #000, -25px 24px 0px #000, -24px 25px 0px #000, -26px 25px 0px #000, -25px 26px 0px #000, -27px 26px 0px #000, -26px 27px 0px #000, -28px 27px 0px #000, -27px 28px 0px #000, -29px 28px 0px #000, -28px 29px 0px #000, -30px 29px 0px #000, -29px 30px 0px #000;
}
<div class="box"></div>
like image 112
Jinu Kurian Avatar answered Sep 30 '22 18:09

Jinu Kurian