【问题标题】:A responsive div is getting way to long height using bootstrap响应式 div 正在使用引导程序达到长高度
【发布时间】:2018-02-08 21:32:56
【问题描述】:

我有一个使用 Chartist 在一行上显示 4 个条形图的网站。 我正在尝试使用 Bootstrap 的响应式解决方案来显示 4 个图表,一个位于另一个下方,但是当我访问 iphone 6 上的页面时,图表 div 的高度越来越长。奇怪的是,当我修改 Chrome 的窗口大小时浏览器,就像一个魅力。

这是我的网站:http://clipping.primerahora.cl/

这是有问题的html部分:

<div class="container">
    <div class="row">
            <div style="display:table; margin:0 auto;">
                <div id="chart-01" class="col-md-3 ct-chart01 d1" style="display:table; margin:0 auto; width:22%; height:50%; max-height: 50%; margin:5px; background-color: white; font-family: arial; font-stretch: condensed; text-align: center;">Tipo de Prensa</div>
                <div id="chart-02" class="col-md-3 ct-chart02 d1" style="display:table; margin:0 auto; width:22%; height:50%; max-height: 50%; margin:5px; background-color: white; font-family: arial; font-stretch: condensed; text-align: center;">Medios mas vistos</div>
                <div id="chart-03" class="col-md-3 ct-chart03 d1" style="display:table; margin:0 auto; width:22%; height:50%; max-height: 50%; margin:5px; background-color: white; font-family: arial; font-stretch: condensed; text-align: center;">Regiones</div>
                <div id="chart-04" class="col-md-3 ct-chart04 d1" style="display:table; margin:0 auto; width:22%; height:50%; max-height: 50%; margin:5px; background-color: white; font-family: arial; font-stretch: condensed; text-align: center;">Productos</div>   
            </div>
        </div>
</div>

我尝试使用一些媒体查询但没有运气:

@media screen and (min-width: 1024px) {
.d1{
    max-height:50%;
    height:50%;
  }
}      

@media screen and (max-width: 800px) {
.d1{
    max-height:50%;
    height:50%;
   }
}

@media screen and (max-width: 600px) {
.d1{
    max-height:50%;
    height:50%;
   }
}

【问题讨论】:

    标签: jquery css twitter-bootstrap media-queries chartist.js


    【解决方案1】:

    将您的 html 更改为,

    <div class="container">
        <div class="row">
             <div id="chart-01" class="col-md-3 ct-chart01 d1" style="margin:0 auto; width:22%; height:50%; max-height: 50%; margin:5px; background-color: white; font-family: arial; font-stretch: condensed; text-align: center;">Tipo de Prensa</div>
             <div id="chart-02" class="col-md-3 ct-chart02 d1" style="margin:0 auto; width:22%; height:50%; max-height: 50%; margin:5px; background-color: white; font-family: arial; font-stretch: condensed; text-align: center;">Medios mas vistos</div>
             <div id="chart-03" class="col-md-3 ct-chart03 d1" style="margin:0 auto; width:22%; height:50%; max-height: 50%; margin:5px; background-color: white; font-family: arial; font-stretch: condensed; text-align: center;">Regiones</div>
             <div id="chart-04" class="col-md-3 ct-chart04 d1" style="margin:0 auto; width:22%; height:50%; max-height: 50%; margin:5px; background-color: white; font-family: arial; font-stretch: condensed; text-align: center;">Productos</div>   
        </div>
    </div>
    

    你可以进一步改进它,

    CSS,

    .d1 {
       height: 175px;
    }
    
    .chart-wrapper {
       height:100%;
       background-color: white;
       font-family: arial; font-stretch: condensed;
       text-align: center;
    }
    

    HTML,

    <div class="container">
        <div class="row">
             <div class="col-md-3 d1"><div id="chart-01" class="chart-wrapper ct-chart01">Tipo de Prensa</div></div>
             <div class="col-md-3 d1"><div id="chart-02" class="chart-wrapper ct-chart02">Medios mas vistos</div></div>
             <div class="col-md-3 d1"><div id="chart-03" class="chart-wrapper ct-chart03">Regiones</div></div>
             <div class="col-md-3 d1"><div id="chart-04" class="chart-wrapper ct-chart04">Productos</div></div>   
        </div>
    </div>
    

    【讨论】:

    • 现在,当我缩小 Chrome 的窗口时,我只看到每个 div 的四分之一,在 iphone 6 上也是如此。
    • 用更新的代码再次检查。我可以在现场看到吗?
    • 如果我使用最后一个代码,我会看到 div 之外的图表,所以我像这样合并了 div
      标题
      并且成功了!我只需要将每个图表分开一点。谢谢
    • 是的,很抱歉。后来只有我检查了你的脚本。我已经更新了标记。希望答案对您有所帮助。如果它解决了您的问题,请不要忘记批准答案。干杯:)
    猜你喜欢
    • 2015-06-23
    • 1970-01-01
    • 2016-03-19
    • 2019-12-22
    • 1970-01-01
    • 2014-09-16
    • 2017-03-30
    • 2019-12-20
    • 2017-09-13
    相关资源
    最近更新 更多