gpt4 book ai didi

html - 每次我将鼠标悬停在按钮上时,我的文字和图像都会移动

转载 作者:太空宇宙 更新时间:2023-11-04 10:09:21 25 4
gpt4 key购买 nike

每次我将鼠标悬停在 7 个按钮中的任何一个时,一切都会向右移动一点。有人可以快速告诉我解决方案吗?我知道这不是很好的代码,但我只是 HTML 的初学者。

<html>
<head>
<title> Desenele Animate </title>
<center> <font face="Lucida Bright" color="#000000" size="48"> Desenele Animate </font> </center>
<style>
.button {
background-color: #4CAF50;
border: none;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s;
transition-duration: 0.4s;
cursor: pointer;
border-radius: 8px;
width: 250px;
}

.button1 {
background-color: #4CAF50;
color: white;
}
.button1:hover {
background-color: white;
color: black;
border: 2px solid #4CAF50;
}

.button2 {
background-color: #008CBA;
color: white;
}
.button2:hover {
background-color: white;
color: black;
border: 2px solid #008CBA;
}

.button3 {
background-color: #f44336;
color: white;
}
.button3:hover {
background-color: white;
color: black;
border: 2px solid #f44336;
}

.button4 {
background-color: #ffa500;
color: white;
}
.button4:hover {
background-color: white;
color: black;
border: 2px solid #ffa500;
}`

.button5 {
background-color: #bf80ff;
color: white;
}
.button5:hover {
background-color: white;
color: black;
border: 2px solid #bf80ff;
}

.button6 {
background-color: #ff66ff;
color: white;
}
.button6:hover {
background-color: white;
color: black;
border: 2px solid #ff66ff;
}
.button7 {
background-color: #00cccc;
color: white;
}
.button7:hover {
background-color: white;
color: black;
border: 2px solid #00cccc;
}

</style>
</head>
<body bgcolor= "white">
<br>
<div id="nav">
<table style="float:left;">
<tr><td><a href="Archer.html" class="button button1">Archer</a><br></td></tr>
<tr><td><a href="South park.html" class="button button2">South Park</a><br></td></tr>
<tr><td><a href="Gravity Falls.html" class="button button3">Gravity Falls</a><br></td></tr>
<tr><td><a href="Steven Universe.html" class="button button4">Steven Universe</a><br></td></tr>
<tr><td><a href="Adventure Time.html" class="button button5">Adventure Time</a><br></td></tr>
<tr><td><a href="Rick and Morty.html" class="button button6">Rick And Morty</a><br></td></tr>
<tr><td><a href="Futurama.html" class="button button7">Futurama</a><br></td></tr>
</table>
</div>
<center> <font face="Lucida Bright" color="#000000" size="5"> Desenele animate au inceput sa devina din ce in ce mai interesante, diferite si amuzante. Desigur, nu ne referim la desene precum "Looney Tunes". Ne referim la cele noi! Pline de sarcasm si de glume rautacioase! Am ales cateva PE care noi le consideram foarte inventive, amuzante si suntem siguri ca o sa va placa. Inainte de a le prezenta ne-am gandit sa vorbim putin despre ce sunt ele si evolutia lor, DAAAAR ne-am dat seama ca ar fi MULT prea plictisitor asa ca hai sa trecem direct la review-uri.</font></center>
<br>
<center> <img src="cornel.jpg"> </center>
</body>
</html>

最佳答案

你应该添加一个默认的透明边框

.button {
border: 2px solid transparent;

原因 :hover添加那个边框border: 2px solid #00cccc;因此元素移动那些 2 px

a.btn:hover{
border:2px solid red;
}

/* solution */
a.button{
border:2px solid transparent;
}
a.button:hover{
border:2px solid red;
}
<a class="btn">HOVER ME (I HAVE THT ISSUE...)</a><br>
<a class="button">HOVER ME (I feel just fine!)</a><br>

我刚刚注意到您正在使用 <center><font>标签。 不要这些标签在某些浏览器中工作只是为了向后兼容但已弃用!使用 CSS text-align: center;font-size相反。

关于html - 每次我将鼠标悬停在按钮上时,我的文字和图像都会移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37736290/

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