I am trying to create a content box that has a zig zag border around all sides, similar to this:
This is what I have, but I can’t get the zig zags on the sides. Also, I don’t know how to get the borders to have opacity. I can get the main content opaque, but not the sides.
This is what I have:
Can anyone help me with this?
This is the sort of thing I would probably use
border-image for, as Paul linked to in your other topic.
Just a small PNG with alpha, or SVG would do it.
I did something simialr once where I had a paper texture as the background of a container, then had torn edges all around.
I agree with @SamA74, such small image could even be a data url (base64 png).
Thanks for the replies. Yes, I have seen the border-image property, but wondered if it is do-able with just CSS
I will have a play around
Here’s 2 demos using svg and linear gradients.
I haven’t had time to play around with the border-image method as my computer crashed and wasted a day restoring it.
Thanks @PaulOB I really appreciate your time helping with this. The third one in the examples is great and I will have a play with that.
Hope your computer is ok! I hate it when that happens, it’s the little things that you miss like shortcuts etc
I added a border-image example which doesn’t need the extra background overlaid. However it’s a bit complex as I used an inline svg as the border-image. I’m sure it could be improved with a bit of time and effort…
Yes it’s a pain but luckily I have time machine backup on the mac so I restored everything back to last week which seems to have worked (fingers crossed).
I had a go last night.
Which I did not get around to finishing until just now.
border-image with an SVG as a data URL, rather than a file.
Thank you @SamA74 too that is awesome
Good job. Much better than my attempt
I have had a play with @PaulOB’s version, but can’t seem to get the transparency right.
This is my code:
$slider_title = get_the_title();
<span>'.esc_html($slider_title). ' '. '</span>';
<?php the_excerpt(); ?>
<?php //echo zigcy_lite_get_excerpt_content(absint($zigcy_lite_slider_excerpts));?>
<a class="slider-button" href="
<?php the_permalink(); ?>">
<?php echo esc_html('shop Now','zigcy-lite'); ?>
The content inside the
class is also opaque. I have tried adding another
div inside the
div and set that to
opacity: 1, but it is still showing opaque.
What would be the way round this to get the content to appear without any opacity and the
jagged part/background to have opacity?
Just going offline but if you placed the new inner div absolutely and moved all the rules to the inner div including the :after rules for the new div then on the outer div you’d just have position relative and no other styling apart from dimensions if needed. The content then would not be part of the opacity.
I updated example 3 with the above code.
However I suggest you go with Sams example as it won’t suffer from that issue.
Thank you, that, that worked perfectly I will have a play with both examples.
Thanks everyone for all your great help as usual
Just for fun I simplified my border-image example and gave it a more ragged appearance rather than the uniform edges.
You can edit the color and opacity of the svg directly in the svg code (which is an inline value in the border-image css).
If you want to draw a better svg then this online tool will help you.
Thanks for these examples.
I am trying to change the opacity of the SVG/background and keep the text content 100% opacity, but I can’t see where it is inline.
Should I be looking at this part?
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80'><polygon points='40 0,0 40,40 80,80 40' style='fill:red;fill-rule:nonzero;'></polygon></svg>");?
For the last example it’s here.
polygon style='fill:red;fill-opacity:0.7;' points='0 -1 13 20 4 32 15 45 2 51
You were looking at the code from the other example which can’t be made transparent otherwise the background gets a double transparency in places.
The last example in that codepen is the best version as it also paints the background.
I think I am looking at the wrong example. I can only see this one:
Or am I missing something?