Ivanのおかげで、私は希望の出力を作成することができました。 これはCSSになると最悪ですので、これを多く改善することができます。ブートストラップと、次のCSSを使用した
は
次のHTML
<body>
<div class="d">
<div class="col-md-12 col-md-offset-3">
<img class="pic l" src="http://solarsystem.nasa.gov/images/galleries/618486main_earth_320.jpg" id="leftImage">
<img class="pic r" src="http://solarsystem.nasa.gov/images/galleries/618486main_earth_320.jpg" id="rightImage">
</div>
</div>
</body>
で
.l {
clip-path: polygon(0% 0%, 100% 0%, 80% 100%,0% 100%);
filter: grayscale(100%);
position:absolute;
z-index: 2;
}
.r {
left: 540px;
margin-left: -20%;
clip-path: polygon(20% 0%, 100% 0%, 100% 100%,0% 100%);
filter: grayscale(100%);
position:absolute;
z-index: 1;
}
.d {
position:relative
}
を含み、これは(canEnter変数が最善の解決策にはほど遠いですが、それは何もないよりはましだ)JS:
を
window.onload = function(){
var canEnter = true;
$('#leftImage')[0].hX2 = $('#leftImage').height() * 2;
$('#leftImage')[0].h = $('#leftImage').height();
$('#leftImage').on('mouseenter', function(){
if (!canEnter)
return;
canEnter = false;
this.style.filter = 'none';
this.style.zIndex = 2;
this.style.clipPath = 'none';
$(this).animate({height: $('#leftImage')[0].hX2}, "fast");
});
$('#leftImage').on('mouseleave', function(){
$(this).animate({height: $('#leftImage')[0].h}, "fast", function(){
this.style.filter = 'grayscale(100%)';
this.style.zIndex = 1;
this.style.clipPath = 'polygon(0% 0%, 100% 0%, 80% 100%, 0% 100%)';
if (!canEnter)
canEnter = true;
});
});
$('#rightImage').on('mouseenter', function(){
if (!canEnter)
return;
canEnter = false;
this.style.filter = 'none';
this.style.zIndex = 2;
this.style.clipPath = 'none';
$(this).animate({height: $('#leftImage')[0].hX2, left: 300}, "fast");
});
$('#rightImage').on('mouseleave', function(){
$(this).animate({height: $('#leftImage')[0].h, left: 540}, "fast", function(){
this.style.filter = 'grayscale(100%)';
this.style.zIndex = 1;
this.style.clipPath = 'polygon(20% 0%, 100% 0%, 100% 100%, 0% 100%)';
if (!canEnter)
canEnter = true;
});
});
}
これを達成するために試行したことの証拠で質問する必要がありますゴール。私たちはあなたのためにそれをしないためにここにいます。 – Sicae
はい、わかっています。私はちょうどこのアイデアを持っていたので、使用できるテンプレートがあると思ったので、0から始める必要はありません – sundri23
あなたがしようとすると、あなたのコードを共有してください。 –