让2个Divs并排Html Django。

问题描述 投票:1回答:1

我的问题是,我不能在一行中放置2个以上的div。我不能使用浮动,因为我有一个不稳定的DIVs数量(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>

索引样式.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;
}
python html css django
1个回答
0
投票

你应该使用 divrowcol 以获得并排的divs,即使divs的数量是未知的。

© www.soinside.com 2019 - 2024. All rights reserved.