[英]How to position container to fixed position?
I have a div where I display next and previous blog post. 我有一个div,在其中显示下一个和上一个博客文章。 I have the title in one container
(footer_post_title)
and the year and "read more button" in another container (footer_post_buttons)
underneath. 我将标题放在一个容器
(footer_post_title)
,将年份和“阅读更多按钮”放在另一个容器(footer_post_buttons)
。 I need to have the second container stay in the bottom of the main container (blog_image_footer)
no matter how long the title is in (footer_post_title)
. 无论标题
(footer_post_title)
停留多长时间,我都需要将第二个容器留在主容器(blog_image_footer)
的底部。 How can I achieve this? 我该如何实现?
<div class="col-md-6 more-articles-left">
<div class="more-articles previous">
<div class="blog_image_footer">
<div class="row artikkel-title-previous" style="height:100%; background: linear-gradient(24deg, rgba(167, 85, 194, 0.9), rgba(219, 197, 218, 0.9)), url('/files/blog_pictures/o-KID-EATING-facebook.jpg') no-repeat center center /cover">
<div class="container footer_post_title">
<div class="col-md-12">
<h1 class="blog_post_title_footer">How to teach Your kids to eat healthy</h1>
</div>
</div>
<div class="container footer_post_buttons">
<p class="blog_post_year_footer">December 2016</p>
<a href="article.php?article_title=how-to-teach-your-kids-to-eat-healthy" class="btn btn-default btn-footer-read-more" name="read-more-article">Read now!</a>
</div>
</div>
</div>
</div>
</div>
You can set position: relative
to the container and position: absolute
to its child so you will be able to position your child element taking as reference your parent element. 您可以设置
position: relative
对于容器的position: absolute
以及position: relative
于其子容器的position: absolute
,以便您能够将父元素作为参考来放置子元素。
After that, you can set bottom: 0
to the child so the child will be fixed at the bottom of its container. 之后,您可以将child设置为
bottom: 0
,以便将child固定在其容器的底部。
.blog_image_footer{
position: relative;
}
.footer_post_buttons{
position: absolute;
bottom: 0;
}
You can use this basic principle: 您可以使用以下基本原理:
*{ box-sizing: border-box; } body, html{ height: 100%; width: 100%; margin: 0; } body{ display:flex; flex-direction: column; } #container { margin: 0 auto; width:100%; background-color: white; border: 0.2em solid black; flex-shrink:0; flex-grow:1; display:flex; } #footer,#header { margin: 0 auto; width:100%; text-align: center; height:1.5em; background-color: white; border: 0.2em solid black; flex-shrink:0; }
<div id="header"> header here </div> <div id="container"> this is container </div> <div id="footer"> footer here </div>
Try using bootstraps grid system: http://www.w3schools.com/bootstrap/bootstrap_grid_system.asp 尝试使用Bootstraps网格系统: http : //www.w3schools.com/bootstrap/bootstrap_grid_system.asp
This should allow you to make the h1 container responsive. 这应该使您可以使h1容器响应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.