另一个问题可能无法回答:
在我的网站上,我在 div 容器中有一个 iframe
:
分区:
<div id='frame'>
<iframe id='content' name='contentfield' ></iframe>
</div>
在 css
文件中有:
CSS:
div#frame{
position:absolute;
display:flex;
background-color:green;(just for my testing)
top:100px;
float:left;
width:calc(100vw - 200px);
height:calc(100vh - 100px);
}
iframe#content{
border:none;
width:100%;
height:100%;
}
这个 iframe
显示了我网站的不同方面,例如index.php(很多 index.php 的)
所以一个由 javascript
加载:
function start(id){active = id;
document.getElementById('content').src='content/hallo/';
}
所以有:content/hallo/index.php。
index.php
是一个普通的 html
文件,但是 body 被设置为特定的 px 宽度:
<body style='width:1000px'>
...
</body>
现在:如果浏览器窗口大于 1200px(body 为 100px,另一个 div 为 200px,请参阅 div#frame)iframe
的内容具有 1000px 的宽度但向左浮动。我希望它居中,这样如果浏览器窗口的宽度为 1600px,则内容的 margin-left=margin-right 为 200px a.s.o.
编辑: 显示不希望的屏幕截图: darkgray is the menu, light gray the iframe and, as you guess right, the pic i a part of me
最佳答案
解决方案:您将设置以下属性
max-width:auto;
关于html - 为特定宽度的内容主体居中 iframe 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47729931/