【问题标题】:how to make the divs at the same size如何使 div 大小相同
【发布时间】:2020-08-27 14:13:32
【问题描述】:

我怎样才能使所有的 div 大小相同

我正在使用 django ??

 <div class="row text-left">

                    {% for meg in objj %}
                    <div class="col-lg-6 col-md-12">

                        <!--Image-->
                        <div class="view overlay rounded z-depth-1-half mb-3">
                            <img src="{{ meg.img.url }}" class="img-fluid" alt="Sample post image" height="100%"
                                width="150%">
                            <a>
                                <div class="mask rgba-white-slight"></div>
                            </a>


                    {% endfor %}

型号:

class News(models.Model):
    title = models.CharField(max_length=250)
    body = models.TextField()
    img = models.ImageField(upload_to='media/')

    def __str__(self):
        return self.title

enter image description here

【问题讨论】:

    标签: django django-models bootstrap-4


    【解决方案1】:

    按照你的方式,它只会生成相同大小的 div。

    但是你忘记了 for 循环中的&lt;/div&gt;

    解决这个问题对你有用。

    {% for meg in objj %}
    <div class="col-lg-6 col-md-12">
        <!--Image-->
        <div class="view overlay rounded z-depth-1-half mb-3">
            <img src="{{ meg.img.url }}" class="img-fluid" alt="Sample post image" height="100%"
                width="150%">
            <a>
                <div class="mask rgba-white-slight"></div>
            </a>
        <!---- !!!!!!!! you are missing the below 2 closing divs --->
        </div>
    </div>
    {% endfor %}                  
    

    【讨论】:

    • 同意。结束标签对于 Django、Bootstrap 等框架很重要。
    猜你喜欢
    • 2019-12-27
    • 1970-01-01
    • 2019-06-09
    • 2018-06-13
    • 2020-10-12
    • 1970-01-01
    • 2021-12-19
    • 2013-12-13
    • 1970-01-01
    相关资源
    最近更新 更多