translateY -50% does not center things exactly

我怕爱的太早我们不能终老 提交于 2021-01-29 13:30:40

问题


I'm vertically centering custom arrows on BxSlider using translateY-50%. It's kinda centering the icons, but not exactly. This is what I have now"

Note the grey bars are of the same height, so the icon is placed more towards the bottom. What's causing this?

$(document).ready(function(){
      $('.slider').bxSlider({
      auto: true,
      pause: 3000,
       mode: 'fade',
       speed: 1200, 
      pager: false,
      controls: true,
           nextSelector: '.bxNext',
     prevSelector: '.bxPrev',  
          nextText: '<img id="next-arrow" src="img/next.png">',
     prevText: '<img id="prev-arrow" src="img/prev.png">'

});
    });


.bx-wrapper, .bx-viewport {
    height: auto; !important; //provide height of slider
}


.bxNext {
  float: right;
  position: absolute;
  right: 1.7%;
}

.bxPrev {
  position: absolute;
  left: 1.7%;
}

#slider-wrapper {
  position: relative;
}

.controls {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
}


  <div id="slider-wrapper">
  
  
  <div class="slider">
    <div>I am a slide.</div>
    <div>I am another slide.</div>
  </div>
  
  <div class='controls'>
    <a href='#' id='PREV' class='bxPrev'></a>
    <a href='#' id='NEXT' class='bxNext'></a>
  </div>
  
  </div>

来源:https://stackoverflow.com/questions/64406585/translatey-50-does-not-center-things-exactly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!