CSS - Keep text under an image

家住魔仙堡 提交于 2019-12-02 09:13:19

you need to clear any floats. So after the floated elements you can add this class to your footer and to your the parent of your floated divs, #txt1, .clearfix:after:

.clearfix:after {
   clear: both;
   content: ".";
   display: block;
   height: 0;
   visibility: hidden;
}

or you can just add a div with clear:both above your include of footer.php:

<div style="clear:both;"></div>

<?php
include('includes/footer.php');
?>
George

Floating an element takes it out of the 'flow' of the page. Your footer shoots up because it is taking no notice of floated elements. This is where clear comes in, it specifies whether the element can be next to (or in line with) floated elements. Add clear:both to your footer, and you should get the result you wanted:

#footer {
  border-top: 1px solid;
  margin-left: auto;
  margin-right: auto;
  width: 700px;
  padding-top: 10px;
  padding-bottom: 10px;
  text-align: center;
  white-space: nowrap;
  clear:both;
}

JSFiddle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!