Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

css - How To Add Zig Zag Border to a Box contains background image

I already find following perfect CSS snippet which creates zip zag border at this link.

.h-zigzag {
    background:
        linear-gradient(-135deg, #333538 5px, transparent 0) 0 5px,
        linear-gradient(135deg, #333538 5px, #fff 0) 0 5px;
    background-color: #333538;
    background-position: left bottom;
    background-repeat: repeat-x;
    background-size: 10px 10px;
}

As you can see the code create a perfecr zig zag border but I need to add this border to a box which contains an image as:

 .h-zigzag {
   background: url(../img/grrenfooter.png) repeat-x top left scroll transparent;
 }

can you please help me to mix them? I already tried several ways but the image disappears when I mix them!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can do that, but you need masking, and as far as I know it is only available in webkit.

#zigzag {
    width: 600px;
    height: 400px;
    -webkit-mask-image: linear-gradient(0deg, transparent 30px, white 30px), linear-gradient(-135deg, white 15px, transparent 15px), linear-gradient(135deg, white 15px, transparent 15px);
    -webkit-mask-position: left bottom;
    -webkit-mask-repeat: repeat-x;
    -webkit-mask-size: 100% 100%, 30px 30px, 30px 30px;
    background: url("http://placekitten.com/1000/750");
    background-size: cover;
}

body {
    background-image:  repeating-linear-gradient(20deg, lightgreen, lavender 40px);   
}
<div id="zigzag"></div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...