将div容器放在右侧 [英] Position a div container on the right side

查看:90
本文介绍了将div容器放在右侧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发某种实用工具栏.我可以使用float:left;

I want to develop some kind of utility bar. I can position each element in this bar side by side using float:left;

但是我希望第二个元素位于条形的最右边.这对我来说很难,因为条形的宽度不是固定的.

But I want the second element to be positioned at the very right of the bar. This is hard for me because the width of the bar is not static.

看一下我的演示: http://jsfiddle.net/x5vyC/2/

它应该看起来像这样:

任何想法如何使用CSS来实现吗?

Any idea how to achieve this using css?

推荐答案

这是您想要的吗? - http://jsfiddle.net/jomanlk/x5vyC/3/

Is this what you wanted? - http://jsfiddle.net/jomanlk/x5vyC/3/

现在两边都漂浮了

#wrapper{
    background:red;
    overflow:auto;
}

#c1{
   float:left;
   background:blue;
}

#c2{
    background:green;
    float:right;
}​

<div id="wrapper">
    <div id="c1">con1</div>
    <div id="c2">con2</div>
</div>​

这篇关于将div容器放在右侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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