我正在使用Django制作一个博客发布网站。当用户发布文章时,如果标题有21个字符,那么文章看起来很棒。如果标题有35个字符,它将使作者、日期和缩略图向右移动,如果少于21个字符,则将它们向左移动。我不希望出现这种情况!
目前的显示效果如下:
{% for post in posts %}
<div class="blogpost">
<a class="post-title"> {{post.title}} </a>
<img class="thumbnail" src="{{post.author.imageURL}}">
<a class="date-author">{{post.date}} - {{post.author}}</a>
<br>
<hr>
<br>
<div class="blogpost-content">{{post.context|linebreaks}}</div>
<br>
<br>
<br>
</div>
<br>
{% endfor %}
CSS 代码
.blogpost {
/*Whole blogpost div*/
border: 5px solid #149414;
background-color: black;
color: #149414;
width: 700px;
margin:auto;
border-radius: 40px;
border-width: 1px;
}
hr{
/*The middle line in the blogpost*/
height: 1px;
background-color: #149414;
border: none;
}
.thumbnail{
/*The author's image of the blogpost*/
height: 120px;
width: 120px;
position: relative;
right: -70px;
bottom: 4px;
border: 3px solid #149414;
border-radius: 50%;
}
.blogpost-content{
/*Content in the blogpost*/
text-align: left;
margin-left: 30px;
margin-right: 30px;
}
.date-author{
/*The date and author div in the blogpost*/
font-size: 12;
margin:10%;
}
.green_link{
/*Green link to the random key*/
color:#149414;
}
.post-title{
font-size: 40px;
margin: 10%;
}
我尝试跟随这个视频:https://www.youtube.com/watch?v=jx5jmI0UlXU,但好像不起作用。我认为这与...有关。
position: relative;
但我不确定。