We are on the lookout for a way to apply a specific border style to nearly all img tags within the content area of a CMS (such as Wordpress or Joomla). Our goal is to achieve this solely using CSS without having to access any parent tags:
The initial step is straightforward with the code found here: http://border-image.com/ (the link should display our border image), but it results in a gap between the image and the border edge.
We initially tried some CSS properties that seemed promising, but encountered roadblocks:
border-image-outset
: only extends to the outer side, not the inner side, useful for solid background colorsoutline-offset
: only works for outlines, not border images- Multiple Backgrounds: the most viable option, but the borders appear below the image, necessitating additional padding. We want them to overlap the image as intended (which is what we have currently implemented).
We have explored similar questions and attempted to implement the most relevant solutions:
::after
: requires the image to have content="", which makes it disappear- JQuery
$(img).after
: We are unable to position the border elements relative to the corresponding image since they are inserted after the image itself. This would require setting it on the parent tag, which often doesn't have the same dimensions as the image. We are currently experimenting with wrapping.
So far, we have not been successful in resolving the issue as intended.
Here's a JSFiddle where we are testing all the aforementioned options and have sufficient resources to work with (clean image, grouped and separated corners, all mentioned codes applied, etc).
We would greatly appreciate it if someone could help us achieve the desired outcome for the img tag.