0

I have been seeing a lot of new websites that have a zigzagged border in between an image and a div. When you open the image in a new tab the zigzag is not there, so it was created either with CSS3 or HTML5. Does anyone know how it is done?

Here are some examples:

Wait for them to load.

byrass
  • 360
  • 2
  • 12

2 Answers2

1

First one is built with repeatable background image, and secound one with :before pseudo element:

.ss-style-top::before {
  position: absolute;
  content: '';
  left: 0;
  width: 100%;
  height: 30px;
  background-size: 25px 100%;
  top: 0;
  background-image: linear-gradient(315deg, #FFF 50%, transparent 50%), 
  linear-gradient(45deg, #FFF 50%, transparent 50%);
  margin-top: -30px;
  z-index: 100;
}

Here is the link of background image from first example: http://www.cssvillain.com/hungry/images/assets/parallax-bottom-alt.png

Danko
  • 1,819
  • 1
  • 13
  • 12
1

zig zag borders are made using linear-gradient

  • 50% is the blur
  • 315deg is the rotation of right side
  • 45deg is the rotation of left side
  • background size is the width and placement of the triangle

div {
  width: 100%;
  height: 50px;
  background-size: 25px 120%;
  background-image: linear-gradient(315deg, red 50%, rgba(0, 0, 0, 0) 50%), 
                    linear-gradient(45deg, red 50%, black 50%);
}
<div></div>

you can also change the angle of rotation by changing the deg values

div {
  width: 100%;
  height: 50px;
  background-size: 25px 150%;
  background-image: linear-gradient(297deg, red 50%, rgba(0, 0, 0, 0) 50%), 
                    linear-gradient(63deg, red 50%, black 50%);
}
<div></div>
Vitorino fernandes
  • 15,794
  • 3
  • 20
  • 39