2015-11-07 66 views
0

我有一個響應滑塊內部包裝的問題。當我縱向調整瀏覽器窗口(水平調整爲包裝的寬度)時,包裝正在改變其尺寸,並且滑塊越過它。我試圖用很多方式解決它,但我找不到一個好的解決方案。響應滑塊超出包裝

CSS

* { 
    box-sizing: border-box; 
    padding: 0; 
    margin: 0; 
} 

body { 
    margin: 0 !important; 
    font-family: 'Lato', sans-serif; 
    background-color: #fff; 
    color: #161616; 
} 

#wrapper { 
    position: fixed; 
    width: 90%; 
    height: 75%; 
    margin-top: 5%; 
    margin-left: 5%; 
    background-color: #f2f2f2; 
} 

.logo{ 
    position:absolute; 
    width: 100px; 
    height: 94px; 
    margin-top: -26px; 
    margin-left: 50px; 
    background-image: url('images/logo.png'); 
    background-image: no-repeat; 
} 

.nav { 
    float: right; 
    margin-top: 35px; 
    margin-right: 35px; 
} 

.nav ul { 
    padding: 0; 
    margin: 0; 
    list-style: none; 
} 

.nav ul li { 
    float: left; 
} 

.nav ul li a { 
    color: #161616; 
    /*font-family: Verdana;*/ 
    text-decoration: none; 
    font-size: 14px; 
    letter-spacing: 2px; 

} 

.nav ul li a:hover { 
    color: #cccccc; 
} 

.nav ul li:nth-child(n+2) { 
    margin-left: 23px; 
} 


img { 
    max-width: 100%; 
} 
.cycle-slideshow { 
    position:relative; 
    display:block; 
    width: 60%; 
    max-width: 960px; 
    margin: 90px 20%; 
    overflow:auto; 
} 

.cycle-prev, .cycle-next { 
    position: absolute; 
    display:block; 
    top: 37%; 
    font-size: 200%; 
    color: #161616; 
    cursor: pointer; 
    z-index: 9999; 
} 

.cycle-prev { 
    left: 0; 
} 

.cycle-next { 
    right: 0; 
} 

.footer{ 
    position:fixed; 
    padding: 38px 0; 
    left: 5%; 
    bottom: 0; 
    width: 90%; 
    height: 85px; 
    font-size: 12px; 
    text-align: center; 
    letter-spacing: 1px; 
} 

HTML

<div id="wrapper"> 
    <header> 
     <div class="logo"></div> 
     <div class="nav"> 
      <ul> 
       <li><a href="#">First</a></li> 
       <li><a href="#">Second</a></li> 
       <li><a href="#">Third</a></li> 
      </ul> 
     </div> 
    </header> 
    <div class="cycle-slideshow"> 
     <span class="cycle-prev">&#10092;</span> 
     <span class="cycle-next">&#10093;</span> 
     <img src="images/bg.png" alt="Robak" /> 
     <img src="images/bg2.png" alt="Robak" /> 
    </div> 
    <div class="footer">Footer info.</div> 
</div> 

回答

0

您正在運行的jQuery插件週期?您想要調整幻燈片大小以避免在窗口大小調整時垂直滾動嗎?當垂直空間縮小時允許頁面滾動出現問題。

編輯:嘗試......

http://codepen.io/robotslater/pen/YyJNER

* { 
 
    box-sizing: border-box; 
 
    padding: 0; 
 
    margin: 0; 
 
} 
 

 
body { 
 
    margin: 20px; 
 
    font-family: 'Lato', sans-serif; 
 
    background-color: #fff; 
 
    color: #161616; 
 
} 
 

 
#wrapper { 
 
    position: absolute; 
 
    left: 30px; 
 
    right: 30px; 
 
    top: 30px; 
 
    bottom: 30px; 
 
    background-color: #f2f2f2; 
 
} 
 

 
.logo { 
 
    position: absolute; 
 
    width: 100px; 
 
    height: 94px; 
 
    margin-top: -26px; 
 
    margin-left: 50px; 
 
    background-image: url('images/logo.png'); 
 
    background-image: no-repeat; 
 
} 
 

 
.nav { 
 
    float: right; 
 
    margin-top: 35px; 
 
    margin-right: 35px; 
 
} 
 

 
.nav ul { 
 
    padding: 0; 
 
    margin: 0; 
 
    list-style: none; 
 
} 
 

 
.nav ul li { 
 
    float: left; 
 
} 
 

 
.nav ul li a { 
 
    color: #161616; 
 
    /*font-family: Verdana;*/ 
 
    
 
    text-decoration: none; 
 
    font-size: 14px; 
 
    letter-spacing: 2px; 
 
} 
 

 
.nav ul li a:hover { 
 
    color: #cccccc; 
 
} 
 

 
.nav ul li:nth-child(n+2) { 
 
    margin-left: 23px; 
 
} 
 

 
img { 
 
    max-width: 100%; 
 
} 
 

 
.cycle-slideshow { 
 
    position: absolute; 
 
    display: block; 
 
    top: 90px; 
 
    left: 20%; 
 
    right: 20%; 
 
    bottom: 30px; 
 
    overflow: auto; 
 
} 
 

 
.cycle-prev, 
 
.cycle-next { 
 
    position: absolute; 
 
    display: block; 
 
    top: 37%; 
 
    font-size: 200%; 
 
    color: #161616; 
 
    cursor: pointer; 
 
    z-index: 9999; 
 
} 
 

 
.cycle-prev { 
 
    left: 0; 
 
} 
 

 
.cycle-next { 
 
    right: 0; 
 
} 
 

 
.cycle-slideshow > div { 
 
    width: 100%; 
 
    height: 100%; 
 
    background: #eee; 
 
    background-size: auto 100%; 
 
    background-position: center center; 
 
    background-repeat: no-repeat; 
 
    position: absolute; 
 
} 
 

 
.footer { 
 
    position: absolute; 
 
    left: 0; 
 
    bottom: 0; 
 
    right: 0; 
 
    font-size: 12px; 
 
    text-align: center; 
 
    letter-spacing: 1px; 
 
    line-height: 30px; 
 
    z-index: 9999999; 
 
}
<div id="wrapper"> 
 
    <header> 
 
    <div class="logo"></div> 
 
    <div class="nav"> 
 
     <ul> 
 
     <li><a href="#">First</a></li> 
 
     <li><a href="#">Second</a></li> 
 
     <li><a href="#">Third</a></li> 
 
     </ul> 
 
    </div> 
 
    </header> 
 
    <div class="cycle-slideshow" data-cycle-slides="> div"> 
 
    <span class="cycle-prev">&#10092;</span> 
 
    <span class="cycle-next">&#10093;</span> 
 

 
    <div style="background-image:url(http://s3.freefoto.com/images/9912/01/9912_01_1095_web.jpg)"></div> 
 
    <div style="background-image:url(http://www.keenthemes.com/preview/conquer/assets/plugins/jcrop/demos/demo_files/image2.jpg)"></div> 
 
    </div> 
 
    <div class="footer">Footer info.</div> 
 
</div>

+0

是的,沒錯 - 這是jQuery的週期插件。當然,我想在窗口大小調整時避免垂直滾動。當我垂直縮小瀏覽器窗口的大小時,我想以與水平方向匹配的滑塊相同的方式來完成此操作。但我找不到任何解決方案,當我垂直縮小窗口時,滑塊超出了包裝。 – Daminski

+0

垂直尺寸調整與橫向尺寸調整不同,支持類型不同。如果你絕對定位元素,你可以使用CSS來對窗口高度作出反應。所提供的HTML是網頁上的所有內容還是幻燈片下面有更多內容?如果是這樣,它只是幻燈片,你想保持在摺疊之上? –

+0

是的,在幻燈片下你可以找到一些文本的頁腳。頁腳應該就在那裏,就在slidershow和包裝背景下面..其中包含 - 徽標,導航,滑塊和頁腳。 – Daminski