div内居中图片小组件
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div style="width:300px;height:200px;position:relative;display: table;text-align: center;background-color:#ccc;"> <img src="img/fp_06.png" alt="" style="position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;max-width:100%;max-height: 100%;width:auto;height:auto;"> </div> </body> </html>
效果如图:或者: