让不固定个数的子元素自适应居中
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style type="text/css"> ul { background:#f7f7f7; text-align:center; list-style:none; font-size:0; margin:10px;}<!--font-size是为了去掉FF下面的右间距--> li { display:inline-block; padding:10px; background: #666; color:#fff; margin-right:5px;*display:inline;*zoom:1; font-size:11px;} </style> </head> <body> <div> <ul> <li>test1</li> </ul> <ul> <li>test1</li> <li>test2</li> </ul> <ul> <li>test1</li> <li>test2</li> <li>test3</li> </ul> <ul> <li>test1</li> <li>test2</li> <li>test3</li> <li>test4</li> </ul> </div> </body> </html>