我目前正在学校学习HTML,而且我有点想要在div中定位图像。继承人我的HTML代码:
.bild1 {
position:relative;
top:500 px;
max-width:50%;
max-height:50%;
}

<div class="bild1">
<img src="http://cms.immoscout24.ch/media/1341/umzug-ostern.jpg">
</div>
&#13;
有谁知道如何定位相对的图片(它需要是相对的)
答案 0 :(得分:0)
.bild1{width:200px;height:200px;}
.bild1 img{max-width:100%;}
&#13;
<div class="bild1">
<img src="http://cms.immoscout24.ch/media/1341/umzug-ostern.jpg">
</div>
&#13;
答案 1 :(得分:0)
获取位置:对图像进行相对处理,然后将其传递给图像。
这将仅在类bild1
上绑定css.bild1 {
这将绑定类bild1
中img元素的css
.bild1 img {
position:relative;
top:500 px;
max-width:50%;
max-height:50%;
}
&#13;
<div class="bild1">
<img src="http://cms.immoscout24.ch/media/1341/umzug-ostern.jpg">
</div>
&#13;
答案 2 :(得分:0)
您的top: 500 px;
在500
和px
之间有空格,因此它不接受它。将其更改为top: 500px;
.bild1 {
position:relative;
top: 500px;
max-width:50%;
max-height:50%;
}
&#13;
<div class="bild1">
<img src="http://cms.immoscout24.ch/media/1341/umzug-ostern.jpg">
</div>
&#13;
如果您希望图片接收这些属性,请在img
之后添加.bild1
,如此.bild1 img { ...
.bild1 img {
position:relative;
top: 500px;
max-width:50%;
max-height:50%;
}
&#13;
<div class="bild1">
<img src="http://cms.immoscout24.ch/media/1341/umzug-ostern.jpg">
</div>
&#13;
希望有所帮助