html - 如何创建此 CSS3 页面 curl 效果?

标签 html css

我正在尝试使用 CSS3 创建页面 curl 效果。那种效果应该是类似这样的——

enter image description here

我试图让它工作,但无法弄清楚。

这是我的代码

.nav {
    width: 200px;
    background: #353942;
    height: 50px;
    position: relative;

}
.curl {
    width:70px;
    height:50px;
    position: absolute;
    top:0;
    right:0;
    background: linear-gradient(
      25deg, 
      #4c4c4c 0%,
      #474747 39%,
      #2c2c2c 50%,
      #000000 51%,
      #111111 60%,
      #2b2b2b 76%,
      #1c1c1c 91%,
      #131313 100%);
    box-shadow : 0 0 10px rgba(0,0,0,0.5);
    transition: all .5s ease;
}
.curl:before,
.curl:after {
    content: '';
    position: absolute;
    z-index: -1;
    left: 12.5%;
    bottom: 5.8%;
    width: 70%;
    max-width: 300px;
    max-height: 100px;
    height: 55%;
    box-shadow: 0 12px 15px rgba(0, 0, 0, 0.3);
    transform: skew(-10deg) rotate(-6deg);
}
.curl:after {
    left: auto;
    right: 5.8%;
    bottom: auto;
    top: 14.16%;
    transform: skew(-25deg) rotate(-84deg);
}

.curl:hover {
    width: 120px;
    height: 50px;
}
.curl:hover:before,
.curl:hover:after {
    box-shadow: 0 24px 30px rgba(0, 0, 0, 0.3);
}

这是 JS BIN

谁能告诉我我是如何解决这个问题的?

任何想法将不胜感激。

谢谢。

最佳答案

检查一下。

.nav {
width: 200px;
background: #353942;
height: 50px;
position: relative;

}
 .curl {
width:120px;
height:120px;
position: absolute;
top:0;
left:0;
background : 
    linear-gradient(
        135deg, 
        #fff, 
        #f3f3f3 45%, 
        #ddd 50%, 
        #aaa 50%, 
        #bbb 56%, 
        #ccc 62%, 
        #f3f3f3 80%,
        #fff 100%
    );
box-shadow : 0 0 10px rgba(0, 0, 0, .5);
transition: all .5s ease;
}
.curl:before,
.curl:after {
content: '';
position: absolute;
z-index: -1;
left: 12.5%;
bottom: 5.8%;
width: 70%;
max-width: 300px;
max-height: 100px;
height: 55%;
box-shadow: 0 12px 15px rgba(0, 0, 0, .3);
transform: skew(-10deg) rotate(-6deg);
}
.curl:after {
left: auto;
right: 5.8%;
bottom: auto;
top: 14.16%;
transform: skew(-15deg) rotate(-84deg);
}

.curl:hover {
width: 240px;
height: 240px;
}
.curl:hover:before,
.curl:hover:after {
box-shadow: 0 24px 30px rgba(0, 0, 0, .3);
}

关于html - 如何创建此 CSS3 页面 curl 效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24603293/

相关文章:

javascript - 如何在不破坏代码的情况下删除链接

javascript - 向表中添加一行

css - Bootstrap v4 中 $container-max-width 和 $grid-breakpoint 之间有关系吗?

javascript - css 转换中的奇怪行为 :rotate

jquery - 如何从该控件包含的字符中获取 html 控件的宽度(以像素为单位)

javascript - 根据变量/条件重新排序 li 项

javascript - 如何在窗口中弹出?

html - 我可以在元标记中使用 HTML 字符实体吗?

Javascript 表单验证,在 <input> 旁边显示错误消息

php - 图像随机标题有问题