css - Logo 向左浮动,内容向右浮动

标签 css html css-float

我有以下 HTMLCSS, Logo float 在左侧,但我希望内容 float 在右侧.

<html>
  <body>
    <div id="logo">
      <img src="images/logo.gif" height="376" width="198" alt="LOGO" title="" />
    </div>
    <div id="maintext">
      <p id="main">First paragraph</p>
      <p>Second paragraph.</p>
    </div>
    <footer>...</footer>
  </body>
</html>

在我的 CSS 中,logo 的选择器是:

#logo {
  display: block;
  float: left;
}

#maintext {
  padding: 0 0.5em 0 0.5em;
}

发生的事情是 Logo “images/logo.gif”出现在页脚的左侧但在页脚的顶部。它应该显示在“maintext”选择器的左侧。

有什么想法吗?

最佳答案

添加此 CSS:

footer {
    clear: both;
}

关于css - Logo 向左浮动,内容向右浮动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19215104/

相关文章:

html - 圆形翻转时背面文字消失

html - 为什么图片不放在html页面的最左上角?

html - float div 中的列表

html - 修改浏览器变小时的 CSS float 行为

python - 样式表在 Django 中不起作用

javascript - 检测滚动到页面底部事件并采取行动

html - 隐藏的输入弄乱了我的填充

php - 使用一条 'isset' 语句处理不同的 PHP 提交

html - 为什么我的标题和导航在具有相同 CSS 的不同页面上表现不同

css - IE7中的 float div问题