2014-03-27 2 views
0

슬라이드 쇼를 만들고 있는데 이미지 위의 탐색 버튼을 세로로 가운데에 놓으려고합니다. 나는 top : 50 %를 시도하고 있지만, 슬라이드 쇼의 높이가 아니라 버튼의 높이에 비례하여 움직입니다. jQuery Cycle을 사용하고 있습니다.부모 요소에 요소 가운데 맞추기

<div class="slideshow_container"> 
<h2>Amor Insecta</h2> 
<div class="slideshow_controls"> 
<div class="cycle_prev">&nbsp;</div> 
<div class="cycle_next">&nbsp;</div> 
</div> 
<div class="slideshow"> 
<img title="stylepageart2.jpg" src="http://cmpltunknwn.mybigcommerce.com/product_images/uploaded_images/stylepageart21.jpg" alt="stylepageart2.jpg" /> 
<img title="stylepageart3.jpg" src="http://cmpltunknwn.mybigcommerce.com/product_images/uploaded_images/stylepageart22.jpg" alt="stylepageart3.jpg" /> 
</div> 
</div> 

.slideshow_container { 
width:90%; 
margin: 0 auto 50px auto; 
max-height:2000px; 
} 

.slideshow { 
position: relative; 
width: 100% !important; 
} 

.slideshow img { 
width: 100% !important; 
height:auto !important; 
position: absolute; 
top: 0; 
left: 0; 
} 

.slideshow_controls { 
display:none; 
width:100%; 
height:100%; 
position:relative; 
z-index:100!important; 
} 

.cycle_prev, .cycle_next { 
position:absolute; 
top:50%; 
width:37px; 
height:37px; 
} 

.cycle_prev{ 
left:0; 
background:url(http://cmpltunknwn.mybigcommerce.com/product_images/theme_images/prev.jpg) no-repeat; 
} 

.cycle_next { 
right:0; 
background:url(http://cmpltunknwn.mybigcommerce.com/product_images/theme_images/next.jpg) no-repeat; 

} 
+0

문제는 소자 절대 요소로 배치되어있다. 따라서 그들은 유용한 높이를 얻지 못합니다. 내 제안 : 당신의 욕망의 높이를 계산하고 자바 스크립트로 설정하십시오. 그러면 훨씬 쉬울 것입니다. – KittMedia

+0

@KittMedia : 어떻게해야 할 지 알려주시겠습니까? –

+0

가장 쉬운 방법은이 경우'$ ('img'). height();'입니다. – KittMedia

답변

0

이 방법은 이상적인 솔루션은 아니지만 코드에 적용됩니다. 이전/다음 버튼에서 top: 50%을 꺼내고 패딩 뚜껑을 해당 컨테이너에 추가하십시오. http://jsfiddle.net/4qSPr/

참고 : 디스플레이를 제거했습니다. 예제의 화살표 ...의

CSS

.slideshow_controls { 
width:100%; 
height:100%; 
position:relative; 
z-index:100!important; 
padding-top: 30%; 
} 

.cycle_prev, .cycle_next { 
position:absolute; 
width:37px; 
height:37px; 
} 
+0

흠, 바이올린이 작동하지만 내 사이트에서 탐색 버튼이 커서를 가리키면 표시되는 이미지 위로 마우스를 이동하면 이미지가 아래로 밀려납니다. 'http : //cmpltunknwn.mybigcommerce.com/style/' –

+0

I float : 왼쪽으로 .slideshow-controls를 추가하면 이미지가 아래로 밀리지 않습니다. 감사. –

관련 문제