把iframe嵌套的网页放在某一位置,只需在iframe外加个框,改变框的位置即可,如:
<!doctype html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title></title> </head> <body> <div class="main"> <iframe src="http://www.bootcss.com/" onload="changeFrameHeight()" id="myiframe" scrolling="yes" frameborder="0"></iframe> </div> </body>
css如下:
<style type="text/css"> *{ padding: 0; margin: 0;} body{background: green} .main{ width: 80%; height: 500px; margin: 0 auto;} .main iframe{ display: block; width:100%; height: 100%;} </style>
效果如图: