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"/> 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;
}