我的问题是我不能在一行中放置2个以上的div。我不能使用float因为我有一个不稳定的div数(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;
}
答案 0 :(得分:0)
您应该将div
标记与row
和col
类一起使用,以使div并排显示,即使div的数量未知。