300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > html style设置靠右 css怎么设置右对齐

html style设置靠右 css怎么设置右对齐

时间:2024-06-03 03:08:47

相关推荐

html style设置靠右 css怎么设置右对齐

css设置右对齐的方法:1、通过使用cssposition属性来实现右对齐效果;2、通过float属性实现右对齐效果;3、通过text-align属性实现右对齐效果。

本文操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

通过css设置右对齐方法详解:

1、通过css的position属性实现右对齐

右对齐

以下实例演示了如何使用 position 来实现右对齐:

元素右对齐

css代码:

.right {

position: absolute;

right: 0px;

width: 300px;

border: 3px solid #73AD21;

padding: 10px;

}

效果图:

2、通过float属性实现右对齐

img

{

float:right

}

在下面的段落中,我们添加了一个样式为float:right的图像。结果是这个图像会浮动到段落的右侧。

This is some text. This is some text. This is some text.

This is some text. This is some text. This is some text.

This is some text. This is some text. This is some text.

This is some text. This is some text. This is some text.

This is some text. This is some text. This is some text.

This is some text. This is some text. This is some text.

This is some text. This is some text. This is some text.

This is some text. This is some text. This is some text.

This is some text. This is some text. This is some text.

This is some text. This is some text. This is some text.

效果图:

3、通过text-align属性实现右对齐

h1 {text-align: center}

h2 {text-align: left}

h3 {text-align: right}

这是标题 1

这是标题 2

这是标题 3

效果图:

【推荐学习:css视频教程】

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。