代码之家  ›  专栏  ›  技术社区  ›  MK-DK

使引导程序列的高度大于768 px

  •  0
  • MK-DK  · 技术社区  · 7 年前

    我用bootstrap 3制作了4列。每列都是 400x220px . 我愿意做任何事来制作那些专栏 300x350px 当视窗点击时 < 768px . 我不知道这样做的方法,正如我看到的,引导程序无法做到这一点。

    我可以用HTML5 <picture> 标签。但是我看不到我可以将它与bootstrap 3网格集成,在我看来这不是一个好的解决方案。

    有人对我该怎么做还有别的想法吗,还是不可能?

    A demo of the columns is here .

      background-color: #f5f5f5;
        }
        /* Set width between grid elements */
        .small-padding.top {
           padding-top:10px;
        }
    
        .small-padding.bottom {
            padding-bottom:10px;
        } 
        .small-padding.left {
            padding-left:5px;
        }
    
        .small-padding.right {
            padding-right:5px;
        }
        .margin_bottom {
          margin-bottom: 10px;
        }
        .row [class*="col-"] {
          padding-right: 5px;
          padding-left: 5px;
        }
        .row {
          margin-left: -5px;
          margin-right: -5px;
        }
        .img-responsive { 
            height: 100%;
        }
        /* Position of buttons/text in a single grid element */
        .inner-wrapper {
          text-align: center;
          background: none;
        }
        .centered {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
    
        .bottom-right {
            position: absolute;
            bottom: 8px;
            right: 16px;
        }
    
        .bottom-left {
            position: absolute;
    
            bottom: 8px;
            left: 16px;
        }
        /* Color on text */
        .dark-font {
          color: #333;
        }
        .light-font {
          color: #fff;
        }
       
        /* Set full width on columns */
        @media (max-width: 768px) {
          .img-responsive {
            width: 100%;
            }
          .btn-success {
            width: fit-content;
          }
    
        }
    
        @media (max-width: 991px) {
          h3 {
            font-size: 1.2em;
    
          }
        }
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <title>TEMPLATE</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!------ Include the above in your HEAD tag ---------->
    </head>
    <body>
    	<div class="container-fluid">
    		<div class="row">
    	        <div class="col-xs-6 col-sm-3 margin_bottom">
    	            <img src="http://placehold.it/400x220" alt="5" class="img-responsive" />
    	            <div class="inner-wrapper bottom-left">
    	            	<h3>Here is headline 1</h3>
    	            </div>
    	        </div>
    	        <div class="col-xs-6 col-sm-3 margin_bottom">
    	            <img src="http://placehold.it/400x220" alt="5" class="img-responsive" />
    	            <div class="inner-wrapper bottom-left">
    	                <h3>Here is headline 2</h3>
    	            </div>
    	        </div>
    	        <div class="col-xs-6 col-sm-3 margin_bottom">
    	            <img src="http://placehold.it/400x220" alt="5" class="img-responsive" />
    	            <div class="inner-wrapper bottom-right">
    	                <h3>Here is headline 3</h3>
    	            </div>
    	        </div>
    	        <div class="col-xs-6 col-sm-3 margin_bottom">
    	            <img src="http://placehold.it/400x220" alt="5" class="img-responsive" />
    	            <div class="inner-wrapper bottom-right">
    	                <h3>Here is headline 4</h3>
    	            </div>
    	        </div>
    	    </div>
    	</div>
    </body>
    </html>
    1 回复  |  直到 7 年前
        1
  •  1
  •   rileyjsumner    7 年前

    向容器中添加类,给它一个高度…我想这就是你想要的。如果没有,请告诉我!

      background-color: #f5f5f5;
        }
        /* Set width between grid elements */
        .small-padding.top {
           padding-top:10px;
        }
    
        .small-padding.bottom {
            padding-bottom:10px;
        } 
        .small-padding.left {
            padding-left:5px;
        }
    
        .small-padding.right {
            padding-right:5px;
        }
        .margin_bottom {
          margin-bottom: 10px;
        }
        .row [class*="col-"] {
          padding-right: 5px;
          padding-left: 5px;
        }
        .row {
          margin-left: -5px;
          margin-right: -5px;
        }
        .img-responsive { 
            height: 100%;
        }
        /* Position of buttons/text in a single grid element */
        .inner-wrapper {
          text-align: center;
          background: none;
        }
        .centered {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
    
        .bottom-right {
            position: absolute;
            bottom: 8px;
            right: 16px;
        }
    
        .bottom-left {
            position: absolute;
    
            bottom: 8px;
            left: 16px;
        }
        /* Color on text */
        .dark-font {
          color: #333;
        }
        .light-font {
          color: #fff;
        }
       
        /* Set full width on columns */
        @media (max-width: 768px) {
          .img-responsive { /*EDIT*/
            width: 100%;
            height: auto;
            }
          .btn-success {
            width: fit-content;
          }
          /* Here you go */
          .height-m {
            height: 350px;
          }
    
        }
    
        @media (max-width: 991px) {
          h3 {
            font-size: 1.2em;
    
          }
        }
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <title>TEMPLATE</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!------ Include the above in your HEAD tag ---------->
    </head>
    <body>
    	<div class="container-fluid">
    		<div class="row">
    	        <div class="col-xs-6 col-sm-3 margin_bottom height-m">
    	            <img src="http://placehold.it/400x220" alt="5" class="img-responsive" />
    	            <div class="inner-wrapper bottom-left">
    	            	<h3>Here is headline 1</h3>
    	            </div>
    	        </div>
    	        <div class="col-xs-6 col-sm-3 margin_bottom height-m">
    	            <img src="http://placehold.it/400x220" alt="5" class="img-responsive" />
    	            <div class="inner-wrapper bottom-left">
    	                <h3>Here is headline 2</h3>
    	            </div>
    	        </div>
    	        <div class="col-xs-6 col-sm-3 margin_bottom height-m">
    	            <img src="http://placehold.it/400x220" alt="5" class="img-responsive" />
    	            <div class="inner-wrapper bottom-right">
    	                <h3>Here is headline 3</h3>
    	            </div>
    	        </div>
    	        <div class="col-xs-6 col-sm-3 margin_bottom height-m">
    	            <img src="http://placehold.it/400x220" alt="5" class="img-responsive" />
    	            <div class="inner-wrapper bottom-right">
    	                <h3>Here is headline 4</h3>
    	            </div>
    	        </div>
    	    </div>
    	</div>
    </body>
    </html>