如何在 HTML 中将文本和图像并排放置? [英] How to place Text and an Image next to each other in HTML?

查看:16
本文介绍了如何在 HTML 中将文本和图像并排放置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望文本和图像彼此相邻,但我希望图像位于屏幕的最左侧,而我希望文本位于屏幕的最右侧.这就是我目前拥有的......

I want the text and the image to be next to each other but I want the image to be on the far left of the screen and I want the text to be on the far right of the screen. This is what I currently have....

<body>
<img src="website_art.png" height= "75" width= "235"/>
<h3><font face="Verdana">The Art of Gaming</font></h3>
</body>

我该怎么做?

谢谢

推荐答案

img {
    float:left;
}
h3 {
    float:right;
}

jsFiddle 示例

请注意,您可能希望在您提供的代码之后的任何元素上使用 clear:both 样式,以免它直接向上滑动到浮动元素下方.

Note that you will probably want to use the style clear:both on whatever elements comes after the code you provided so that it doesn't slide up directly beneath the floated elements.

这篇关于如何在 HTML 中将文本和图像并排放置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆