box2在box1中的位置怎么設置
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>相對參照元素進行定位</title>
<style type="text/css">
div{border:2px red solid;}
#box1{
? ? width:200px;
? ? height:100px;
? ? position:relative;
? ? ? ? ??
}
#box2{
? position:absolute;
bottom:0;
? ? text-align:right; ? ? ?
}
/*下面是任務部分*/
#box3{
? ? width:200px;
? ? height:200px;
? ? position:relative; ? ? ??
}
#box4{
? ? width:99%;
? position:absolute;
top:0;
? ??
}
</style>
</head>
<body>
<div id="box1">
<div id="box2">相對參照元素進行定位</div>
</div>
<h1>下面是任務部分</h1>
<div id="box3">
? ? <img src="http://img1.sycdn.imooc.com//541a7d8a00018cf102000200.jpg">
? ? <div id="box4">當我還是三年級的學生時是一個害羞的小女生。</div>
</div>
</body>
</html>
2017-01-09
如圖,我用的text-align:center;,但是沒反應,不用left,right,怎么能使它居中或者在其他位置