based on this question
How to add a gradient border above image (diagonal border)
I want to make the same but on an small div, but the diagonal line doesn't fit the borders
Here is the fiddle
http://jsfiddle.net/wo8gbhx3/36/
HTML
<div class="testing">
<ul>
<li class="selected unavailable">
<a href="#">
<img src="http://placehold.it/25x25"/>
</a>
</li>
</ul>
</div>
And the CSS
.testing ul {
list-style: none;
}
.testing ul li {
width: 20px;
height: 18px;
}
.testing ul li img {
width: 100%;
height: 100%;
display: block;
}
.unavailable {
position: relative;
}
.unavailable a:after {
content: '';
width: 100%;
height: 100%;
top: 0;
left: 0;
position: absolute;
background: repeating-linear-gradient(135deg, transparent, transparent 16px, #000 18px);
z-index: 2;
}
Adjust the spacing in the
background
property of the.unavailable a:after
rule:Also, since the you have specified a 135 degree angle, this works best on a square. So I've adjusted the width and height of the div to be equal:
Alternatively you can play with the angle to get it corner to corner for a rectangle, but the line may look rough.
Example: http://jsfiddle.net/wo8gbhx3/39/