前端集合 - 关注前端技术和互联网免费资源

关注前端技术和互联网免费资源

分类儿

页面儿

搜索儿

前端集合 RSS订阅
Home » 前端集合 » 高级css3技巧:纯css制作的box

高级css3技巧:纯css制作的box

发布者:前端集合 // 发布时间:2011-06-08 10:59:00 // 分类:前端集合 // 访问: 3,822 次 // 热度:

1. 第一种效果

image


/* This establishes the design of the boxes' paragraphs */
.box1 p, .box2 p, .box3 p, .box4 p, .box5 p, .box6 p, .box7 p, .box9 p, .box10 p, .box11 p, .box12 p, .box13 p, .box14 p, .box15 p, .box16 p{
margin: 30px;
color: #aaa;
outline: none;
}

/* In this selector we specify  the width, height, borders, position, background color, color and shadow's dimensions */
.box1{
    width: 300px;
    margin: 40px;
    min-height: 200px;
    position:relative;
    display: inline-block;
    background:#fff;
    background: -webkit-gradient(linear, 0% 20%, 0% 1000%, from(#fff), to(#fff), color-stop(.1,#f3f3f3));
    background: -moz-linear-gradient(0% 0%, #fff, #f3f3f3 10%, #fff);
    border: 1px solid #ccc;
    -webkit-box-shadow: 0px 3px 30px rgba(0, 0, 0, 0.1) inset;
    -moz-box-shadow: 0px 3px 30px rgba(0, 0, 0, 0.1) inset;
    box-shadow: 0px 3px 30px rgba(0, 0, 0, 0.1) inset;
    -webkit-border-bottom-right-radius: 6px 50px;
    -moz-border-radius-bottomright: 6px 50px;
    border-bottom-right-radius:6px 50px;
}

/* On this pseudo class we specify the design that goes prior the box1 class, in this case it's the shadow placed at the bottom of this box, here's where we determine the measures, rotation and skew of the shadow itself */
.box1:before{
    content: '';
    width: 50px;
    height: 100px;
    position:absolute;
    bottom:0; right:0;
    -webkit-box-shadow: 20px 20px 10px rgba(0, 0, 0, 0.1);
    -moz-box-shadow: 20px 20px 15px rgba(0, 0, 0, 0.1);
    box-shadow: 20px 20px 15px rgba(0, 0, 0, 0.1);
    z-index:-1;
    -webkit-transform: translate(-35px,-40px)
                        skew(0deg,30deg)
                        rotate(-25deg);
    -moz-transform: translate(-35px,-40px)
                        skew(0deg,32deg)
                        rotate(-25deg);
    -o-transform: translate(-35px,-40px)
                        skew(0deg,32deg)
                        rotate(-25deg);
}

/* On this pseudo class we specify the design that goes prior the box1 class, in this case it's the shadow placed on top of the box, here's where we determine the measures, rotation and the skew of the shadow itself*/
.box1:after{
    content: '';
    width: 100px;
    height: 100px;
    top:0; left:0;
    position:absolute;
    display: inline-block;
    z-index:-1;
    -webkit-box-shadow: -10px -10px 10px rgba(0, 0, 0, 0.2);
    -moz-box-shadow: -10px -10px 15px rgba(0, 0, 0, 0.2);
    box-shadow: -10px -10px 15px rgba(0, 0, 0, 0.2);
    -webkit-transform: rotate(2deg)
                        translate(20px,25px)
                        skew(20deg);
    -moz-transform: rotate(7deg)
                        translate(20px,25px)
                        skew(20deg);
    -o-transform: rotate(7deg)
                        translate(20px,25px)
                        skew(20deg);
        transform: rotate(7deg)
                        translate(20px,25px)
                        skew(20deg);
}

2. 第二种效果

image


/* This is the selector of the seventh box, here's where we establish the measures, background colors, borders and shadows */
.box7{
    margin: 50px;
    width: 320px;
    min-height: 150px;
    padding: 0 0 1px 0;
    position:relative;
    background: #fff;
    background: -webkit-gradient(linear, 0% 20%, 0% 92%, from(#fff), to(#f3f3f3), color-stop(.1,#fff));
    background: -moz-linear-gradient(0 0 270deg, #fff, #fff 10%, #f3f3f3);
    border-top: 1px solid #ccc;
    border-right: 1px solid #ccc;
    border-left: 1px solid #ccc;
    -webkit-box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.2);
    -moz-box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.2);
    box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.2);
}

/* This is the top left tape */
.box7:before{
    content: '';
    position:absolute;
    width: 130px;
    height: 30px;
    border-left: 1px dashed rgba(0, 0, 0, 0.1);
    border-right: 1px dashed rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.1);
    background: -webkit-gradient(linear, 555% 20%, 0% 92%, from(rgba(0, 0, 0, 0.1)), to(rgba(0, 0, 0, 0.0)), color-stop(.1,rgba(0, 0, 0, 0.2)));
    background: -moz-linear-gradient(555% 0 180deg, rgba(0,0,0,0.1), rgba(0,0,0,0.2) 10%, rgba(0,0,0,0.0));
    -webkit-box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.2);
    -moz-box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.2);
    box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.2);
    -webkit-transform:translate(-50px,10px)
                        skew(10deg,10deg)
                        rotate(-50deg);
    -moz-transform:translate(-50px,10px)
                        skew(10deg,10deg)
                        rotate(-50deg);
        -o-transform:translate(-50px,10px)
                        skew(10deg,10deg)
                        rotate(-50deg);
        transform:translate(-50px,10px)
                        skew(10deg,10deg)
                        rotate(-50deg);
}

/* This is the top bottom right tape */
.box7:after{
    content: '';
    position:absolute;
    right:0;
    bottom:0;
    width: 130px;
    height: 30px;
    background: rgba(0, 0, 0, 0.1);
    background: -webkit-gradient(linear, 555% 20%, 0% 92%, from(rgba(0, 0, 0, 0.1)), to(rgba(0, 0, 0, 0.0)), color-stop(.1,rgba(0, 0, 0, 0.2)));
    background: -moz-linear-gradient(555% 0 180deg, rgba(0,0,0,0.1), rgba(0,0,0,0.2) 10%, rgba(0,0,0,0.0));
    border-left: 1px dashed rgba(0, 0, 0, 0.1);
    border-right: 1px dashed rgba(0, 0, 0, 0.1);
    -webkit-box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.2);
    -moz-box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.2);
    box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.2);
    -webkit-transform: translate(50px,-20px)
                        skew(10deg,10deg)
                        rotate(-50deg);
    -moz-transform: translate(50px,-20px)
                        skew(10deg,10deg)
                        rotate(-50deg);
    -o-transform: translate(50px,-20px)
                        skew(10deg,10deg)
                        rotate(-50deg);
    transform: translate(50px,-20px)
                        skew(10deg,10deg)
                        rotate(-50deg)
}

Demo (里面含有更多样式的box)

VIA

Tags: CSS, css3, css3技巧, box

网页设计素材(1):丝带>>  << 有关本博主题
Top