对齐2划分 [英] Align 2 Divs side by side

查看:138
本文介绍了对齐2划分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从来没有一个问题,对齐divs并排,但由于某种原因,不管我做什么,只是不工作。我试过从stackoverflow几个答案,但他们没有工作。我已经用完了想法。



我有两个div。 1 div是content - 它有一个表中显示的所有主要信息。第二个div是sidebar - 它只有一些额外的垃圾图像,twitter feed等。



这是我的CSS

  #content {
width:580px;
height:auto;
}

#sidebar {
width:270px;
height:auto;
float:right;

}



播放定位,边距,包含那些2个div在另一个 - 包装 - 一个但它不工作或创建另一个问题。有趣的是,我重写了我的旧网站,即使我复制旧的属性,它仍然不工作。任何人都有任何想法?



每个人都允许洗劫! LOL



解决方案:
删除div #clear,我完全忘记了!什么是muppet。 :-P现在我感觉很蠢。 :-P

解决方案

  #content {background:#eee; width:300px; height:auto; float:left;} #sidebar {background:#c00; width:200px; height:auto; float:left;}  

 < div id = >内容< / div>< div id =sidebar>侧栏< / div>  

b $ b

I've never had a problem with aligning divs side by side but for some reason no matter what I do it just doesn't work. I tried a few answers from stackoverflow but they didn't work either. I've run out of ideas.

What I have are 2 divs. 1 div is "content" - it has all main info displayed in a table. Second div is "sidebar" - it has just some extra rubbish like images, twitter feed etc.

This is my CSS

#content {
width: 580px;
height:auto;
}     

#sidebar {
width: 270px;
height:auto;
float:right;

}

I've tried to play with positioning, margins, containing those 2 divs in another - wrapper - one but it either doesn't work or creates another problem. Funny enough I am re-writing my old website and even if I copy the old attributes it still doesn't work. Anyone has any idea?

EVERYONE IS ALLOWED TO LAUGHT! LOL

SOLUTION: Delete div #clear which I totally forgot about! What a muppet. :-P Now I feel stupid. :-P

解决方案

#content {
  background:#eee;
  width: 300px;
  height:auto;
  float: left;
}     

#sidebar {
  background:#c00;
  width: 200px;
  height:auto;
  float:left;
}

<div id="content">Content</div>
<div id="sidebar">Sidebar</div>

这篇关于对齐2划分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆