2015-01-17 22 views
-1

我正试图让我的照片库适合移动窗口。我在响应/移动方面的大部分经验来自twitter bootstrap,它为您做了一切。如何使这个图片库对移动设备敏感?

这里是的jsfiddle(按钮不起作用,因为我并没有包括我的javascript):http://jsfiddle.net/L9hued7b/2/

HTML:

<body> 
    <div id="wrapper"> 
     <div id="prev"> 
      <a href="#" class="images">&uArr; </a> 
      <a href="#" class="thumbs">&uArr; </a> 
     </div> 
     <div id="images"> 
      <!-- large images on left--> 
     </div> 
     <div id="thumbs"> 
     <!--thumbnails on right--> 
     </div> 
     <div id="next"> 
      <a href="#" class="images">&dArr; </a> 
      <a href="#" class="thumbs">&dArr; </a> 
     </div> 
    </div> 
</body> 

CSS:

html, body { 
    height: 100%; 
    padding: 0; 
    margin: 0; 
} 
body { 
    min-height: 600px; 
} 
body * { 
    font-family: Arial, Geneva, SunSans-Regular, sans-serif; 
    font-size: 14px; 
    color: #333; 
    line-height: 22px; 
} 


#wrapper { 
     border: 1px solid #ddd; 
     background-color: #fff; 
     width: 750px; 
     height: 350px; 
     padding: 50px 25px 50px 50px; 
     margin: -225px 0 0 -412px; 
     position: absolute; 
     top: 50%; 
     left: 50%; 
     box-shadow: 0 0 20px rgba(0, 0, 0, 0.3); 
      } 
#wrapper img { 
    display: block; 
    float: left; 
} 
#images, #thumbs { 
    height: 350px; 
    float: left; 
    overflow: hidden; 
} 
#images { 
    width: 350px; 
} 
#thumbs { 
    width: 375px; 
    margin-left: 25px; 
} 
#thumbs img { 
    border: 1px solid #ccc; 
    padding: 14px; 
    margin: 0 25px 25px 0; 
    cursor: pointer; 
} 
#thumbs img.selected, #thumbs img:hover { 
    border-color: #333; 
} 

#thumbs div { 
    width: 375px; 
    height: 350px; 
    float: left; 
} 
#prev a, #next a { 
    text-decoration: none; 
    font-size: 20px; 
    color: #999; 
    position: absolute; 
} 
#prev a:hover, #next a:hover { 
    color: #000; 
} 
#prev a.disabled, #next a.disabled { 
    display: none !important; 
} 
#prev a { 
    top: 15px; 
} 
#next a { 
    bottom: 15px; 
} 
a.images { 
    left: 220px; 
} 
a.thumbs { 
    right: 220px; 
} 

#source { 
    text-align: center; 
    width: 400px; 
    margin: 0 0 0 -200px; 
    position: absolute; 
    bottom: 10px; 
    left: 50%; 
} 
#source, #source a { 
    color: #999; 
    font-size: 12px; 
} 

回答

0

如果添加这对你的CSS文件,你调整浏览器,你会看到他们将堆叠在对方下。所以当屏幕宽度低于500px时,这些盒子的风格会有所不同。您可能需要查看如何定位按钮,但是您可以在@media块中执行此操作,因此它仅适用于宽度低于500像素的屏幕。

@media (max-width: 500px) { 

    #images, #thumbs { 
     display: block; 
     width: 100%; 
     float: left; 
    } 

} 
0

尝试使用这个和你的自我修复您的问题

/* #Mobile (Portrait) 
 
================================================== */ 
 
    
 
/* Note: Design for a width of 320px */ 
 
    
 
@media only screen and (max-width: 767px) { 
 
    #wrapper { width:100%; padding:0px; margin:0px; } 
 
    #images, #thumbs {display: block;width: 100%;float: left;} 
 
} 
 
/* #Mobile (Landscape) 
 
================================================== */ 
 

 
/* Note: Design for a width of 480px */ 
 
    
 
@media only screen and (min-width: 480px) and (max-width: 767px) { 
 
    #wrapper { width:100%; padding:0px; margin:0px; } 
 
    #images, #thumbs {display: block;width: 100%;float: left;} 
 
} 
 

 
}

0

html, body { 
 
\t height: 100%; 
 
\t padding: 0; 
 
\t margin: 0; 
 
} 
 
body { 
 
\t min-height: 600px; 
 
} 
 
body * { 
 
\t font-family: Arial, Geneva, SunSans-Regular, sans-serif; 
 
\t font-size: 14px; 
 
\t color: #333; 
 
\t line-height: 22px; 
 
} 
 
#wrapper { 
 
\t border: 1px solid #ddd; 
 
\t background-color: #fff; 
 
\t width: 750px; 
 
\t height: 350px; 
 
\t padding: 50px 25px 50px 50px; 
 
\t margin: -225px 0 0 -412px; 
 
\t position: absolute; 
 
\t top: 50%; 
 
\t left: 50%; 
 
\t box-shadow: 0 0 20px rgba(0, 0, 0, 0.3); 
 
} 
 
#wrapper img { 
 
\t display: block; 
 
\t float: left; 
 
} 
 
#images, #thumbs { 
 
\t height: 350px; 
 
\t float: left; 
 
\t overflow: hidden; 
 
} 
 
#images { 
 
\t width: 350px; 
 
} 
 
#thumbs { 
 
\t width: 375px; 
 
\t margin-left: 25px; 
 
} 
 
#thumbs img { 
 
\t border: 1px solid #ccc; 
 
\t padding: 14px; 
 
\t margin: 0 25px 25px 0; 
 
\t cursor: pointer; 
 
} 
 
#thumbs img.selected, #thumbs img:hover { 
 
\t border-color: #333; 
 
} 
 
#thumbs div { 
 
\t width: 375px; 
 
\t height: 350px; 
 
\t float: left; 
 
} 
 
#prev a, #next a { 
 
\t text-decoration: none; 
 
\t font-size: 20px; 
 
\t color: #999; 
 
\t position: absolute; 
 
} 
 
#prev a:hover, #next a:hover { 
 
\t color: #000; 
 
} 
 
#prev a.disabled, #next a.disabled { 
 
\t display: none !important; 
 
} 
 
#prev a { 
 
\t top: 15px; 
 
} 
 
#next a { 
 
\t bottom: 15px; 
 
} 
 
a.images { 
 
\t left: 220px; 
 
} 
 
a.thumbs { 
 
\t right: 220px; 
 
} 
 
#source { 
 
\t text-align: center; 
 
\t width: 400px; 
 
\t margin: 0 0 0 -200px; 
 
\t position: absolute; 
 
\t bottom: 10px; 
 
\t left: 50%; 
 
} 
 
#source, #source a { 
 
\t color: #999; 
 
\t font-size: 12px; 
 
} 
 
@media (max-width:768px) { 
 
#wrapper { 
 
margin:0 !important; 
 
position:relative !important; 
 
margin-left:auto !important; 
 
margin-right:auto !important; 
 
margin-top:10% !important; 
 
padding:20px 6px 20px 20px !important; 
 
top:0; 
 
left:0; 
 
right:0; 
 
bottom:0; 
 
width:50%; 
 
margin-bottom:10% !important; 
 
height:765px; 
 
} 
 
#images { 
 
width: 100%; 
 
margin-top:20px; 
 
} 
 
#thumbs { 
 
width: 100%; 
 
margin-left:0; 
 
margin-top:20px; 
 
} 
 
#thumbs img { 
 
padding: 14px; 
 
margin: 0 22px 25px 0; 
 
} 
 
} 
 
@media (max-width:600px) { 
 
#wrapper { 
 
padding: 20px 20px 20px 20px !important; 
 
height: 588px !important; 
 
} 
 
#images, #thumbs { 
 
height: 284px; 
 
} 
 
#images img { 
 
width:auto; 
 
max-width:100%; 
 
height:auto; 
 
max-height:100%; 
 
} 
 
#thumbs img { 
 
padding: 7px; 
 
margin: 0 0px 20px 20px; 
 
height: 50px; 
 
width: 50px; 
 
} 
 
} 
 
@media (max-width:480px) { 
 
#wrapper { 
 
padding: 20px 0px 20px 30px !important; 
 
width: 70%; 
 
} 
 
} 
 
@media (max-width:360px) { 
 
#wrapper { 
 
padding: 20px 0px 20px 30px !important; 
 
width: 70%; 
 
} 
 
}
<body> 
 
<div id="wrapper"> 
 
    <div id="prev"> <a href="#" class="images">&uArr; </a> <a href="#" class="thumbs">&uArr; </a> </div> 
 
    <div id="images"> <img src="http://placehold.it/350x350" width="350" height="350" /> <img src="http://placehold.it/350x350" width="350" height="350" /> <img src="http://placehold.it/350x350" width="350" height="350" /> <img src="http://placehold.it/350x350" width="350" height="350" /> <img src="http://placehold.it/350x350" width="350" height="350" /> <img src="http://placehold.it/350x350" width="350" height="350" /> <img src="http://placehold.it/350x350" width="350" height="350" /> 0 <img src="http://placehold.it/350x350" width="350" height="350" /> <img src="http://placehold.it/350x350" width="350" height="350" /> </div> 
 
    <div id="thumbs"> <img src="http://placehold.it/350x350" width="70" height="70" /> <img src="http://placehold.it/350x350" width="70" height="70" /> <img src="http://placehold.it/350x350" width="70" height="70" /> <img src="http://placehold.it/350x350" width="70" height="70" /> <img src="http://placehold.it/350x350" width="70" height="70" /> <img src="http://placehold.it/350x350" width="70" height="70" /> <img src="http://placehold.it/350x350" width="70" height="70" /> <img src="http://placehold.it/350x350" width="70" height="70" /> <img src="http://placehold.it/350x350" width="70" height="70" /> </div> 
 
    <div id="next"> <a href="#" class="images">&dArr; </a> <a href="#" class="thumbs">&dArr; </a> </div> 
 
</div> 
 
</body>