【问题标题】:Move element X when element Y is hovered on?当元素 Y 悬停时移动元素 X?
【发布时间】:2019-12-29 01:17:28
【问题描述】:

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>

当父标签<a> 悬停在上面时,如何使图像(箭头)向右移动margin-left: 15px;?没有javascript或jquery这可能吗?

【问题讨论】:

    标签: html css hover position css-position


    【解决方案1】:

    请试试这个代码

    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>

    【讨论】:

      【解决方案2】:

      像这样?

      a img {
        width:3%;
        text-decoration:none;
        margin-left:10px;
      }
      
      a:hover img {
        margin-left:15px;
      }
      
      
      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>

      【讨论】:

        【解决方案3】:

        试试这个。

        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{
          margin-left:15px;
        }
        <a href="#">View <img src="https://cdn1.iconfinder.com/data/icons/internet-28/48/31-512.png"> </a>

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-03-04
          • 1970-01-01
          • 2021-06-29
          • 2014-10-15
          • 2012-12-28
          • 2016-01-21
          • 1970-01-01
          • 2010-10-08
          相关资源
          最近更新 更多