html - 当元素 Y 悬停时移动元素 X?

标签 html css hover position css-position

a img {
  width:3%;
  text-decoration:none;
  margin-left:10px;
}

a {
    top: 10px;
    left: 10px;
    position: absolute;
    color: #090909;
}
<a href="#">View <img src="https://cdn1.iconfinder.com/data/icons/internet-28/48/31-512.png"> </a>

如何使图像(箭头)变为 5px向右所以 margin-left: 15px;当父标签<a>一直徘徊在?如果没有 javascript 或 jquery,这可能吗?

最佳答案

请试试这段代码

a img {
  width:3%;
  text-decoration:none;
  margin-left:10px;
  transition:0.5s;
}
a {
  top: 10px;
  left: 10px;
  position: absolute;
  color: #090909;
}
a:hover img{
  	opacity: 1; 
	margin-left: 50px;  
	transition: all 0.5s ease-out; 
	-webkit-transform: rotate(177deg);   
	zoom: 1;
}
<a href="#">View <img src="https://cdn1.iconfinder.com/data/icons/internet-28/48/31-512.png"> </a>

关于html - 当元素 Y 悬停时移动元素 X?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57630949/

相关文章:

html - 如何将父级的父级宽度应用于相对定位的子级 div?

html - 有没有其他方法可以更改 Bootstrap 导航链接的颜色?使用深色主题

html - 使用显示 : inline-block 避免 "duplicate"边框

css - 在 Sass 中循环 @for 如何正确使用 $#{value}#{$i}?

:hover does'nt show 上的背景图片

python - 当鼠标悬停时使用 matplotlib 注释绘图的线条

CSS 背景图像大小过渡

javascript - 如何在 Javascript 中更改音频输入

javascript - 通过jQuery设置di​​v的行高?

php - 在图像旁边放置文本