解决mindmaster分享嵌入网页居中问题,使iframe居中代码,实现思维导图嵌入网页居中。
1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 <head> 3 <meta http-equiv="Content-Type" content="textml; charset=utf-8" /> 4 <title>无标题文档</title> 5 <style type="text/css"> 6 .box{ position:absolute;} 7 </style> 8 <script> 9 window.onload=function() 10 { 11 var oBox=document.getElementById(‘box‘); 12 adjustResize(); 13 window.onresize=window.onscroll=adjustResize; 14 function adjustResize() 15 { 16 var iWidth=document.documentElement.clientWidth; 17 var iHegiht=Math.max(document.documentElement.clientHeight,document.body.clientHeight); 18 oBox.style.left=(iWidth-oBox.offsetWidth)/2+‘px‘; 19 oBox.style.top=(iHegiht-oBox.offsetHeight)/2+‘px‘; 20 } 21 } 22 </script> 23 </head> 24 25 <body> 26 <div class="box" id="box"> 27 <iframe width="800" height="400" frameborder="0" scrolling="no" src="http://www.baidu.com"></iframe> 28 </div> 29 </body> 30 <html>
源码来源:https://bbs.csdn.net/topics/390737285 中网友【人生难得一只鸡】的评论。
原文:https://www.cnblogs.com/renxingblack/p/11603051.html