2017-07-17 32 views
0

我的最終目標是能夠完美地將我的網格合併到2列中,因此它適合我的移動設備上的整個屏幕。現在,我仍然需要向下滾動一下,但這不是我想要的。我希望我的屏幕不可滾動,但圖像/屏幕完全符合我的願望。也許擺脫2列之間的空間。現在我的屏幕看起來有點偏離,需要一點滾動。底部的2張圖片不適合,需要滾動,如圖片所示。網格,使我可以適應它整個移動屏幕,無需滾動

enter image description here

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script> 
 
<!DOCTYPE html> 
 
<html lang="en"> 
 

 
<head> 
 
    <meta charset="utf-8"> 
 
    <title>Swiper demo</title> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"> 
 

 
    <!-- Link Swiper's CSS --> 
 

 

 
    <link rel="stylesheet" href="../dist/css/swiper.min.css"> 
 
    <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='styles/swiper.min.css') }}"> 
 

 
    <!-- Demo styles --> 
 
    <style> 
 
    html, 
 
    body { 
 
     position: relative; 
 
     height: 100%; 
 
    } 
 
    
 
    .swiper-container { 
 
     width: 100%; 
 
     height: 100%; 
 
    } 
 
    
 
    .swiper-slide { 
 
     top: 0; 
 
     left: 0; 
 
     top: 0; 
 
     bottom: 0; 
 
     right: 0; 
 
     overflow-y: auto; 
 
     height: 100%; 
 
     width: 100%; 
 
     display: flex; 
 
     flex-wrap: wrap; 
 
     justify-content: space-between; 
 
    } 
 
    
 
    body { 
 
     margin: 0; 
 
     padding: 0; 
 
     background-color: white; 
 
     font: 10px/13px 'Lucida Sans', sans-serif; 
 
    } 
 
    
 
    .wrap { 
 
     overflow: hidden; 
 
     margin: 10px; 
 
    } 
 
    
 
    .box { 
 
     float: center; 
 
     position: relative; 
 
     width: 200%; 
 
     padding-bottom: 100%; 
 
    } 
 
    
 
    .boxInner { 
 
     position: absolute; 
 
     left: 50px; 
 
     right: -5px; 
 
     top: -10px; 
 
     bottom: 10px; 
 
     overflow: hidden; 
 
    } 
 
    
 
    .fixed { 
 
     position: absolute; 
 
     left: 30px; 
 
     right: 10px; 
 
     top: -10px; 
 
     bottom: 10px; 
 
     overflow: hidden; 
 
    } 
 
    
 
    .boxInner img { 
 
     width: 79%; 
 
     height: 75% 
 
    } 
 
    
 
    .boxInner img.img2 { 
 
     width: 100%; 
 
     height: 50% 
 
    } 
 
    
 
    body.no-touch .boxInner:hover .titleBox, 
 
    body.touch .boxInner.touchFocus .titleBox { 
 
     margin-bottom: 100; 
 
    } 
 
    
 
    @media only screen and (max-width: 480px) { 
 
     /* Smartphone view: 1 tile */ 
 
     .topnav a:not(:first-child) { 
 
     display: none; 
 
     } 
 
     .topnav a.icon { 
 
     float: right; 
 
     display: block; 
 
     } 
 
     .box { 
 
     width: 50%; 
 
     padding-bottom: 30%; 
 
     } 
 
    } 
 
    
 
    .topnav { 
 
     overflow: hidden; 
 
     background-color: #66CDAA; 
 
    } 
 
    
 
    .topnav a { 
 
     float: center; 
 
     display: block; 
 
     color: #f2f2f2; 
 
     text-align: center; 
 
     padding: 10px 16px; 
 
     text-decoration: none; 
 
     font-size: 17px; 
 
    } 
 
    
 
    .topnav a:hover { 
 
     background-color: #98FB98; 
 
     color: white; 
 
    } 
 
    
 
    .topnav .icon { 
 
     display: none; 
 
    } 
 
    
 
    .header1 { 
 
     margin: auto; 
 
     float: center; 
 
     padding: 15px; 
 
     font-size: 20px; 
 
    } 
 
    </style> 
 
</head> 
 

 
<body class="no-touch"> 
 
    <!-- Swiper --> 
 
    <div class="topnav" id="myTopnav"> 
 
    <a href="#home">Let's Get To Know You!</a> 
 

 
    </div> 
 
    <div class="swiper-container"> 
 

 
    <div class="swiper-wrapper"> 
 

 

 
     <div class="swiper-slide"> 
 

 

 
     <!-- Define all of the tiles: --> 
 
     <div class="header1">What's your skin color?</div><br><br> 
 
     <div class="box"> 
 
      <div class="boxInner"> 
 
      <img class='img1' src="http://i.imgur.com/U8pJVY0.png" /> 
 
      </div> 
 
     </div> 
 
     <div class="box"> 
 
      <div class="boxInner"> 
 
      <img class='img1' src="http://i.imgur.com/Kz06qEO.png" /> 
 

 
      </div> 
 
     </div> 
 
     <div class="box"> 
 
      <div class="boxInner"> 
 
      <img class='img1' src="http://i.imgur.com/43tH7Td.png" /> 
 

 
      </div> 
 
     </div> 
 
     <div class="box"> 
 
      <div class="boxInner"> 
 
      <img class='img1' src="http://i.imgur.com/3uZKpV2.png" /> 
 

 
      </div> 
 
     </div> 
 
     <div class="box"> 
 
      <div class="boxInner"> 
 
      <img class='img1' src="http://i.imgur.com/SF3vYC9.png" /> 
 

 
      </div> 
 
     </div> 
 
     <div class="box"> 
 
      <div class="boxInner"> 
 
      <img class='img1' src="http://i.imgur.com/8hujzfl.png" /> 
 

 
      </div> 
 
     </div> 
 
     <div class="box"> 
 
      <div class="boxInner"> 
 
      <img class='img1' src="http://i.imgur.com/cxvELu2.png" /> 
 

 
      </div> 
 
     </div> 
 
     <div class="box"> 
 
      <div class="boxInner"> 
 
      <img class='img1' src="http://i.imgur.com/zLD3Nv1.png" /> 
 

 
      </div> 
 
     </div> 
 
     <div class="box"> 
 
      <div class="boxInner"> 
 
      <img class='img1' src="http://i.imgur.com/baYebAV.png" /> 
 

 
      </div> 
 
     </div> 
 
     <div class="box"> 
 
      <div class="boxInner"> 
 
      <img class='img1' src="http://i.imgur.com/iLd0ukK.png" /> 
 

 
      </div> 
 
     </div> 
 

 

 
     </div> 
 

 

 
    </div> 
 

 
    </div> 
 
    <!-- Add Pagination --> 
 
    <div class="swiper-pagination"></div> 
 
    <!-- Add Arrows --> 
 
    <div class="swiper-button-next"></div> 
 
    <div class="swiper-button-prev"></div> 
 
    </div> 
 

 
    <!-- Swiper JS --> 
 
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script> 
 
    <script src="../dist/js/swiper.min.js"></script> 
 
    <script type="text/javascript" src="{{ url_for('static', filename='swiper.min.js') }}"></script> 
 
    <!-- Initialize Swiper --> 
 
    <script> 
 
    var swiper = new Swiper('.swiper-container', { 
 
     pagination: '.swiper-pagination', 
 
     paginationClickable: true, 
 
     nextButton: '.swiper-button-next', 
 
     prevButton: '.swiper-button-prev', 
 
     spaceBetween: 30 
 

 
    }); 
 
    </script> 
 
    <script type="text/javascript"> 
 
    $(function() { 
 
     // See if this is a touch device 
 
     if ('ontouchstart' in window) { 
 
     // Set the correct body class 
 
     $('body').removeClass('no-touch').addClass('touch'); 
 

 
     // Add the touch toggle to show text 
 
     $('div.boxInner img').click(function() { 
 
      $(this).closest('.boxInner').toggleClass('touchFocus'); 
 
     }); 
 
     } 
 
    }); 
 
    </script> 
 
</body> 
 

 
</html>

回答

0

這是因爲你的 「刷卡容器」 是height:100%,但33px下來開始,因爲它上面的元素。如果您的browser target range allows it爲了使其100%高度減去上述元素的高度,您可以嘗試使用calc() css。例如:

height: calc(100% - 33px);