如何在 HTML 中向右移动文本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17226551/
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 10:19:00  来源:igfitidea点击:

How to move text to the Right in HTML?

htmlcssimage

提问by user2426533

I know that by adding style="right: 100px;"to an image, it can move an image slightly to the right. How can I do this with text, I want to move the text 100px to the right. I'd rather not use CSS but if I have to that's fine.

我知道通过添加style="right: 100px;"到图像,它可以将图像稍微向右移动。我该如何处理文本,我想将文本向右移动 100 像素。我宁愿不使用 CSS,但如果必须这样做也没关系。

回答by kevinandrada

This is another approach for people (like me) not into the positionCSS property:

这是人们(像我一样)没有进入positionCSS 属性的另一种方法:

#my-text {
    float: right;
    margin-right: 100px;
}

/* or an inline style */
style="float: right; margin-right: 100px;"

回答by Doorknob

Use a relative position:

使用相对位置:

#yourText {
    position: relative;
    left: -100px;
}

This will position it relativeof where it used to be.

这将对于它以前所在的位置定位它。

回答by Jerska

You want to manage the style of your page content. So you have to use CSS.

您想管理页面内容的样式。所以你必须使用CSS。

Doorknob answers is perfectly good (and is probably the right one), but you could also set a negative margin (Note that its positionattribute will remain static)

Doorknob 答案非常好(并且可能是正确的),但您也可以设置负边距(请注意,它的position属性将保持不变static

#yourText {
    margin-left: -100px;
}

or

或者

style="margin-left: -100px;"