我试图让我的照片库适合移动窗口。我在响应/移动方面的大多数经验都来自twitter bootstrap,它可以为您完成所有工作。
这是jsfiddle(按钮不起作用,因为我没有包含我的javascript):http://jsfiddle.net/L9hued7b/2/
HTML:
<body>
<div id="wrapper">
<div id="prev">
<a href="#" class="images">⇑ </a>
<a href="#" class="thumbs">⇑ </a>
</div>
<div id="images">
<!-- large images on left-->
</div>
<div id="thumbs">
<!--thumbnails on right-->
</div>
<div id="next">
<a href="#" class="images">⇓ </a>
<a href="#" class="thumbs">⇓ </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 :(得分:0)
如果您将此添加到您的css文件并调整浏览器大小,您将看到它们将堆叠在一起。因此,当屏幕的宽度低于500px时,框的样式将有所不同。您可能需要查看按钮的位置,但是您可以在@media块中执行此操作,因此它仅适用于宽度低于500px的屏幕。
@media (max-width: 500px) {
#images, #thumbs {
display: block;
width: 100%;
float: left;
}
}
答案 1 :(得分: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;}
}
}
&#13;
答案 2 :(得分:0)
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;
}
@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">⇑ </a> <a href="#" class="thumbs">⇑ </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">⇓ </a> <a href="#" class="thumbs">⇓ </a> </div>
</div>
</body>