3
How did I respond in How to Make Tilt Button? and Button diagonally only the left side, you can use pseudo elements:
.main-banner {
width: 600px;
height: 200px;
background: #ccc;
position: relative;
}
.main-banner > .banner-img {
background: #fc0;
position: absolute;
top: 0;
right: 0;
width: 50%; /* pode ajustar a largura do Element 2 (foto)*/
height: 100%;
}
.main-banner > .banner-l {
color: #fff;
position: relative;/*faz os elementos pseudos acompanharem o elemento com a classe*/
width: 50%; /* pode ajustar a largura do Element 1 (verde)*/
height: 100%; /*Acompanha a altura do elemento*/
/* altera a cor, deve ser a mesma corda do border no :before*/
background-color: #01b215;
}
.banner-l:before {
content: "";
width: 0px;
height: 0px;
top: 0px;
position: absolute;
/*ajuste aqui*/
border-top: 200px solid transparent;
border-left: 100px solid #01b215; /*altere a cor aqui, deve ser a mesma cor do background-color no banner-l*/
right: -100px;
}
<div class="main-banner">
<div class="banner-img">Banner</div>
<div class="banner-l">Left</div>
</div>
Explanations:
border-top: 200px solid transparent;
200px should be the same height asmain-banner
, adjusting the height should adjust here.border-left: 100px solid #CC0000;
it must have the same measure as theright
, however with the positive value, a must be the same as the background-color in the selector.banner-l
right: -100px;
it must have the same value asborder-left
, however it must be the negative value.
I think this might solve your problem. Solution
– David Fornazier
skew does not solve, so much so that in the accomplished fiddle itself, the image is distorted
– Murilo Melo