CSS 想要将特定的 div 向右移动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12710843/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 20:22:14  来源:igfitidea点击:

Want to move a particular div to right

css

提问by Bala

I want to move a particular div more to the right side so that the div in the left gets some more space to display the contents in it.

我想将特定的 div 移动到右侧,以便左侧的 div 获得更多空间来显示其中的内容。

I tried few things in CSS, but I know I am doing something wrong.

我在 CSS 中尝试了一些东西,但我知道我做错了什么。

In CSS, I have...

在 CSS 中,我有...

login-box {
    width: 200px;
    margin-left: 50px;
} 

回答by dsgriffin

You can use float on that particular div, e.g.

您可以在该特定 div 上使用浮动,例如

<div style="float:right;">

Float the div you want more space to have to the left as well:

将您想要更多空间的 div 浮动到左侧:

<div style="float:left;">

If all else fails give the div on the right position:absolute and then move it as right as you want it to be.

如果所有其他方法都失败了,请将 div 放在正确的位置:绝对,然后根据需要将其移动到正确的位置。

<div style="position:absolute; left:-500px; top:30px;"> 

etc. Obviously put the style in a seperate stylesheet but this is just a quicker example.

等。显然将样式放在单独的样式表中,但这只是一个更快的示例。

回答by Roberto Sepúlveda Bravo

This will do the job:

这将完成这项工作:

<div style="position:absolute; right:0;">Hello world</div>