Reputation: 152657
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;
}
Upvotes: 3
Views: 1121
Reputation: 92803
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;
}
Upvotes: 2
Reputation: 93276
I would remove the border, padding, and background color from the box
class and add it to the image inside:
.box { position:relative; overflow:hidden;}
.box img {
border:2px solid green;
padding: 10px;
background:#ccc;
}
Upvotes: 0
Reputation: 2471
Try this fiddle:
Basically, move the border and the background and padding to the image, and that way, the div.box
can display till the edge and hide the rest.
Upvotes: 1