【问题标题】:Boostrap 3, toggle collapse wont stay closed on page loadBootstrap 3,切换折叠不会在页面加载时保持关闭状态
【发布时间】:2015-09-03 13:37:16
【问题描述】:

我在 boostrap 3 中使用 data-toggle="collapse" 但在页面加载时我隐藏的 div 内容不会保持关闭状态。我搜索了许多解决方案,但没有一个有效。下面是我的代码,对新手编码表示歉意,但我是自雇人士,还没有时间精通 html。

<div class="row">
    <div class="container">
        <div class="col-md-12">
            <div class="thumbnail">
                <img src="img/ground/grnd1.jpg" alt="...">
  <div class="caption">

    <p style=" color: dimgray;">text here,text here,text here,text here,text here,</p>
    <p> <a class="btn btn-default" href="#foundations" data-toggle="collapse" data-target="#foundations" style="padding:2%;">Continue Reading &raquo;</a></p>
  </div>

      <div class="container" >
                    <div class="collaspe" id="foundations" data-toggle="false">
                    <br><br>
                <div class="col-md-12 col-sm-12">
                    <h1 style=" color: dimgray; font-weight:300; margin-top:5%;">Pad Foundations</h1>
                <br><br>
                    <img src="img/ground/grnd2.jpg" alt="..." style="width:100%;">
                     <p style=" color: dimgray;">text here, text here, text here, text here, </p><br><br>

                     <h1 style=" color: dimgray; font-weight:300; margin-top:5%;">Jack Pad Foundations</h1>
                     <img src="img/ground/grnd5.jpg" alt="..."  style="width:100%;">
                     <p style=" color: dimgray;">text here,text here,text   here,text here,</p><br><h2 style="font-weight: 300">Need advice?<a    href="contact_us.html">Contact us</a></h2><br><br>                   
  </div> 
  </div>
  </div>
  </div>
  </div>
  </div>
  </div>

提前谢谢你

【问题讨论】:

    标签: html css


    【解决方案1】:

    您为 id 为“foundations”的 div 拼错了“collapse”类名。

    <div class="row">
        <div class="container">
            <div class="col-md-12">
                <div class="thumbnail">
                    <img src="img/ground/grnd1.jpg" alt="...">
                    <div class="caption">
    
                        <p style=" color: dimgray;">text here,text here,text here,text here,text here,</p>
                        <p> <a class="btn btn-default" href="#foundations" data-toggle="collapse" data-target="#foundations" style="padding:2%;">Continue Reading &raquo;</a>
                        </p>
                    </div>
    
                    <div class="container">
                        <div class="collapse" id="foundations" data-toggle="false">
                            <br>
                            <br>
                            <div class="col-md-12 col-sm-12">
                                <h1 style=" color: dimgray; font-weight:300; margin-top:5%;">Pad Foundations</h1>
                                <br>
                                <br>
                                <img src="img/ground/grnd2.jpg" alt="..." style="width:100%;">
                                <p style=" color: dimgray;">text here, text here, text here, text here, </p>
                                <br>
                                <br>
    
                                <h1 style=" color: dimgray; font-weight:300; margin-top:5%;">Jack Pad Foundations</h1>
                                <img src="img/ground/grnd5.jpg" alt="..." style="width:100%;">
                                <p style=" color: dimgray;">text here,text here,text here,text here,</p>
                                <br>
                                <h2 style="font-weight: 300">Need advice?<a    href="contact_us.html">Contact us</a></h2>
                                <br>
                                <br>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    

    【讨论】:

    • 哈哈,总结了我的一天,非常感谢 Chitrang 它有效!我一直在尝试解决这个问题 3 小时哈哈。
    猜你喜欢
    • 1970-01-01
    • 2014-09-08
    • 2014-12-23
    • 1970-01-01
    • 2015-01-18
    • 2014-02-07
    • 2012-09-25
    • 2015-06-11
    • 1970-01-01
    相关资源
    最近更新 更多