Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在HTML中将文本和图像相邻放置?_Html_Css_Image_Text - Fatal编程技术网

如何在HTML中将文本和图像相邻放置?

如何在HTML中将文本和图像相邻放置?,html,css,image,text,Html,Css,Image,Text,我希望文本和图像彼此相邻,但我希望图像位于屏幕的最左侧,我希望文本位于屏幕的最右侧。这就是我现在拥有的 <body> <img src="website_art.png" height= "75" width= "235"/> <h3><font face="Verdana">The Art of Gaming</font></h3> </body> 游戏艺术 我该怎么做 谢谢 请注意,您可能希望在您提供

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

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

游戏艺术
我该怎么做

谢谢

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

如果要使用此样式,可以直接将其放入代码中

<body>
<img src="website_art.png" height= "75" width="235" style="float:left;"/>
<h3 style="float:right;">The Art of Gaming</h3>
</body>

可以使用垂直对齐和浮动

在大多数情况下,您希望垂直对齐:中间,图像

下面是一个测试:

垂直对齐:基线|长度|子|超级|顶部|文本顶部|中间|底部|文本底部|初始|继承

中,定义是:元素放置在父元素的中间。


因此,您可能希望将其应用于元素中的所有元素。

CSS:
float:left
float:right
?自HTML5起,
标记已被删除。请将其删除并替换为等效的CSS;)您可以使用css将它们放置在div中,并使用适当的float:right或left将它们放在各自的边上。div width可以设置为允许您按照自己的意愿选择“最左边”和“最右边”。唯一的问题是父div的大小会变大,如果您使用的是背景色,这是个问题,etc@User“父div的大小”是什么意思?我认为
垂直对齐
浮动
不能一起工作。
<body>
<img src="website_art.png" height= "75" width="235" style="float:left;"/>
<h3 style="float:right;">The Art of Gaming</h3>
</body>
<body>
  <img src="website_art.png" class="myImage"/>
  <h3 class="heading">The Art of Gaming</h3>
</body>
.myImage {
  float: left;
  height: 75px;
  width: 235px;
  font-family: Veranda;
}
.heading {
  float:right;
}