将2个Divs并排制作Html Django

时间:2018-04-23 19:26:37

标签: python html css django

我的问题是我不能在一行中放置2个以上的div。我不能使用float因为我有一个不稳定的div数(django中的每个帖子都有一个div) 这是我正在使用的代码:

的index.html

<!DOCTYPE html>
<html>
<head>
    {% load static %}
    <link rel="stylesheet" type="text/css" href="{% static "Css/indexstyle.css" %}">
    <title>Temporary</title>
</head>
<body>
{% for post in posts %}
    <a href="#"><div class="cl1">
        <img src="{% static 'Img/img.jpg' %}" id="picture">
        <center>{{ post.title}}</center>
        </center>
    </div></a>
{% endfor %}

</body>
</html>

indexstyle.css

.product {
    height: 350px;
    width: 250px;
    background-color: #E5E5E5;
    border-radius: 10px;
    margin-right: 2em;
    float: left;
}

img{
    height: 200px;
    width: 250px;
    border-radius: 10px 10px 0px 0px;
}

a{
    text-decoration : none;
    color: inherit;
}

1 个答案:

答案 0 :(得分:0)

您应该将div标记与rowcol类一起使用,以使div并排显示,即使div的数量未知。