Create Ribbon With Css
I have sidebar menu finally created. now I need create ribbon on selected item like show image (red) (I need really gray color ribbon). But I don't want use image background and us
Solution 1:
this will have to be adapted to your needs, but something using pseudo elements would make this possible:
.box{
height:300px;
width:300px;
box-shadow:inset 0015px#222;
position:relative;
margin:0 auto;
background:gray;
}
.active{
position:absolute;
top:30px;
left:-5%;
height:30px;
width:105%;
background:tomato;
border-radius: 5px000;
}
.active:before{
content:"";
position:absolute;
height:16px;
top:5px;
left:0;
width:100%;
border-top:2px dashed red;
border-bottom:2px dashed red;
}
.active:after{
content:"";
position:absolute;
right:-10px;
height:20px;
width:20px;
top:5px;
background:tomato;
border-radius: 05px00;
transform:rotate(45deg);
}
.activea{
position:absolute;
top:0;
left:0;
height:100%;
width:100%;
text-align:center;
display:inline-block;
text-decoration:none;
line-height:30px;
}
.activea:after{
content:"";
position:absolute;
bottom:-15px;
left:6px;
height:30px;
width:30px;
background:darkred;;
transform:rotate(45deg);
z-index:-2;
}
<divclass="box"><divclass="active"><ahref="#">some text</a></div></div>
note
the transform property will require prefixes as well.
Solution 2:
it's real with CSS3.
maybe like this:) but you need to customize.
html:
* {
box-sizing: border-box;
}
.container {
width: 80%;
max-width: 1000px;
height: 80px;
margin: 40px auto;
position: relative;
}
.one > div {
height: 50px;
}
.main {
background: #0fadc0;
position: relative;
display: block;
width: 90%;
left: 50%;
top: 0;
padding: 5px;
margin-left: -45%;
z-index: 10;
}
.main > div {
border: 1px dashed #fff;
border-color: rgba(255, 255, 255, 0.5);
height: 40px;
}
.bk {
background: #1199a9;
position: absolute;
width: 8%;
top: 12px;
}
.bk.l {
left: 0;
}
.bk.r {
right: 0;
}
.skew {
position: absolute;
background: #0c7582;
width: 3%;
top: 6px;
z-index: 5;
}
.skew.l {
left: 5%;
transform: skew(00deg, 20deg);
}
.skew.r {
right: 5%;
transform: skew(00deg, -20deg);
}
.bk.l > div {
left: -30px;
}
.bk.r > div {
right: -30px;
}
.arrow {
height: 25px!important;
position: absolute;
z-index: 2;
width: 0;
height: 0;
}
.arrow.top {
top: 0px;
border-top: 0px solid transparent;
border-bottom: 25px solid transparent;
border-right: 30px solid #1199a9;
}
.arrow.bottom {
top: 25px;
border-top: 25px solid transparent;
border-bottom: 0px solid transparent;
border-right: 30px solid #1199a9;
}
.r.bottom {
border-top: 25px solid transparent;
border-bottom: 0px solid transparent;
border-left: 30px solid #1199a9;
border-right: none;
}
.r.top {
border-bottom: 25px solid transparent;
border-top: 0px solid transparent;
border-left: 30px solid #1199a9;
border-right: none;
}
@media all and (max-width: 1020px) {
.skew.l {
left: 5%;
transform: skew(00deg, 25deg);
}
.skew.r {
right: 5%;
transform: skew(00deg, -25deg);
}
}
@media all and (max-width: 680px) {
.skew.l {
left: 5%;
transform: skew(00deg, 30deg);
}
.skew.r {
right: 5%;
transform: skew(00deg, -30deg);
}
}
@media all and (max-width: 460px) {
.skew.l {
left: 5%;
transform: skew(00deg, 40deg);
}
.skew.r {
right: 5%;
transform: skew(00deg, -40deg);
}
}
<!-- RIBBON 1 --><divclass="container one"><divclass="bk l"><divclass="arrow top"></div><divclass="arrow bottom"></div></div><divclass="skew l"></div><divclass="main"><div></div></div><divclass="skew r"></div><divclass="bk r"><divclass="arrow top"></div><divclass="arrow bottom"></div></div></div>
https://jsfiddle.net/5pu4rqr8/
this is a pure copy/paste from @willpaige's CodePen
Post a Comment for "Create Ribbon With Css"