小编Kar*_*zek的帖子

使用绝对定位调整<img />的大小

div#ipsko更改宽度和高度以满足绝对定位。为什么img#utas没有?

JSFiddle:http : //jsfiddle.net/pejh7/1/

HTML代码:

<div id="upsko">
    <img id="utas" src="http://kharg.czystybeton.pl/108.png" />
    <div id="ipsko"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS代码:

div#upsko {
    position: relative;
    top: 200px; left: 200px; width: 100px; height: 100px;
    background: rgba(255,0,0,0.5);
}

img#utas {
    position: absolute;
    top: 10px; left: 10px; right: 10px; bottom: 10px;
}

div#ipsko {
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: rgba(0,255,0,0.5);
}
Run Code Online (Sandbox Code Playgroud)

css image css-position image-resizing

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

css ×1

css-position ×1

image ×1

image-resizing ×1