I am trying to create a design in which the images are octagonal. I used a border hack, but the image should be inside the octagon shape. Using pesudo elements is not suitable in this case, since the body will also have its own background image. Is it possible with css?

My code
div {
width: 100vh;
height: 100vh;
background: gold;
position: relative;
}
div:before {
content: "";
position: absolute;
top: 0;
left: 0;
border-bottom: 29vh solid gold;
border-left: 29vh solid white;
border-right: 29vh solid white;
width: 42vh;
height: 0;
}
div:after {
content: "";
position: absolute;
bottom: 0;
left: 0;
border-top: 29vh solid gold;
border-left: 29vh solid white;
border-right: 29vh solid white;
width: 42vh;
height: 0;
}
<div></div>
Run codeHide resultI wanted this image to be in the golden area: http://images.visitcanberra.com.au/images/canberra_hero_image.jpg . In addition, I used vh so that it responds to the height of the window.
user4471047
source
share