更新時(shí)間:2020-08-13 來(lái)源:黑馬程序員 瀏覽量:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style tpye="text/css"> body{ background:#000 } div{ width: 900px; height: 800px; background:deeppink; display: flex; align-items: center; } div img{ width: 579px; height: 282px; align-items: center; } </style> </head> <body> <div> <img src="html.png" alt=""> </div> </body> </html>
看下效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style tpye="text/css"> body{ background: #bbb; } div{ display: table; width: 900px; height: 700px; background: #f3f3f3; display: table-cell; vertical-align: middle; } div img{ width: 282px; } </style> </head> <body> <div> <img src="html.png" alt=""> </div> </body> </html>
猜你喜歡: