增加宽度并减小色带尺寸

时间:2014-02-22 16:53:54

标签: css css3

我从http://cssdeck.com/labs/pure-css3-smooth-ribbon-with-borders

获取了以下代码

HTML代码是:

<div id="ribbon">

<div class="inset"></div>

<div class="container">
    <div class="base"></div>
    <div class="left_corner"></div>
    <div class="right_corner"></div>
</div>

CSS代码是:

#ribbon {
width: 180px;
 height: 280px;
 margin: 0px;
 position: relative;
 overflow: hidden;
}

#ribbon .inset {
width: 200px;
 height: 55px;
 position: absolute;
 top: -50px;
 left: -10px;
 z-index: 5;

-webkit-border-radius: 50%;
-moz-border-radius: 50%;
 border-radius: 50%;

background: rgba(0,0,0,0.3);

box-shadow: 0px 5px 10px 0px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 5px 10px 0px rgba(0,0,0,0.3);
-webkit-box-shadow: 0px 5px 10px 0px rgba(0,0,0,0.3);
}

#ribbon .container {
 position: relative;
 width: 100px;
 height: 250px;
 overflow: hidden;
 margin: 0 auto;
 border-left: 1px solid #631a15;
 border-right: 1px solid #631a15;
}

#ribbon .base {
 height: 200px;
 width: 100px;

background: rgb(199,59,60);
background: -moz-linear-gradient(top,  rgba(199,59,60,1) 0%, rgba(184,32,31,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(199,59,60,1)), color-stop(100%,rgba(184,32,31,1)));
background: -webkit-linear-gradient(top,  rgba(199,59,60,1) 0%,rgba(184,32,31,1) 100%);
background: -o-linear-gradient(top,  rgba(199,59,60,1) 0%,rgba(184,32,31,1) 100%);
background: -ms-linear-gradient(top,  rgba(199,59,60,1) 0%,rgba(184,32,31,1) 100%);
background: linear-gradient(top,  rgba(199,59,60,1) 0%,rgba(184,32,31,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c73b3c', endColorstr='#b8201f',GradientType=0 );

 position: relative;
 z-index: 2;
}

#ribbon .base:after {
 content: '';
position: absolute;
top: 0;
 width: 86px;
left: 6px;
 height: 242px;
 border-left: 1px dashed #631a15;
border-right: 1px dashed #631a15;
}

#ribbon .base:before {
 content: '';
position: absolute;
 top: 0;
width: 86px;
 left: 7px;
height: 242px;
 border-left: 1px dashed #da5050;
border-right: 1px dashed #da5050;
}

#ribbon .left_corner {
 width: 100px;
height: 100px;
 background: #b8201f;
 position: absolute;
 bottom: 20px;
left: -50px;
 z-index: 1;

-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
 -o-transform: rotate(45deg);
transform: rotate(45deg);
}

#ribbon .right_corner {
width: 100px;
height: 100px;
 background: #b8201f;
position: absolute;
bottom: 20px;
right: -50px;
 z-index: 1;

-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}

我想增加色带的宽度(至250px)并降低高度(至140px)。

我该怎么做?

我还在学习CSS。 我还想在上面编码形成的色带顶部插入一个图像。

请帮忙!

2 个答案:

答案 0 :(得分:2)

你去兄弟:)检查 DEMO1 DEMO2

#ribbon .base {
  height: 140px;
  width: 250px;
}

更改了.left_arrow.right_arrow值以使其适合。在小提琴上查看它并问我是否需要任何澄清。

答案 1 :(得分:1)

宽度250px,高度140px完成..
See this fiddle
HTML

<div id="ribbon">
    <div class="inset"></div>
    <div class="container">
        <div class="base"></div>
        <div class="left_corner"></div>
        <div class="right_corner"></div>
    </div>
</div>

<强> CSS

#ribbon {
    width: 350px;
    height: 280px;
    margin: 50px auto 0;
    position: relative;
    overflow: hidden;
}

#ribbon .container {
    position: relative;
    width: 250px;
    height: 140px;
    overflow: hidden;
    margin: 0 auto;
    border-left: 1px solid #631a15;
    border-right: 1px solid #631a15;
}

#ribbon .base {
    height: 80px;
    width: 250px;

    background: rgb(99,59,60);
    background: -moz-linear-gradient(top,  rgba(199,59,60,1) 0%, rgba(184,32,31,1) 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(199,59,60,1)), color-stop(100%,rgba(184,32,31,1)));
    background: -webkit-linear-gradient(top,  rgba(199,59,60,1) 0%,rgba(184,32,31,1) 100%);
    background: -o-linear-gradient(top,  rgba(199,59,60,1) 0%,rgba(184,32,31,1) 100%);
    background: -ms-linear-gradient(top,  rgba(199,59,60,1) 0%,rgba(184,32,31,1) 100%);
    background: linear-gradient(top,  rgba(199,59,60,1) 0%,rgba(184,32,31,1) 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c73b3c', endColorstr='#b8201f',GradientType=0 );

    position: relative;
    z-index: 2;
}

#ribbon .base:after {
    content: '';
    position: absolute;
    top: 0;
    width: 234px;
    left: 6px;
    height: 132px;
    border-left: 1px dashed #631a15;
    border-right: 1px dashed #631a15;
}

#ribbon .base:before {
    content: '';
    position: absolute;
    top: 0;
    width: 234px;
    left: 7px;
    height: 132px;
    border-left: 1px dashed #da5050;
    border-right: 1px dashed #da5050;
}

#ribbon .left_corner {
    width: 150px;
    height: 100px;
    background: #b8201f;
    position: absolute;
    bottom: 15px;
    left: -45px;
    z-index: 1;

    -webkit-transform: rotate(50deg);
    -moz-transform: rotate(50deg);
    -ms-transform: rotate(50deg);
    -o-transform: rotate(50deg);
    transform: rotate(145deg);
}

#ribbon .right_corner {
    width: 150px;
    height: 100px;
    background: #b8201f;
    position: absolute;
    bottom: 15px;
    right: -45px;
    z-index: 1;

    -webkit-transform: rotate(35deg);
    -moz-transform: rotate(35deg);
    -ms-transform: rotate(35deg);
    -o-transform: rotate(35deg);
    transform: rotate(35deg);
}

#ribbon .inset {
    width: 400px;
    height: 55px;
    position: absolute;
    top: -50px;
    left: -20px;
    z-index: 5;

    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    border-radius: 50%;

    background: rgba(0,0,0,0.3);

    box-shadow: 0px 5px 10px 0px rgba(0,0,0,0.3);
    -moz-box-shadow: 0px 5px 10px 0px rgba(0,0,0,0.3);
    -webkit-box-shadow: 0px 5px 10px 0px rgba(0,0,0,0.3);
}