We are looking to obtain exactly this type of border for almost all img tags inside the content area of a CMS (wordpress/joomla) site (that's why we are searching for a solution using only CSS, without accesing any parent tag):
First step goes smoothly with the code form here: http://border-image.com/ (the link should show our border image used), but it creates a space between the image and the edge of the actual border.
We first tried some CSS rules that could do the job, but:
border-image-outset
: it only extends to outside, not inside, helps for cases where background is solid coloroutline-offset
: works only for the outline, doesn't affects the border-image- Multiple Backgrounds: Is the nearest one, but the borders show BELOW the image, so it needs to have a padding applied. We are expecting it to be partially over the image as intended (indeed it is what we've implemented until now).
We have already found many similar questions and tried using the most applicable answers:
::after
: it needs the image to have content="" which disappears it.- jquery
$(img).after
: We can't position the border elements relatively to the correspondent image, as they are precisely inserted AFTER the image (the same with before). We would require to set this on the parent tag which most times doesn't has the same size of the img. We are at the moment trying some wrap.
Until now we haven't been able to solve the problem as intended.
Here's a JSfiddle where we are making tests with all above 5 options and have enough material to work (neat image, grouped and separated corners, all mentioned codes appliead, etc).
We would really appreciate somebody achieving the exact result applicable for the img tag.