简体   繁体   English

HTML/CSS 用图像为段落添加边距

[英]HTML/CSS Margin a paragraph with image

I want to add some margin/padding but keep the paragraph nice/clean and responsive.我想添加一些边距/填充,但要保持段落漂亮/干净且响应迅速。

I tried adding margin: 10px but it only applies to the first line我尝试添加margin: 10px但它仅适用于第一行

在此处输入图片说明

Is there a way to tune up the code above to have some padding/margin without compromising responsiveness.有没有办法在不影响响应能力的情况下调整上面的代码以获得一些填充/边距。

Please be advised that I cannot use any JQUERY/Javascript in the code above due to clients odd restrictions.请注意,由于客户的奇怪限制,我不能在上面的代码中使用任何 JQUERY/Javascript。

 <table> <tbody> <tr> <td> <div style="width:100%;height:auto;"> <div> <img src="https://i.imgur.com/ieffVLU.png" width="360px" style="float:left;border: 1px solid black"> </div> <div> <h5 style="text-align: justify;"> <span style="font-weight: normal;"> a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something </span> </h5> </div> </div> </td> </tr> </tbody> </table>

you can add "display: block" to your image tag and the output would be like:您可以将“显示:块”添加到您的图像标签,输出将如下所示:

 <table> <tbody> <tr> <td> <div style="width:100%;height:auto;"> <div> <img src="https://i.imgur.com/ieffVLU.png" width="360px" style="float:left;border: 1px solid black; display:block"> </div> <div> <h5 style="text-align: justify;"> <span style="font-weight: normal;"> a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something a nice paragraph about something </span> </h5> </div> </div> </td> </tr> </tbody> </table>

Try to change first div's width from 100% to 360px.尝试将第一个 div 的宽度从 100% 更改为 360px。 Also, remove the extra div that came inside the first div.此外,删除第一个 div 中的额外 div。 And if this not works, then insert span of second div to first div after the img.如果这不起作用,则在 img 之后将第二个 div 的跨度插入到第一个 div。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM