2016-10-20 3 views
1

私は「メニュー」という形で、いくつかの画像を重ねて表示しています。IE7:画像をホバーすると、別の場所に別の画像が表示されます

画像の1つをホバーしている間、別の画像が表示されます。 また、各画像をホバリングしている間に5px(現在は表示されません)まで上がります。

Internet Explorer 7以上をサポートしている必要があります。

私が要求したことが可能であり、本当にあなたが提供できるヘルプに感謝したいと思います。これまで

マイコード:

.hw { font-size: 50px; padding: 50px; } 
 

 
.first { 
 
    position: relative; 
 
    top: 0; 
 
    left: 0; 
 
} 
 

 
.second { 
 
    position: absolute; 
 
    right: 180px; 
 
} 
 

 
.third { 
 
    position: absolute; 
 
    right: 360px; 
 
} 
 

 
.logo { 
 
    position: relative; 
 
    bottom:60px; 
 
    left: 100px; 
 
} 
 

 
.first:hover, .second:hover, third:hover { 
 
    bottom: 5px; 
 
} 
 

 
.hidden { 
 
    display: none; 
 
} 
 

 
.logo:hover .hidden { 
 
    display: block; 
 
}
<!DOCTYPE html> 
 
<html> 
 
<head> 
 
<title>Title</title> 
 
</head> 
 
<body dir="rtl"> 
 
    
 
    <p class="hw">Hello World!</p> 
 
    
 
    
 
    <img class="hidden" src="http://i.imgur.com/MY5bRT1.jpg" style="position: relative; bottom: 80px; right: 500px;"/> 
 
    
 
    <div style="position: relative; left: 0; top: 0;"> 
 
    <img class="first" src="http://i.imgur.com/cr2cqPA.png"/> 
 
    <img class="second" src="http://i.imgur.com/MY5bRT1.jpg"/> 
 
    <img class="third" src="http://i.imgur.com/cr2cqPA.png"/> 
 
    <img class="logo" src="http://i.imgur.com/MY5bRT1.jpg"/> 
 
    </div> 
 

 
</body> 
 
</html>

EDIT:ソリューション:

.hw { 
 
\t font-size: 50px; 
 
\t padding: 50px; 
 
} 
 

 
.menu { 
 
\t margin-right:300px; 
 
} 
 

 
.first { 
 
    position: relative; 
 
    top: 0; 
 
} 
 

 
.second { 
 
    position: absolute; 
 
    right: 180px; 
 
} 
 

 
.third { 
 
    position: absolute; 
 
    right: 360px; 
 
} 
 

 
.forth { 
 
    position: absolute; 
 
    right: 540px; 
 
} 
 

 
.logo { 
 
    position: relative; 
 
    bottom:60px; 
 
    left: 100px; 
 
} 
 

 
.first:hover, .second:hover, .third:hover, .forth:hover { 
 
    margin-top: 3px; 
 
} 
 

 
.img-con { 
 
    position: relative; 
 
    width: 300px; 
 
    padding-top: 50px; 
 
    z-index: 9998; 
 
} 
 

 
.img-con > img { 
 
    position: absolute; 
 
    top: 0; 
 
    left: 0; 
 
} 
 

 
.img-con > img.logo { 
 
    z-index: 1; 
 
} 
 

 
.img-con:hover > img.logo { 
 
    z-index: -1; 
 
    margin-top: 3px; 
 
} 
 

 
.img-con:hover > img.hidden { 
 
    top: -100px; 
 
    right: 500px; 
 
}
<!DOCTYPE html> 
 
<html> 
 
<head> 
 
<title>bla bla</title> 
 
<link rel="stylesheet" type="text/css" href="styles.css"> 
 
</head> 
 
<body dir="rtl"><div class="center"> 
 
\t <p class="hw">Hello World!</p> 
 
    
 
\t <div class="menu" style="position: relative; left: 0; top: 0;"> 
 
\t \t \t <div class="img-con"> 
 
\t \t \t \t <img class="logo" src="http://i.imgur.com/cr2cqPA.png"/> 
 
\t \t \t \t <img class="hidden" src="http://i.imgur.com/MY5bRT1.jpg"/> 
 
\t \t \t </div> 
 
\t 
 
\t \t \t <img class="first" src="http://i.imgur.com/cr2cqPA.png"/> 
 
\t \t \t <img class="second" src="http://i.imgur.com/MY5bRT1.jpg"/> 
 
\t \t \t <img class="third" src="http://i.imgur.com/cr2cqPA.png"/> 
 
\t \t \t <img class="forth" src="http://i.imgur.com/MY5bRT1.jpg"/> 
 
\t </div> 
 
</div></body> 
 
</html>

+0

IE7?本当に?好奇心のために、なぜIE7の要件?それはビジネス向けですか、このブラウザの使用率が高い地域ですか? –

答えて

2

私はあなたのための解決策を見つけました。 2つのイメージをコンテナに挿入し、Relativeの位置に設定する必要があります。あなたの画像はAbsoluteポジションで設定され、にz-indexと遊ぶことができます。

ここに私達は行く:

.img-con { 
 
    position: relative; 
 
    width: 400px; 
 
    margin: 20px; 
 
} 
 

 
.img-con > img { 
 
    position: absolute; 
 
    top: 0; 
 
    left: 0; 
 
} 
 

 
.img-con > img.first { 
 
    z-index: 1; 
 
} 
 

 
.img-con:hover > img.first { 
 
    z-index: -1; 
 
} 
 

 
.img-con:hover > img.second { 
 
    top: -5px; 
 
    left: 5px; 
 
}
<div class="img-con"> 
 
    <img class="first" src="http://i.imgur.com/cr2cqPA.png"/> 
 
    <img class="second" src="http://i.imgur.com/MY5bRT1.jpg"/> 
 
</div>

+1

ちょっと見てみると、IE7は 'ファースト・チャイルド'や 'ラスト・チャイルド'をサポートしていないので、これがどう機能するか分かりません。 –

+0

少しの変更があった後、私はそれを動作させることができました! これは完璧に動作します!これほどまでにありがとうございます。私は本当に感謝しています。今、唯一の事は...ホバリングしている間に3つの画像を上向きにすることができないのです(現在は中央のものだけです)。 コードがすべて修正されるとすぐに公開します。 – Silver007

+0

あなたは1つのイベント(ホバー)しか持たないので、3つの画像は使用できません。フォーカスやアクティブなどの新しいイベントを追加できます。 –

関連する問題