display的几种参数
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> div{ background-color: aqua; } span{ background-color: crimson; } h1{ background-color: yellow; } </style> <title>display</title> </head> <body> <div>div是block的</div> <div>div是block的</div> <span>span是inline的</span> <span>span是inline的</span> <h1>h1也是block的</h1> <h1>h1也是block的</h1> </body> </html>效果如下:
div{ background-color: aqua; display: inline; } span{ background-color: crimson; display: block; } h1{ background-color: yellow; display:inline; }那么得到的效果是这样的:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> span{ display:inline-block; background-color: yellow; width: 200px; } </style> <title>inline-bock</title> </head> <body> <span>span是inline的1</span> <span>span是inline的2</span> <span>span是inline的3</span> <span>span是inline的4</span> </body> </html>效果如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>inline-table</title> <style> span{ background-color: aquamarine; } table{ background-color: crimson; } </style> </head> <body> <span>header</span> <table> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> </table> <span>footer</span> </body> </html>效果如下:
table{ display: inline-table; background-color: crimson; }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>list-item</title> <style> div{ display: list-item; list-style-type: circle; margin-left: 30px; background-color: aqua; width: 300px; margin-bottom: 10px; padding: 5px; } </style> </head> <body> <div>item1</div> <div>item2</div> <div>item3</div> <div>item4</div> <div>item5</div> </body> </html>效果:
1 display: list-item; 2 list-style-type: circle; 3 margin-left: 30px;第1行和第2行必须同时出现,缺一个都不会有圆圈的效果