当屏幕变小时,如何将div叠加在一起?引导

时间:2017-05-13 14:46:18

标签: html css twitter-bootstrap grid resize

我有三个div并排,我希望它们在屏幕变小时叠加在一起。相反,div调整大小使内容看起来很糟糕。

我按照w3schools教程(bootstrap_grid_stacked_to_horizo​​ntal)将它们放入container div和row div中,除了添加类col-lg-4之外,还要进行堆叠,但它们仍会调整大小。

这是相关的HTML和CSS:



.how-it-works-container{
    	padding: 50px;
    	background-color: #C5B358;
    	font-family: 'Montserrat', sans-serif;
    	opacity: .8;
    	text-align: center;
    
    	width: 100%
    }
 
    .how-it-works-box{
    	padding: 30px;
    	background-color: #D6C362;
    	margin: 20px 5px;
    	
    	width: calc(30%);
    	overflow-wrap: break-word;
    	color: white;
    	display: inline-block;
    	box-shadow: 0 4px 8px 0 rgba(255, 255, 255, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
    }

<!-- How It Works section -->
<div class="how-it-works-container container">

    <h2>How It Works</h2>

  <div class="row">

      <div class="how-it-works-box col-lg-4"> 
        <img src=" {% static "images/meetlocals3.svg" %} "> 
        <h3>Meet Local People</h3>
        <p>Meet like-minded locals who could show you around their city.</p>
      </div>

      <div class="how-it-works-box col-lg-4">
        <img src=" {% static "images/showpeople.svg" %} ">
        <h3>Show Visitors Around</h3>
        <p>Show visitors around and meet interesting international visitors.</p>
      </div>

      <div class="how-it-works-box col-lg-4">
        <img src=" {% static "images/makefriends.svg" %} ">
        <h3>Make New Friends!</h3>
        <p>Walking around is a fun bonding activity to make new friends!</p>
      </div>

    </div>
</div>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

CSS正在覆盖Bootstrap网格。将这些框放在Bootstrap网格列中,这些列将自动堆叠在xs屏幕上。

http://www.codeply.com/go/gTkC50Paql

.how-it-works-container{
    padding: 50px;
    background-color: #C5B358;
    font-family: 'Montserrat', sans-serif;
    opacity: .8;
    text-align: center;
}

.how-it-works-box{
    width: 100%;
    padding: 30px;
    background-color: #D6C362;
    margin: 20px 5px;
    overflow-wrap: break-word;
    color: white;
    display: inline-block;
    box-shadow: 0 4px 8px 0 rgba(255, 255, 255, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}

<div class="how-it-works-container container-fluid">
    <h2>How It Works</h2>
    <div class="row">
        <div class="col-lg-4">
            <div class="how-it-works-box">
                <img src="">
                <h3>Meet Local People</h3>
                <p>Meet like-minded locals who could show you around their city.</p>
            </div>
        </div>
        <div class="col-lg-4">
            <div class="how-it-works-box">
                <img src="">
                <h3>Show Visitors Around</h3>
                <p>Show visitors around and meet interesting international visitors.</p>
            </div>
        </div>
        <div class="col-lg-4">
            <div class="how-it-works-box">
                <img src="">
                <h3>Make New Friends!</h3>
                <p>Walking around is a fun bonding activity to make new friends!</p>
            </div>
        </div>
    </div>
</div>

答案 1 :(得分:0)

如你所知,bootstrap有12列,所以你需要添加int main(void) { DDRD = 0x00; // set PORTC for input DDRB = 0xFF; // set PORTB for output PORTB = 0x00; // Initial value is 0 PCICR |= _BV(PCIE2); //or, PCICR |= 0x04; PCMSK2 |= 0xFF; //any changes in PIND will trigger interrupt d = 4000; sei(); //other codes... } col-xs-12,然后对于额外的小屏幕,每个div将占用所有12列。

col-lg-4

最好为所有尺码添加标签。 <div class="col-lg-4 col-xs-12"> <div class="how-it-works-box"> <img src=""> <h3>Meet Local People</h3> <p>Meet like-minded locals who could show you around their city.</p> </div> </div> <div class="col-lg-4 col-xs-12"> <div class="how-it-works-box"> <img src=""> <h3>Show Visitors Around</h3> <p>Show visitors around and meet interesting international visitors.</p> </div> </div> <div class="col-lg-4 col-xs-12"> <div class="how-it-works-box"> <img src=""> <h3>Make New Friends!</h3> <p>Walking around is a fun bonding activity to make new friends!</p> </div> </div> 以及col-md-