I am working on a project that calls for two triangles to hold background images, and be links.
Here is my mock up for how I would like the two triangles.
Currently, I have just two divs that span the 900x600 with each triangle as a background image. The issue I am having now is I can't hover over the transparent part of the Cinema div to reach the photo div.
Can I accomplish this design with css3 triangles and set their background images? I always thought the custom shape is made up from a border, with a border-color.
Is it possible to do with css3 triangles, and if so, can someone help me with the code?
Here is what I currently have.
.pageOption {
position: relative;
width: 900px;
height: 600px;
}
.pageOption .photo {
position: absolute;
top: 0px;
left: 0px;
width: 900px;
height: 600px;
background: url('../images/menuPhoto.png') no-repeat 0 0;
}
.pageOption .cinema {
position: absolute;
bottom: 0px;
right: 0px;
width: 900px;
height: 600px;
background: url('../images/menuCinema.png') no-repeat 0 0;
}
<div class="pageOption">
<a href="#" class="option photo" id="weddingPhoto"></a>
<a href="#" class="option cinema" id="weddingCinema"></a>
</div>
Here are my CSS suggestions:
Rotate transition:
It's really easy if you use child images for the links instead of background images. You just need to skew the two
.option
elements with different transform origins, then unskew their child images and setoverflow: hidden
on both.pageOption
and the.option
elements. Support is good, should work for everything except IE8/7 and Opera Mini.DEMO
Result:
HTML:
Relevant CSS:
As you said, css3 tringles are made of borders so you can't attach backgrounds to them.
I would suggest you to just to use two PNGs one upon the other and to use js in order listen to the click event and create the correct action based on the mouse position.
There is also a webkit-mask css property but it very unsupported in other browsers (I used it for a little pageing pilling trick - http://jsfiddle.net/xTNTH/3/ - best on safari [no js only css] - http://snag.gy/7fRNq.jpg)
You can achive this layout with several approaches. Here is an example using an inline svg and the clip-path element: