親要素にwidthを指定してmargin:0 autoで中央寄せにした後、
子要素にposition:fixed、left:autoを指定するだけです。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
■html <body> <div id="box"> <p id="inner">テキスト</p> </div> </body> ■css #box{ width:300px; height:250px; margin:0 auto; padding:0; } #inner{ width:20px; height:50px; position:fixed; left:auto; top:0; margin:0 0 0 900px; padding:0; } |
コメント