CSS分类:将带有边框的图像浮动于段落的右侧
CSS 代码均位于 HTML 的 head 部分,这样做的目的是为了利于演示例子本身。在实际的开发中,使用 CSS 最好的方式是引用外部样式表。
这里介绍CSS分类:将带有边框的图像浮动于段落的右侧
步骤/方法
- 01
在编辑器中输入以下代码: <html> <head> <style type="text/css"> img { float:right; border:1px dotted black; margin:0px 0px 15px 20px; } </style> </head> <body> <p>在下面的段落中,图像会浮动到右侧,并且添加了点状的边框。我们还为图像添加了边距,这样就可以把文本推离图像:上和右外边距是 0px,下外边距是 15px,而图像左侧的外边距是 20px。</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>
- 02
运行结果为: