水平居中佈局
父元素text-align:center;子元素:inline-block;
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>水平居中布局</title> <style> *{ margin: 0; padding: 0; } .parent { width: 100%; background: green; text-align: center; } .child { display: inline-block; width: 800px; height: 100px; background: blue; } </style> </head> <body> <p class="parent"> <p class="child">1</p> <p class="child">2</p> <p class="child">3</p> <p class="child">4</p> <p class="child">5</p> <p class="child">6</p> </p> </body> </html>
以上是單列佈局水平居中佈局方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!