如何将像素定位到右侧

时间:2014-10-24 17:25:57

标签: css

请看下面的小提琴:

http://jsfiddle.net/hqn4gLk6/

<div style="display:inline-block;margin-right:5px">
        <button type=button id="fdfdd"  class="btn btn-small" style="width:150px;">sadfasfdsfdfd</button>
    </div>

我希望按钮位于页面右侧5像素处。

我尝试使用margin-right女巫不起作用。

3 个答案:

答案 0 :(得分:0)

您可以定位元素absolute然后使用css right,如:

<div style="display:inline-block; position:absolute; right:5px;">
    <button type=button id="fdfdd"  class="btn btn-small" style="width:150px;">sadfasfdsfdfd</button>
</div>

另请查看您的jsfiddle

答案 1 :(得分:0)

固定

<div style="margin-left:@marginDate;">
    <h2 style="display:inline-block;">454544555 </h2><p style="margin-left:10px;display:inline-block"> sadfasfsafsdf</p>



      /*added float:right; to the style only and some margin */

<div style="display:inline-block;margin-right:5px; float:right;">

/* done working */

                <button type=button id="schema"  class="btn btn-small" style="width:150px;">sadfasfdsfdfd</button>
            </div>

    </div>

答案 2 :(得分:0)

我用花车来得到你要求的东西。如果您想要查看它,我已更新了您的js.fiddle here

<div style="clear:both">
    <div style="float:left;">
        <h2 style="display:inline-block;">454544555 </h2>
        <p style="margin-left:10px;display:inline-block"> sadfasfsafsdf</p>
    </div>
    <div style="float:right; margin-right:5px">
           <button type=button id="schema"  class="btn btn-small" style="width:150px;">sadfasfdsfdfd</button>
        </div>
    </div>
</div>