I want to create triangle as shown in image. Does someone know how to achieve the effect?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
- Adding a timeout to a render function in ReactJS
Triangle shape clip mask using CSS to clip image so that background appear.
You can achieve this kind of masking using clip property of CSS With SVG.
HTML
CSS
I have mask with an image tag you can also use this with div element or any other tag.
Check a working demo here. http://jsfiddle.net/VijayDhanvai/495rpzdb/
With newer browsers, you can use the
clip-path
CSS property. This is much less hacky, but you'll need a fallback for IE/Edge and older browsers.Example
Here is a fiddle that should solve your problem. I used :before and :after on a container to place two squares over the container with borders to create the arrows. You can mess with the border colors and widths to get the arrows how you want them (just remember the inside borders have to be the same weight to make an symmetrical triangle).
http://jsfiddle.net/Smzmn/
Imagine the area with photo is split down the middle into two squares, with the photo as a background.
Now imagine you give those squares very thick top and bottom borders with colours corresponding to the areas above and below the photo.
Now imagine you also give them a very thick border for each of their adjacent sides (the left square has a right border, the right square has a left border), but this time, you make the border transparent.
You will see that where the top/bottom borders and the side borders meet, there is a diagonal edge between them where the colour changes to transparent. This leaves a transparent triangle in the adjacent corners where the background shows through.