核心提示:用到了css3的transition属性,其实是从左往右扩展的。因为设置了块居中,产生从中心向左右扩展的感觉!doctype htmlhtmlheadstyle#box{background-colo...
用到了css3的transition属性,其实是从左往右扩展的。因为设置了块居中,产生从中心向左右扩展的感觉
<!doctype html> <html> <head> <style> #box{ background-color:gray; height:20px; overflow:hidden; } .a{ background-color:red; width:0; height:20px; margin: 0 auto; transition:width .8s; -webkit-transition:width .8s; } #box:hover .a{ width:100%; transition:width .8s; -webkit-transition:width .8s; } </style> </head> <body> <p id="box"> <p class="a"></p> </p> </body> </html>