我的问题是,我不能在一行中放置2个以上的div。我不能使用浮动,因为我有一个不稳定的DIVs数量(Django的每一个帖子的DIV)这是我使用的代码。
<!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>
.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;
}
你应该使用 div
袢 row
和 col
以获得并排的divs,即使divs的数量是未知的。