欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

css想让块靠右该如何实现

程序员文章站 2022-04-04 22:38:03
...

css想让块靠右的实现方法:可以通过float属性来实现,如【float:right;】,表示元素向右浮动。float属性用于定义元素在哪个方向浮动,left表示元素向左浮动,right表示元素向右浮动。

css想让块靠右该如何实现

本文环境:

  • windows10、css3

  • 本文适用于所有品牌的电脑

相关元素:

float 属性定义元素在哪个方向浮动。以往这个属性总应用于图像,使文本围绕在图像周围,不过在 CSS 中,任何元素都可以浮动。浮动元素会生成一个块级框,而不论它本身是何种元素。

(学习视频分享:css视频教程

属性值:

  • left 元素向左浮动。

  • right 元素向右浮动。

  • none 默认值。元素不浮动,并会显示在其在文本中出现的位置。

  • inherit 规定应该从父元素继承 float 属性的值。

代码实现:

<html>
<head>
<style type="text/css">
img 
{
float:right
}
</style>
</head>

<body>
<p>在下面的段落中,我们添加了一个样式为 <b>float:right</b> 的图像。结果是这个图像会浮动到段落的右侧。</p>
<p>
<img src="/i/eg_cute.gif" />
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.
</p>
</body>

</html>

实现效果:

css想让块靠右该如何实现

相关推荐:CSS教程

以上就是css想让块靠右该如何实现的详细内容,更多请关注其它相关文章!

相关标签: css