Ver*_*ous 4 html css shadow css3
我左边有一个固定的,100%高度的菜单,我需要在它的右侧创建一个阴影效果,之后会消失.
请参见说明这一点的图.

如何创造这种效果?
这是一个小提琴:http://jsfiddle.net/52VtD/7787/
HTML:
<nav id="main-menu">
<h1>Hello</h1>
<a href="#">A</a>
<a href="#">B</a>
<a href="#">C</a>
<a href="#">D</a>
</nav>
Run Code Online (Sandbox Code Playgroud)
CSS:
#main-menu {
width: 320px;
height: 100%;
top: 0;
z-index: 1000;
position: fixed;
background-color: #b4bac1;
}
Run Code Online (Sandbox Code Playgroud)
你可以用CSS3实现这个:box-shadow和transform.
在下面的示例中,box-shadow将应用于.menuContainer位于.menu元素下方的伪元素,并1°使用CSS3s rotate()transform属性进行旋转.
html,body { /* This is only here to allow the menu to stretch to 100% */
height: 100%;
margin: 0;
}
.menuContainer {
position: relative;
height: 100%;
width: 100px;
}
.menuContainer::after {
content: "";
position: absolute;
z-index: 1;
top: -10px;
bottom: 0;
left: -7px;
background: rgba(0,0,0,0.3);
box-shadow: 10px 0 10px 0 rgba(0,0,0,0.3);
width: 100px;
transform: rotate(1deg);
}
.menu {
background: #f00;
height: 100%;
width: 100px;
position: relative;
z-index: 2;
}Run Code Online (Sandbox Code Playgroud)
<div class="menuContainer">
<div class="menu"></div>
</div>Run Code Online (Sandbox Code Playgroud)