css - expand width in other direction

后端 未结 1 1556
野性不改
野性不改 2021-01-07 18:10

I\'ve got some icons that expands when I hover them:

  .icon
  {
      width: 128px;
      height: 128px;
      background: url(icons.png) no-repeat;
      b         


        
1条回答
  •  悲&欢浪女
    2021-01-07 18:52

    Use position:absolute and set right:0 and top:0

        .icon{
        width: 128px;
        height: 128px;
        background: url(icons.png) no-repeat red;
        background-position: left top;
        -webkit-transition: width .2s;
        position:absolute;
        top:0; right:0; 
    }
    .icon:hover{
        width:250px
    }
    

    DEMO

    0 讨论(0)
提交回复
热议问题