2017-06-22 77 views
0

自上週我一直在建立一個HTML網站,我一直在使用鼠標懸停,使圖像移動時,一個超鏈接將光標懸停,所以一切都顯得不錯,我主要是完成它,但有一些我不明白,我已創建3超鏈接與3鼠標懸停圖像,但最後一個實際上懸停在網站的整個頁面上。問題,鼠標懸停一整頁

我不知道爲什麼或者它確實是這樣,這就是爲什麼我在這裏問你這個問題。你可以在我的HTML看看:

.college .image { 
 
    margin-left: 100px; 
 
    margin-top: 475px; 
 
    position: absolute 
 
} 
 

 
.college .imagesecond { 
 
    transform: translate(0px, 500px); 
 
    transition: transform 0.5s ease-in-out 0.2s; 
 
    border-radius: 8px; 
 
    overflow: hidden; 
 
} 
 

 
.college:hover>.imagesecond { 
 
    transform: translate(0, -200px); 
 
} 
 

 
.lycee .image { 
 
    margin-left: 700px; 
 
    margin-top: 500px; 
 
    position: absolute 
 
} 
 

 
.lycee .imagefourth { 
 
    transform: translate(0px, 300px); 
 
    transition: transform 0.5s ease-in-out 0.2s; 
 
    border-radius: 8px; 
 
    overflow: hidden; 
 
} 
 

 
.lycee:hover>.imagefourth { 
 
    transform: translate(0, -200px); 
 
} 
 

 
.formations .image { 
 
    margin-left: 1250px; 
 
    margin-top: 510px; 
 
    overflow: hidden; 
 
} 
 

 
.formations .imagesixth { 
 
    transform: translate(0px, 400px); 
 
    transition: transform 0.5s ease-in-out 0.2s; 
 
    border-radius: 8px; 
 
    overflow: hidden 
 
} 
 

 
.formations:hover>.imagesixth { 
 
    transform: translate(0, -900px); 
 
} 
 

 
body { 
 
    background: url("http://via.placeholder.com/571x179") 33em 0% fixed no-repeat; 
 
    position: fixed; 
 
    background-color: rgb(0, 85, 170); 
 
}
<!doctype html> 
 
<html> 
 

 
<head> 
 
    <meta charset="utf-8" /> 
 
    <link rel="stylesheet" href="css.css" /> 
 

 
    <title> sainte marie </title> 
 

 
</head> 
 

 
<body> 
 
    <div class="saintemarie"> 
 
    <a href="college/collegesaintemarie.html"> 
 
     <div class="college"> 
 
     <img class="image imagefirst" src="http://via.placeholder.com/196x175" /> 
 
     <img class="image imagesecond" src="http://via.placeholder.com/320x440" /> 
 
     </div> 
 
    </a> 
 

 
    <a href="lycee/lyceesaintemarie.html"> 
 
     <div class="lycee"> 
 
     <img class="image imagethird" src="http://via.placeholder.com/183x140" /> 
 
     <img class="image imagefourth" src="http://via.placeholder.com/320x440" /> 
 
     </div> 
 
    </a> 
 

 
    <a href="c&formation/c&fsaintemarie.html"> 
 
     <div class="formations"> 
 
     <img class="image imagefifth" src="http://via.placeholder.com/172x153" /> 
 
     <img class="image imagesixth" src="http://via.placeholder.com/320x440" /> 
 
     </div> 
 
    </a> 
 
    </div> 
 

 

 
</body> 
 

 
</html>

你有什麼想法,可以幫助我嗎?或者改進我迄今爲止所做的代碼行?萬分感謝!

+0

嘿souzouker,下次請大家多一點關注你的寫作(大小寫),並使用編輯器按鈕來打開你的代碼堆棧段,這樣我們就可以很容易地重現您的問題。這將幫助我們幫助你。順便說一下,我看到的只有藍色。您應該用[佔位符圖片](https://placeholder.com/)替換圖片的src。我會這樣做,但是你沒有爲你的圖像指定'width'或'height'(你應該)。 – domsson

+0

我認爲它的所有藍色,因爲我使用我的電腦中的文件和圖像,我可以嘗試改變它佔位符圖像給我一分鐘請 – souzouker

+0

我認爲它的工作,你可以看到它在整個頁面上是如何工作的,你可以看到第3圖像盤旋在整個頁面execpt 2個orther超鏈接 – souzouker

回答

1

您需要使用lefttop而不是margin-leftmargin-top。圖像的邊距導致a標籤的尺寸擴大。

.college .image { 
 
    left: 100px; 
 
    top: 475px; 
 
    position: absolute 
 
} 
 

 
.college .imagesecond { 
 
    transform: translate(0px, 500px); 
 
    transition: transform 0.5s ease-in-out 0.2s; 
 
    border-radius: 8px; 
 
    overflow: hidden; 
 
} 
 

 
.college:hover>.imagesecond { 
 
    transform: translate(0, -200px); 
 
} 
 

 
.lycee .image { 
 
    left: 700px; 
 
    top: 500px; 
 
    position: absolute 
 
} 
 

 
.lycee .imagefourth { 
 
    transform: translate(0px, 300px); 
 
    transition: transform 0.5s ease-in-out 0.2s; 
 
    border-radius: 8px; 
 
    overflow: hidden; 
 
} 
 

 
.lycee:hover>.imagefourth { 
 
    transform: translate(0, -200px); 
 
} 
 

 
.formations .image { 
 
    left: 1250px; 
 
    top: 510px; 
 
    position:absolute; 
 
    overflow: hidden; 
 
} 
 

 
.formations .imagesixth { 
 
    transform: translate(0px, 400px); 
 
    transition: transform 0.5s ease-in-out 0.2s; 
 
    border-radius: 8px; 
 
    overflow: hidden 
 
} 
 

 
.formations:hover>.imagesixth { 
 
    transform: translate(0, -200px); 
 
} 
 

 
body { 
 
    background: url("http://via.placeholder.com/571x179") 33em 0% fixed no-repeat; 
 
    position: fixed; 
 
    background-color: rgb(0, 85, 170); 
 
}
<!doctype html> 
 
<html> 
 

 
<head> 
 
    <meta charset="utf-8" /> 
 
    <link rel="stylesheet" href="css.css" /> 
 

 
    <title> sainte marie </title> 
 

 
</head> 
 

 
<body> 
 
    <div class="saintemarie"> 
 
    <a href="college/collegesaintemarie.html"> 
 
     <div class="college"> 
 
     <img class="image imagefirst" src="http://via.placeholder.com/196x175" /> 
 
     <img class="image imagesecond" src="http://via.placeholder.com/320x440" /> 
 
     </div> 
 
    </a> 
 

 
    <a href="lycee/lyceesaintemarie.html"> 
 
     <div class="lycee"> 
 
     <img class="image imagethird" src="http://via.placeholder.com/183x140" /> 
 
     <img class="image imagefourth" src="http://via.placeholder.com/320x440" /> 
 
     </div> 
 
    </a> 
 

 
    <a href="c&formation/c&fsaintemarie.html"> 
 
     <div class="formations"> 
 
     <img class="image imagefifth" src="http://via.placeholder.com/172x153" /> 
 
     <img class="image imagesixth" src="http://via.placeholder.com/320x440" /> 
 
     </div> 
 
    </a> 
 
    </div> 
 

 

 
</body> 
 

 
</html>

+0

你是對的!我不知道保證金實際上是這樣做的,非常感謝你! – souzouker

+0

沒問題。邊距本質上是在元素周圍增加額外的空間,這將增加父元素的大小。 – WizardCoder

0

在你關閉一個標籤之前甲肝關閉開幕saintemarie DIV最後一個看到這裏

<a href="c&formation/c&fsaintemarie.html"> 
     <div class="formations"> 
      <img class="image imagefifth" src="formation.png" /> 
      <img class="image imagesixth" src="pepepls.gif" /> 
     </div> 
    /* closed before a */ </div> 
    </a> 

嘗試一個後關閉它,看它是否得到所有正確的

+0

感謝指出了這一點,我在我的代碼固定它, 不幸的是,它沒有固定我的問題,但你^^感謝 – souzouker

+0

可以使用http圖像並附上代碼片段,以便我可以更好地瞭解它 –

0

.college .image { 
 
    margin-left: 100px; 
 
    margin-top: 475px; 
 
    position: absolute 
 
} 
 

 
.college .imagesecond { 
 
    transform: translate(0px, 500px); 
 
    transition: transform 0.5s ease-in-out 0.2s; 
 
    border-radius: 8px; 
 
    overflow: hidden; 
 
} 
 

 
.college:hover>.imagesecond { 
 
    transform: translate(0, -200px); 
 
} 
 

 
.lycee .image { 
 
    margin-left: 700px; 
 
    margin-top: 500px; 
 
    position: absolute 
 
} 
 

 
.lycee .imagefourth { 
 
    transform: translate(0px, 300px); 
 
    transition: transform 0.5s ease-in-out 0.2s; 
 
    border-radius: 8px; 
 
    overflow: hidden; 
 
} 
 

 
.lycee:hover>.imagefourth { 
 
    transform: translate(0, -200px); 
 
} 
 

 
.formations .image { 
 
    margin-left: 1250px; 
 
    margin-top: 510px; 
 
    overflow: hidden; 
 
} 
 

 
.formations .imagesixth { 
 
    transform: translate(0px, 400px); 
 
    transition: transform 0.5s ease-in-out 0.2s; 
 
    border-radius: 8px; 
 
    overflow: hidden 
 
} 
 

 
.formations:hover>.imagesixth { 
 
    transform: translate(0, -900px); 
 
} 
 

 
body { 
 
    background: url("http://via.placeholder.com/571x179") 33em 0% fixed no-repeat; 
 
    position: fixed; 
 
    background-color: rgb(0, 85, 170); 
 
}
<!doctype html> 
 
<html> 
 

 
<head> 
 
    <meta charset="utf-8" /> 
 
    <link rel="stylesheet" href="css.css" /> 
 

 
    <title> sainte marie </title> 
 

 
</head> 
 

 
<body> 
 
    <div class="saintemarie"> 
 
    <a href="college/collegesaintemarie.html"> 
 
     <div class="college"> 
 
     <img class="image imagefirst" src="http://via.placeholder.com/196x175" /> 
 
     <img class="image imagesecond" src="http://via.placeholder.com/320x440" /> 
 
     </div> 
 
    </a> 
 

 
    <a href="lycee/lyceesaintemarie.html"> 
 
     <div class="lycee"> 
 
     <img class="image imagethird" src="http://via.placeholder.com/183x140" /> 
 
     <img class="image imagefourth" src="http://via.placeholder.com/320x440" /> 
 
     </div> 
 
    </a> 
 

 
    <a href="c&formation/c&fsaintemarie.html"> 
 
     <div class="formations"> 
 
     <img class="image imagefifth" src="http://via.placeholder.com/172x153" /> 
 
     <img class="image imagesixth" src="http://via.placeholder.com/320x440" /> 
 
     </div> 
 
    </a> 
 
    </div> 
 

 

 
</body> 
 

 
</html>