How do I have a static height/width sidebar and bottom bar with a respnsive main content area that houses an iframe?

十年热恋 提交于 2021-02-04 21:14:25

问题


I want to display a web page that is just an iframe, with a fixed width sidebar and a fixed height bottom bar.

It will look like this: enter image description here

This is where I'm at now, which doesn't work:

<style>
body {margin:0;overflow:hidden;background-color:#f4f4f4;}
#iframe {position:absolute;left:0px;top:0px; width:100%; height:100%; padding:0px 200px 100px 0px;}
#bars {width:100%;height:100%;}
#bottombar {width:100%; height: 100px; position: absolute; bottom: 0; background: grey}
#sidebar {width:200px; height: 100%; position: absolute; right: 0;background: grey}
</style>


<iframe id="iframe" name="iframe1" frameborder="0" height="100%" width="100%" src="http://someurl.com"></iframe>

<div id="bars">
     <div id="bottombar"></div>
     <div id="sidebar"></div>
</div>

Any help would be much appreciated!


回答1:


I would use HTML5 and this is not the best way to make the layout, but well...

Here is the jsfiddle: http://jsfiddle.net/JP3zW/

/* In a Reset CSS */

body, div {
    margin: 0;
    padding: 0;
}

/* Style CSS */

html, body { height: 100%; }

body {
    position: relative;
    background: #F4F4F4;
}

iframe#iframe {
    width: calc(100% - 200px);
    height: calc(100% - 100px);
    overflow: hidden;
}

div#sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 200px;
    background: gray;
}

div#bottombar {
    bottom: 0;
    height: 100px;
    width: 100%;
    background: black;
}



回答2:


It looks like your code works just fine. What browser/version are you testing in? Some browsers like Firefox require you to set "min-height" in addition to height to get certain elements to display correctly. Internet Explorer also has many issues with CSS. Please provide more context.



来源:https://stackoverflow.com/questions/17203085/how-do-i-have-a-static-height-width-sidebar-and-bottom-bar-with-a-respnsive-main

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!