CSS relative属性之限魔大法实例页面

代码:

CSS代码:
.box { width:15em; height:10em; background-color:#beceeb; }
.box img { position:absolute; left:20px; top:20px; }
                
HTML代码:
<div id="target" class="box">
    <img src="//image.zhangxinxu.com/image/study/s/s128/mm3.jpg" />
</div>
<p><input type="button" id="button" value="点击图片父标签应用position:relative" /></p>
                
JS代码:
$("#button").click(function() {
    $("#target").css("position", "relative");	
});
                

效果:

分享到:0