Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep border inside to take ribbon over to div?

Tags:

css

In this example http://jsfiddle.net/aNmvc/15/ the red ribbon should touch the the edges of div which has border. How to achieve that? Is there a way to get border inside or something else?

HTML

<div class="box">
  <div class="corner">
  <span href="#">Best Ribbon around</span>  
   </div>
   <img src="http://lorempixel.com/250/300/sports/1/">
</div>

CSS

.box {border:2px solid green; position:relative;padding:3%; width:260px; background:#ccc; overflow:hidden;}

.corner {
    background-color: #a00;
    overflow: hidden;
    position: absolute;
    left: -3em;
    top: 2.5em;
    -moz-transform: rotate(-45deg);
    -webkit-transform: rotate(-45deg);
    transform: rotate(-45deg);

}
.corner span {
    border: 1px solid #faa;
    color: #fff;
    display: block;
    font-size:.8em;
    font-weight:bold;
    padding: 0.5em 4em;
    text-align: center;
    text-decoration: none;
    text-shadow: 1px 1px 1px #000;
}

enter image description here

like image 479
Jitendra Vyas Avatar asked Nov 30 '25 17:11

Jitendra Vyas


1 Answers

I know you accept @inderanil answers but you can do this with box-shadow property like this:

.box {
    position:relative;
    padding:3%;
    width:260px;
    background:#ccc;
    overflow:hidden;
    -moz-box-shadow: 0 0 0 2px green inset;
    -webkit-box-shadow: 0 0 0 2px green inset;
    box-shadow: 0 0 0 2px green inset;
}

http://jsfiddle.net/aNmvc/18/

like image 117
sandeep Avatar answered Dec 03 '25 10:12

sandeep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!