IE6/7 不支持H5标签可以通过以下方法解决
可以通过JS创建标签实现(默认是行级标签),然后转换成块级元素。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> header{ width: 500px; height: 500px; display: block; background: red; } section{ width: 300px; height: 300px; display: block; background: blue; } footer{ width: 100px; height: 100px; display: block; background: yellow; } </style> <script type="text/javascript"> document.createElement('header'); document.createElement('section'); document.createElement('footer'); </script> </head> <body> <header>header</header> <section>section</section> <footer>footer</footer> </body> </html>
标签很多的时候,不可能一一创建元素,可以通过JS插件实现
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> header{ width: 500px; height: 500px; display: block; background: red; } section{ width: 300px; height: 300px; display: block; background: blue; } footer{ width: 100px; height: 100px; display: block; background: yellow; } </style> <script type="text/javascript" src="js/html5shiv.js"></script> </head> <body> <header>header</header> <section>section</section> <footer>footer</footer> </body> </html>