gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 08:32:35 24 4
gpt4 key购买 nike

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

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

最佳答案

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

关于html - 鼠标悬停在整个页面上的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44702699/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com