怎么样在HTML里设置照片背景,而其它标签不会受影响?
<div style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">
<h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">第1</span>种引入<span style="color: black;">照片</span>的方式</h2>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在web前端的html+css的<span style="color: black;">周期</span>,添加<span style="color: black;">照片</span>,有两种方式,一种是<span style="color: black;">经过</span><img src=""/>标签来添加<span style="color: black;">照片</span>。img标签中有一个src属性,<span style="color: black;">经过</span>这个属性<span style="color: black;">能够</span>将<span style="color: black;">必须</span>的<span style="color: black;">照片</span>引入到html文档中,src的属性值为<span style="color: black;">照片</span>的路径。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://picx.zhimg.com/80/v2-3646f5a459bd10d4a9b805e7120c783b_720w.jpg?source=2c26e567" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">然则</span>这种方式会占据文档流,<span style="color: black;">由于</span>img是行内元素,他默认的宽高是和<span style="color: black;">照片</span>的宽高<span style="color: black;">同样</span>的。img标签后面的元素会紧挨着img<span style="color: black;">摆列</span>。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="data:image/svg+xml;utf8," style="width: 50%; margin-bottom: 20px;"></div>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="data:image/svg+xml;utf8," style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">h1中的文字在<span style="color: black;">照片</span>的下方紧挨着<span style="color: black;">照片</span><span style="color: black;">摆列</span>。</p>
<h2 style="color: black; text-align: left; margin-bottom: 10px;">第二种引入<span style="color: black;">照片</span>的方式</h2>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">另一种<span style="color: black;">便是</span><span style="color: black;">经过</span>背景<span style="color: black;">照片</span>的方式引入,这种方式<span style="color: black;">重点</span>是用在css的样式中。<span style="color: black;">经过</span>bac<span style="color: black;">公斤</span>round属性中的url引入。例如在div中添加一张背景图;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">html代码</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><</span><span style="color: black;">body</span><span style="color: black;">></span>
<span style="color: black;"><</span><span style="color: black;">div</span> <span style="color: black;">class</span><span style="color: black;">=</span><span style="color: black;">"box"</span><span style="color: black;">></span>这是一张<span style="color: black;">照片</span><span style="color: black;"></</span><span style="color: black;">div</span><span style="color: black;">></span>
<span style="color: black;"></</span><span style="color: black;">body</span><span style="color: black;">></span>
</div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">css代码</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><</span><span style="color: black;">style</span><span style="color: black;">></span>
<span style="color: black;">.</span><span style="color: black;">box</span> <span style="color: black;">{</span>
<span style="color: black;">height</span><span style="color: black;">:</span> <span style="color: black;">300</span><span style="color: black;">px</span><span style="color: black;">;</span>
<span style="color: black;">bac<span style="color: black;">公斤</span>round</span><span style="color: black;">:</span> <span style="color: black;">url</span><span style="color: black;">(</span><span style="color: black;">images/h.jpg</span><span style="color: black;">)</span> <span style="color: black;">no-repeat</span><span style="color: black;">;</span>
</div>
</span></div>
楼主节操掉了,还不快捡起来! 同意、说得对、没错、我也是这么想的等。 谷歌外贸网站优化技术。 太棒了、厉害、为你打call、点赞、非常精彩等。 你的见解独到,让我受益匪浅,非常感谢。
页:
[1]