【发布时间】:2016-09-11 19:04:05
【问题描述】:
我已经提到了这个question,但它对我有帮助。我正在尝试更改图像标签内的跨度标签 height and width 但它不起作用,这是我的代码:
html
<img class="profile_pic" alt="Sumanth Jois" src="file/someimage">
<span class="changePicture">HelloThere</span>
</img>
CSS
//There are many spans so I am using the . operator to specify
span.changePicture{
width: 100px;
height:200px;
background-color:red;
margin-left: -150px;
color: white;
margin-top: -20px;
}
我无法使用此代码更改宽度和高度。我可以知道如何解决这个问题吗?
谢谢你
【问题讨论】:
-
</img>?一定是这样<img class="profile_pic" alt="Sumanth Jois" src="file/someimage" />里面不能加html -
浏览器不会将
span嵌套在img中,因为img不能是父级。浏览器会将其置于img下方,并忽略/删除</img>