|
margin-left: auto; margin-right: auto margin: auto margin: 上下マージン auto margin: 上マージン auto 下マージン *上下マージン、上マージン、下マージンに付いては任意の値 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <META http-equiv="Content-Style-Type" content="text/css"> <TITLE>CSS覚書</TITLE> <STYLE type="text/css"> <!-- body { color: #ff6600; background: #ffffff } h2,p { margin-left: auto; margin-right: auto; padding: 20px; width: 150px; } table { margin: auto } h2,p ,table { color: #ffffff; background: #ff6600 } h1 { text-align: center; color: #ff6600 } --> </STYLE> </herd></HEAD> <body> <h1>センタリングする</h1> <center> <H2 align="left">これはh2要素です</H2> <P align="left">これはp要素です</P> <DIV> <table border="3" cellpadding="6"> <tr> <th>ヘッダ</th> <th>ヘッダ</th> <th>ヘッダ</th> </tr> <tr> <td>データ</td> <td>データ</td> <td>データ</td> </tr> </table> </DIV> </center> </body> </html> |