2013-08-02 141 views
6

如何让按钮浮动只在div区域?div内的左/右浮动按钮

这里是我的榜样CSS和HTML ..

HTML

<div class='test'> 
    <div style='float: left;'> 
    <button>test</button> 
    </div> 
    <div style='float: right;'> 
    <button>test</button> 
    </div> 
</div> 

CSS

.test { 
    width:60%; 
    display:inline; 
    overflow: auto; 
    white-space: nowrap; 
    margin:0px auto; 
} 

,或者你可以在这里看到现场样品 - >http://jsfiddle.net/ELAVS/

我想它像这样..

enter image description here

回答

12

更改显示:内联到显示:内联块

.test { 
    width:200px; 
    display:inline-block; 
    overflow: auto; 
    white-space: nowrap; 
    margin:0px auto; 
    border:1px red solid; 
} 
+0

感谢,它的工作:d随时 –

+0

YW:d –