鼠标悬停在整个页面上的问题

problems with mouse hovering on a whole page

自上周以来,我一直在创建一个 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>

你有什么想法可以帮助我吗?或者改进我到目前为止所做的代码行?非常感谢!

在上一个 a 中,您在关闭 a 标签之前关闭了开头的 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>

尝试在 a 之后关闭它,看看是否一切正常

.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>

您需要使用 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>