1

我正在尝试在http://jsfiddle.net/chriscoyier/H6rQ6/1/更改 Chris 的角功能区片段。我希望功能区在左侧而不是右侧

这是我到目前为止所做的http://jsbin.com/imUQula/1/功能区的上部和下部没有改变。我想要上部平水平和底部平垂直

css

.wrapper {
margin: 50px auto;
width: 280px;
height: 370px;
background: white;
border-radius: 10px;
-webkit-box-shadow: 0px 0px 8px rgba(0,0,0,0.3);
-moz-box-shadow:    0px 0px 8px rgba(0,0,0,0.3);
box-shadow:         0px 0px 8px rgba(0,0,0,0.3);
position: relative;
z-index: 90;
}

.ribbon-wrapper-green {
width: 85px;
height: 88px;
overflow: hidden;
position: absolute;
top: -3px;
left: -3px;
}

.ribbon-green {
font: bold 15px Sans-Serif;
color: #333;
text-align: center;
text-shadow: rgba(255,255,255,0.5) 0px 1px 0px;
-webkit-transform: rotate(-45deg);
-moz-transform:    rotate(-45deg);
-ms-transform:     rotate(-45deg);
-o-transform:      rotate(-45deg);
position: relative;
padding: 7px 0;
left: -5px;
top: 15px;
width: 120px;
background-color: #BFDC7A;
background-image: -webkit-gradient(linear, left top, left bottom, from(#BFDC7A),   to(#8EBF45)); 
background-image: -webkit-linear-gradient(top, #BFDC7A, #8EBF45); 
background-image:    -moz-linear-gradient(top, #BFDC7A, #8EBF45); 
background-image:     -ms-linear-gradient(top, #BFDC7A, #8EBF45); 
background-image:      -o-linear-gradient(top, #BFDC7A, #8EBF45); 
color: #6a6340;
-webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
-moz-box-shadow:    0px 0px 3px rgba(0,0,0,0.3);
  box-shadow:         0px 0px 3px rgba(0,0,0,0.3);
}

.ribbon-green:before, .ribbon-green:after {
content: "";
border-top:   3px solid #6e8900;   
border-left:  3px solid transparent;
 border-right: 3px solid transparent;
position:absolute;
bottom: -3px;
}

.ribbon-green:before {
left: 0;
}
.ribbon-green:after {
 right: 0;
}
4

2 回答 2

5

假设我正确理解了您的问题,请对您的 CSS 进行以下更改,以使其按您想要的方式工作:

.wrapper {
  margin: 50px auto;
  width: 280px;
  height: 370px;
  background: white;
  border-radius: 10px;
  -webkit-box-shadow: 0px 0px 8px rgba(0,0,0,0.3);
  -moz-box-shadow:    0px 0px 8px rgba(0,0,0,0.3);
  box-shadow:         0px 0px 8px rgba(0,0,0,0.3);
  position: relative;
  z-index: 90;
  overflow: hidden; /* added to hide the part of the green ribbon which goes out of the wrapper */
}

JSBin 演示

编辑:实际上,我之前提到的更改.ribbon-wrapper-green不是必需的。您可以简单地执行以下操作。

.ribbon-green {
    left: -28px; /* changed from left -5px for the purpose of positioning */
}
于 2013-10-21T09:36:54.350 回答
2

像这样? http://jsfiddle.net/sudheer105/Fnpn7/

.wrapper {
margin: 50px auto;
width: 280px;
height: 370px;
background: white;
border-radius: 10px;
-webkit-box-shadow: 0px 0px 8px rgba(0,0,0,0.3);
-moz-box-shadow:    0px 0px 8px rgba(0,0,0,0.3);
box-shadow:         0px 0px 8px rgba(0,0,0,0.3);
position: relative;
z-index: 90;
}

.ribbon-wrapper-green {
width: 85px;
height: 88px;
overflow: hidden;
position: absolute;
top: -3px;
left: -3px;
}

.ribbon-green {
font: bold 15px Sans-Serif;
color: #333;
text-align: center;
text-shadow: rgba(255,255,255,0.5) 0px 1px 0px;
-webkit-transform: rotate(-45deg);
-moz-transform:    rotate(-45deg);
-ms-transform:     rotate(-45deg);
-o-transform:      rotate(-45deg);
position: relative;
padding: 7px 0;
right: 30px;
top: 15px;
width: 120px;
background-color: #BFDC7A;
background-image: -webkit-gradient(linear, left top, left bottom, from(#BFDC7A),   to(#8EBF45)); 
background-image: -webkit-linear-gradient(top, #BFDC7A, #8EBF45); 
background-image:    -moz-linear-gradient(top, #BFDC7A, #8EBF45); 
background-image:     -ms-linear-gradient(top, #BFDC7A, #8EBF45); 
background-image:      -o-linear-gradient(top, #BFDC7A, #8EBF45); 
color: #6a6340;
-webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
-moz-box-shadow:    0px 0px 3px rgba(0,0,0,0.3);
  box-shadow:         0px 0px 3px rgba(0,0,0,0.3);
}

.ribbon-green:before, .ribbon-green:after {
content: "";
border-top:   3px solid #6e8900;   
border-left:  3px solid transparent;
 border-right: 3px solid transparent;
position:absolute;
bottom: -3px;
}

.ribbon-green:before {
right: 0;
}
.ribbon-green:after {
 left: 0;
}
于 2013-10-21T09:36:36.483 回答