Html 如何将div环绕在图像上?
我试图将图像包装到一个div中,但该div被父div扩展Html 如何将div环绕在图像上?,html,css,word-wrap,Html,Css,Word Wrap,我试图将图像包装到一个div中,但该div被父div扩展 <div id="parent" style="display: inline-block; position: relative; text-align:center"> <div id="wrapper"> <img> </div> <p>Some text that expands the wrapper div more than
<div id="parent" style="display: inline-block; position: relative; text-align:center">
<div id="wrapper">
<img>
</div>
<p>Some text that expands the wrapper div more than image width</p>
</div>
某些文本扩展包装器div超过图像宽度
文本字段将父div扩展为比图像宽,这也将扩展包装div。如何使包装div与img的大小完全相同
img和包装都没有边距或填充,但包装div比图像宽。在#包装器上使用
display:inline block
在包装器上使用
显示:内联块
在包装器上使用显示:内联块
在包装器上使用显示:内联块
您需要在wraper元素上设置显示:内联块
<div id="parent" style="display: inline-block; position: relative; text-align:center">
<div id="wrapper" style="display: inline-block;">
<img src="https://cdn2.iconfinder.com/data/icons/picol-vector/32/source_code-128.png" />
</div>
<p>Some text that expands the wrapper div more than image width</p>
</div>
您需要在wraper元素上设置显示:内联块
<div id="parent" style="display: inline-block; position: relative; text-align:center">
<div id="wrapper" style="display: inline-block;">
<img src="https://cdn2.iconfinder.com/data/icons/picol-vector/32/source_code-128.png" />
</div>
<p>Some text that expands the wrapper div more than image width</p>
</div>
您需要在wraper元素上设置显示:内联块
<div id="parent" style="display: inline-block; position: relative; text-align:center">
<div id="wrapper" style="display: inline-block;">
<img src="https://cdn2.iconfinder.com/data/icons/picol-vector/32/source_code-128.png" />
</div>
<p>Some text that expands the wrapper div more than image width</p>
</div>
您需要在wraper元素上设置显示:内联块
<div id="parent" style="display: inline-block; position: relative; text-align:center">
<div id="wrapper" style="display: inline-block;">
<img src="https://cdn2.iconfinder.com/data/icons/picol-vector/32/source_code-128.png" />
</div>
<p>Some text that expands the wrapper div more than image width</p>
</div>
您还有其他css吗?div
s是块元素,因此它们将占据其父元素的全部宽度。尝试将wrapper
设置为display:inline
或float:left
,具体取决于您希望它的显示方式。@Firze将display:inline块放在#wrapper上。您还有其他css吗?div
是块元素,因此它们将占据其父元素的全部宽度。尝试将wrapper
设置为display:inline
或float:left
,具体取决于您希望它的显示方式。@Firze将display:inline块放在#wrapper上。您还有其他css吗?div
是块元素,因此它们将占据其父元素的全部宽度。尝试将wrapper
设置为display:inline
或float:left
,具体取决于您希望它的显示方式。@Firze将display:inline块放在#wrapper上。您还有其他css吗?div
是块元素,因此它们将占据其父元素的全部宽度。尝试将wrapper
设置为display:inline
或float:left
,具体取决于您希望它的显示方式。@Firze将display:inline块放在#wrapper.Oh上。我很确定我已经试过了,但显然我没有。谢谢我现在觉得自己很笨。@Firze我喜欢给元素添加边框,这样我就能准确地看到发生了什么。希望你能试试我的方法。:)如果display:inline块
不起作用,请尝试使用display:inline
。哦。我很确定我已经试过了,但显然我没有。谢谢我现在觉得自己很笨。@Firze我喜欢给元素添加边框,这样我就能准确地看到发生了什么。希望你能试试我的方法。:)如果display:inline块
不起作用,请尝试使用display:inline
。哦。我很确定我已经试过了,但显然我没有。谢谢我现在觉得自己很笨。@Firze我喜欢给元素添加边框,这样我就能准确地看到发生了什么。希望你能试试我的方法。:)如果display:inline块
不起作用,请尝试使用display:inline
。哦。我很确定我已经试过了,但显然我没有。谢谢我现在觉得自己很笨。@Firze我喜欢给元素添加边框,这样我就能准确地看到发生了什么。希望你能试试我的方法。:)如果display:inline块
不起作用,请尝试使用display:inline
。