Center image inside div horizontally

前端 未结 4 1934
野的像风
野的像风 2021-01-24 14:49

I am trying to set the image with arrow up/down to horizontally center of the div.

I have read some tutorials and questions here, but the following method does

4条回答
  •  终归单人心
    2021-01-24 15:25

    just add .expander {left:50%;} to your css
    

    /* Animation */
    $(document).ready(function () {
      $('.text').hide();
      $('.expander').click(function () {
        $(this).parent().next().slideToggle(200);
      });
      $('.text').slideUp(200);
    });
    
    /* Change image */
    $(function() {
      $('.expander').click(function(){
        $(this).children('img').each(function(){
          $(this).toggle(0);
        });
      });
    });
    .red { 
      background-color: #cc1042;
    }
    .expander {
    left:50%;
    }
    .lefttext  p {
    text-align:center;
    }
    .whitetext {
      color: #ffffff;
    }
    .lefttext{ 
      text-align: left; 
    }
    .centertext { 
      text-align: center;
    }
    .righttext {
      text-align: right;
    }
    .littpadding {	
      padding: 15px;
    }
    .paddingned80 {
      padding-bottom: 80px;
    }
    .close { 
      opacity: 1!important;
    }
    .close:focus, .close:hover {
      opacity: 1!important;
    }
    .clickexpander {
      position:absolute;
      bottom: 10px;
    }
    .clickexpander img {
      max-width: 50px;
    }
    
    
    
    
    
    
    
    

提交回复
热议问题