【问题标题】:Overflow after inserting image in column在列中插入图像后溢出
【发布时间】:2018-03-03 11:55:16
【问题描述】:

我知道这是一个设置问题,但我是新手,不知道用什么确切的术语来获得我正在寻找的答案。

我在 Django 1.11 上使用 Bootstrap-3.3.7

当我在第一列和第一行插入图像时,我会溢出到第二列。

有图片

没有图像的列可以正常工作。

                          <div class="tab-content">

                          <div class="tab-pane active" id="{{vg.grouper.id}}{{fg.grouper.id}}hari_ini">

                            <div class="row">                               
                            {% for sg in show_list2 %}
                            {% if sg.grouper %}
                            {% for sh in sg.list %} 

                            <div class="col-xs-3 col-xs-spl col-xs-npr">
                                <div class="contain">
                                                {% load static %}

                                                {% ifchanged %}
                                                <img src='{% static sh.film.poster %}' width= 100% >
                                                {% endifchanged %}
                                </div>          
                            </div>


                            <div class="col-xs-3 col-xs-npl col-xs-npr">
                                <div class="content">
                                    <ul>
                                        <li>
                                                <p class=p1>{{ sh.show_time_today }}</p>

                                        </li>
                                    </ul> 
                                </div>
                            </div>
                           <div class="col-xs-3 col-xs-npl col-xs-npr">
                                <div class="content">
                                    <ul>
                                        <li>

                                            <p class=p1>{{ sh.rps_price }}</p>



                                        </li>
                                    </ul> 
                                </div>
                            </div>
                            <div class="col-xs-3 col-xs-npl col-xs-npr">
                                <div class="content">
                                    <ul>
                                        <li>

                                            <p class=p1>{{ sh.rps_price }}</p>



                                        </li>
                                    </ul> 
                                </div>
                            </div>
                                        {% endfor %}
                                            {% endif %}
                                        {% endfor %}

                                    </div>
                          </div>

我尝试了下面的 css,但没有帮助。

.contain {
    height: /* max height you want */
    width: 95% /* max width you want */
    overflow: hidden;
}

我尝试使用 col3 和 col9 添加一行,并使用 col12 和 col4 col4 col4 添加相应的行,但结果流变得更加混乱。

应用 Astik 的更改后,屏幕看起来更好,没有空行/列。我仍然看到所有列的溢出。此外,右侧的文本填充/对齐也不正确。这是造成问题的原因

 p {

 }
.p1 {
    color: gold;
 font-size: 3.8vw;
text-align: center;
 line-height: 60%;
 margin-top: 5px;
}

ul{
list-style-type: none;
padding-left: 0;

}
li{
 list-style-type: none;
}
col-xs-*{

}
.col-xs-npr{
    padding-right: 0;
}
.col-xs-npl{
    padding-left: 0;
}
.col-xs-smpr{
    padding-right: 3px;
}
.col-xs-smpl{
    padding-left: 3px;
}
}

【问题讨论】:

  • 给出答案,我认为这个案子应该在官方关闭的原因下关闭:这个问题是由一个无法再复制的问题引起的

标签: python css django python-3.x twitter-bootstrap-3


【解决方案1】:

最后,我通过在 Firefox 中打开页面并在 Inspector 中仔细查看呈现的 html (Ctrl + Shift + i) 来解决问题。

从那里我可以看到哪些部分正在填充数据。最后,我的for 循环不在正确的位置。此外,我发现在使用 if 语句时,我需要将模板标签放在 div 标签内。

                <div class="tab-pane" id="{{vg.grouper.id}}{{fg.grouper.id}}besok">
                <div class="row">
                        {% for sg in show_list2 %}
                        {% for sh in sg.list %}
                <div class="col-xs-4 col-xs-npr col-xs-smpl">
                    <div class="content">

                        {% if not sg.grouper %}
                        <div class="content">
                            {% ifchanged %}<p class=p2>{% tomorrow "%a, %d %b" %}</p>{% endifchanged %}
                            <p class=p1>{{ sh.show_time_tomorrow }}</p>
                        </div>
                      </div>
                    </div>
                        {% endfor %}
                        {% endfor %} 
                    </div>
                </div>

【讨论】:

    猜你喜欢
    • 2022-06-16
    • 2021-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-10
    • 2017-02-21
    • 1970-01-01
    • 2022-07-01
    相关资源
    最近更新 更多