Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.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
Css 如何将P元素中的文本放在图像旁边?_Css_Html - Fatal编程技术网

Css 如何将P元素中的文本放在图像旁边?

Css 如何将P元素中的文本放在图像旁边?,css,html,Css,Html,这是我的密码: <img id="mepic" src="images/example.jpg" width="70px" height"60px"> <p>This is some example text that i want next to the image on the right hand side</p> 这是一些示例文本,我想放在右边的图像旁边 此时,文本位于图像下方。如何将文本放在图像旁边?无CSS和JavaScript,纯HTML

这是我的密码:

<img id="mepic" src="images/example.jpg"  width="70px" height"60px">
<p>This is some example text that i want next to the image on the right hand side</p>

这是一些示例文本,我想放在右边的图像旁边


此时,文本位于图像下方。如何将文本放在图像旁边?

无CSS和JavaScript,纯HTML

<p><img src="image.png" alt="image"/>&nbsp;Text beside image</p>
<div class="container">
    <div class="imgdiv">
        <img src="example.jpg" alt="img">
    </div>
    <div class="textdiv">
        <p> Image text here.</p>
        <p> Image text here.</p>
        <p> Image text here.</p>
        <p> Image text here.</p>
    </div>

如果要将文本放置在图像的右侧,以下代码将允许:

   <p><img src="example.jpg" alt="img"> Image text here.</p>

运行示例:

您可以在不更改
html
结构的情况下执行此操作

由于
img
inline
元素,您可以将下一个同级
p
设置为
inline

默认情况下,
p
是一个
元素,因此它占据了整个
宽度

更多关于

img+p{
显示:内联;
左边距:10px;
垂直对齐:顶部;/*以便p与img顶部对齐*/
}


这是一些示例文本,我想在右侧图像旁边作为旁注,因为您将其标记为HTML5,所以最好使用
标记此内容

例如:

<figure>
   <img id="mepic" src="images/example.jpg" alt="Text" />
   <figcaption>This is some example text that i want next to the image on the right hand side</figcaption>
</figure>

嘿,只是提醒用户:HTML5不支持对齐。
<figure>
   <img id="mepic" src="images/example.jpg" alt="Text" />
   <figcaption>This is some example text that i want next to the image on the right hand side</figcaption>
</figure>
figure {
   margin: 0;
   width: 600px;
   height: auto;
   overflow: hidden;
}
figure img {
   width: 30%;
   float: left;
}
figure figcaption {
   width: 70%;
   float: right;
}