2014-01-13 36 views
0

我正在制作一个全宽滑块,但具有特定的高度(500像素)。这个滑块在菜单后面,我试图保持滑块在一个div内,但它不工作,内容漂浮在div之外。我怎样才能保持div内容包装?保持全宽滑块内div

这是我的代码。

HTML

<div id="container"> 
    <div id="header"> 
     <h1>Easy Slider jQuery Plugin - continuous demo</h1> 
    </div> 
    <div id="content"> 
     <div id="slider"> 
      <ul>     
       <li><a href="http://templatica.com/preview/30"><img src="images/01.jpg" alt="Css Template Preview" /></a></li> 
       <li><a href="http://templatica.com/preview/7"><img src="images/02.jpg" alt="Css Template Preview" /></a></li> 
       <li><a href="http://templatica.com/preview/25"><img src="images/03.jpg" alt="Css Template Preview" /></a></li> 
       <li><a href="http://templatica.com/preview/26"><img src="images/04.jpg" alt="Css Template Preview" /></a></li> 
       <li><a href="http://templatica.com/preview/27"><img src="images/05.jpg" alt="Css Template Preview" /></a></li>   
      </ul> 
     </div> 
    </div> 
</div> 


CSS

#container {  
    margin: 0 auto; 
    position: relative; 
    text-align: left; 
    width: 696px; 
    background: #fff;  
    margin-bottom: 2em; 
} 
#header { 
    height: 80px; 
    line-height: 80px; 
    background: #5DC9E1; 
    color: #fff; 
}    
#content{ 
    position: relative; 
}   

/* Easy Slider */ 
#slider ul, #slider li, 
#slider2 ul, #slider2 li { 
    margin: 0; 
    padding: 0; 
    list-style: none; 
} 
#slider2 { 
    margin-top: 1em; 
} 
#slider li, #slider2 li { 
    /* 
     define width and height of list item (slide) 
     entire slider area will adjust according 
     to the parameters provided here 
    */ 
    width: 100%; 
    height: 500px; 
    overflow: hidden; 
} 

#prevBtn, #nextBtn, 
#slider1next, #slider1prev { 
    display: block; 
    width: 30px; 
    height: 77px; 
    position: absolute; 
    left: -30px; 
    top: 71px; 
    z-index: 1000; 
} 
#nextBtn, #slider1next { 
    left: 696px; 
}              
#prevBtn a, #nextBtn a, 
#slider1next a, #slider1prev a { 
    display: block; 
    position: relative; 
    width: 30px; 
    height: 77px; 
    background: url(../images/btn_prev.gif) no-repeat 0 0; 
} 
#nextBtn a, #slider1next a { 
    background: url(../images/btn_next.gif) no-repeat 0 0; 
} 

回答

0

jQuery是不需要这个。
使用这个代替:

<!DOCTYPE html> 
<html> 
<head> 
<style type="text/css"> 
.slider{ 
    overflow:auto; 
    height: 50px; 
    width:50px; 
} 
</style> 
</head> 
<body> 
<div class="slider"> 
    <div>Item 1</div> 
    <div>Item 2</div> 
    <div>Item 3</div> 
    <div>Item 4</div> 
    <div>Item 5</div> 
    <div>Item 6</div> 
    <div>Item 7</div> 
    <div>Item 8</div> 
    <div>Item 9</div> 
    <div>Item 10</div> 
    <div>Item 11</div> 
    <div>Item 12</div> 
</div> 
</body> 

,并且不使用#ID上课使用类=“类名”,并在你的CSS:.classname,看到的例子。

+0

谢谢!如果我需要滑块全宽100%,我只需要将宽度从50像素更换为100%,它应该正常工作?我不需要滑块来响应只是为了显示图像... – Thrice89