I have solutions that work in all browsers except IE, so I'd appreciate if the answers worked in IE.
<div id="content">
<div id="redBar"></div>
<div id="main">
<div id="header">
<img src="images/header.gif" id="logo1">
</div>
<div id="explanation">
Next div.
</div>
</div>
<div id="footer">
</div>
</div>
I guess I'll just give the CSS too:
#main
{
padding-left:229px;
padding-right:229px;
}
#logo1
{
width:auto;
z-index:1;
position: relative;
left:250px;
}
#main
{
//background-image:url('../images/indexBack.gif');
background-repeat:repeat-xy;
width:980px;
}
Well what you're trying to do is relatively simple but you're putting your logo nested in a few block elements that might mess it up because they don't have the necessary styling applied to them...
A visual image of the different areas would help but heres what I think you're trying to do. I am asuming you want the entire page centered too (if not then it is impossible with your current html).
(Also you defined the css class for #main twice)
<div id="content">
<div id="redBar"></div>
<div id="main">
<div id="header">
<img src="images/header.gif" />
</div>
<div id="explanation">
Next div.
</div>
</div>
<div id="footer">
</div>
</div>
<style>
#main
{
background-image:url('../images/indexBack.gif');
background-repeat:repeat-xy;
width: 980px;
margin: 0 auto;
}
#header img /* don't put un-needed ids on elements */
{
display:block; /* img is an inline element by default but we want it as a block so margin works */
margin: 0 auto;
}
</style>
If you know the dimensions of the logo then you can use absolute positioning. Lets say your logo is 200x100:
#logo1 {
position:absolute;
top:50%;
left:50%;
margin-top:-50px; /* half the logo height */
margin-left:-100px; /* half the logo width */
}
This does rather assume that your element's container fills the size of the screen too though.
Related
I have a bootstrap 3 page with a centered box which contains content.
If the content grows the box stays static and doesn't grows with my content but the bootstrap container grows.
I don't know why the "box" did'nt expand. I tried "position:relative" and "overflow:hidden" but it doesn't work.
I tried also "container-fluid" - no reaction.
My CSS-Stylesheet:
html,
body {
height:100%;
width:100%;
}
.container {
height:100%;
min-height:100%;
}
.row {
height:100%;
min-height:100%;
}
.box {
height:90%;
min-height:90%;
max-width:1100px;
background-color:rgba(0,0,0,0.83);
text-align:left;
padding-left:5%;
padding-right:5%;
padding-top:1%;
overflow:hidde;
position: relative;
}
HTML:
<div class="container">
<div class="row">
<div class="box">
<div class="col-xs-12">
</div>
</div>
</div>
</div>
You have hardcoded the height of you box, thats why it doesnt grow as more content comes in. You have to set the height to auto. And if you want that the box has a minimum height while not so much content is present just use an additional min-height: 100vh;
.box {
height:auto;
min-height: 100vh;
/* etc.
}
See working Fiddle
Since you are using bootstrap, try to make like this
<div class="container">
<div class="row">
<div class="col-md-12 box">
<div class="col-xs-12">
</div>
</div>
</div>
and then make the height like:
.box
{
height: 100%;
}
I have a web page that is divided into header, page and footer.
The problem is that I made the page height :auto;.
But it does not work and I need the page to automatically grow up.
This is what I have in the CSS:
/* Page */
#page-wrapper {
overflow: auto;
height: auto;
text-align: center;
}
#page {
overflow: auto;
width: 1120px;
margin: 0px auto;
padding: 50px 40px;
color: #8F8F8F;
min-height:700px;
height:auto;
}
And HTML:
<body>
<div id="banner">
<div class="img-border">
<div id="header-wrapper">
<div id="header">
<div id="logo">
</div>
</div>
</div>
</div>
</div>
<div id="wrapper">
<div id="page-wrapper">
<div id="page">
<div id="wide-content">
</div>
</div>
</div>
</div>
It is very unclear what it is that you want.
In your first line you say you want a footer, but your HTML and CSS don't show any footers.
If you want a footer which sticks to the bottom of the page, have a look at the CSS Sticky Footer.
You shouldn't need the height in there at all... a div will grow or shrink with the amount of content inside of it. Try removing height: auto; completely.
If though you mean that you want to make the content section 100% of the page height even when there isn't enough content, this should help Make div 100% height of browser window
Do you mean you want the footer of your page at the bottom and the div imbetween to take up the remaining space (it's a little difficult to determine from your wording)?
If this is you what you want, I'd suggest looking at this blog post:
http://matthewjamestaylor.com/blog/keeping-footers-at-the-bottom-of-the-page
HTML summary:
<div id="container">
<div id="header"></div>
<div id="body"></div>
<div id="footer"></div>
</div>
CSS summary:
html,
body {
margin:0;
padding:0;
height:100%;
}
#container {
min-height:100%;
position:relative;
}
#header {
background:#ff0;
padding:10px;
}
#body {
padding:10px;
padding-bottom:60px; /* Height of the footer */
}
#footer {
position:absolute;
bottom:0;
width:100%;
height:60px; /* Height of the footer */
background:#6cf;
}
Hi I am really struggling with this, can't figure out what I am doing wrong. I am building my friends website: bethcalter.co.uk/index.php and when checking it on other browsers, the divs were off the page and when I resized the window the divs were moving and I don't want them to do that.
I am new to HTML/CSS I don't do a lot of it, I'm more a designer, please help, I have looked for answers on here already, but something is up with my coding I think, I have tried giving the divs their own wrapper etc and it doesnt work.
My css:
#content {
margin:0;
width:900px;
height:400px;
margin-left:360px;
margin-top:-930px;
background-color: #ffffff;
position:absolute;
}
#bar {
margin:0 auto;
width:900px;
height:90px;
margin-left:360px;
margin-top:-1010px;
background-color: #ffffff;
opacity: 0.4;
position:absolute;
}
Html:
<body>
<div id="banner">
</div>
<div id="background">
<div id="wrapper">
<img src="images/Statue4.jpg">
</div>
</div>
<div id="wrap">
<div id="bar">
</div>
<div id="content">
<img src='images/deb.jpg' style="margin: 40px 40px 40px 40px"/>
</div>
</div>
</body>
</html>
Please help, much appreciated
Your big image div is moving if you resize your window because your are aligning it to the center of the page.
Remove this line in your css in your #wrapper selector if you just want to have it aligned left:
margin: 0 auto;
I'm making some mobile HTML & would like to have a div that uses up 100% of the space it has, but not use up its container and in it have 3 divs that split it up into 3 parts and have the following layout:
How can I do this using divs, I've tried to but having percentage and fixed height divs is confusing. I can do it with horizontally aligned ones, but vertically it confuses me. I don't want it to overlap by making the bottom one absolute.
Edit
The remaining space is essentially just one big div that has an overscroll-y that uses up the whole space
I have to place the layout in the section underneath the titlebar which is why I cant use position: fixed because it will interfere with the parent container.
First of all, the image in your edited question probably came from JQuery Mobile. Consider using jQuery mobile. It could be an option too.
<style type="text/css">
#container{position: relative; width: 100%; height: 100%; background-color:#ddd; z-index:1;}
#header{position: fixed; top:0; left:0; width:100%; height: 80px; background-color:#f30;z-index:3;}
#footer{position: fixed; bottom:0; left:0; width:100%; height: 80px; background-color:#f30;z-index:4;}
#content{width:100%; z-index:5; padding-top: 90px; padding-bottom: 80px;}
</style>
<div id="container">
<div id="header">
</div>
<div id="content">
Put body content here...
</div>
<div id="footer">
</div>
</div>
You might need jQuery to spice it all up. This should give you the basic idea.
http://jsfiddle.net/wy6rS/1/
<div id="toolbar">This is fixed toolbar.</div>
<div id="wrap">
<div id="header">This is the header</div>
<div id="content">Content will Expand with scripting. Notice the push.</div>
<div id="push"></div>
<div> <!--wrap ends here-->
<div id="footer">This is the footer</div>
The push makes room for the sticky footer. Notice equal negative margin on #wrap.
#wrap { width:100%; min-height:100%; height:100% !important; margin-bottom:-80px; margin-top:50px; }
#toolbar { position:fixed; top:0; width:100%; height:50px; }
#header { height: 140px; }
#content { min-height:300px; height:100%; }
#push, #footer { height:80px; } /* Must be same height as footer */
Then you'll need script to expand the content. Check the jsfiddle. It will work in a real page.
I'm trying to set up a site that has a "carousel" of divs that are all side-by-side (floated left) each with a full-screen width. Using javascript i plan to move different divs into view by moving the "carousel."
My problem is that for some reason when I set overflow:hidden on the div that contains the carousel all the content is hidden. When I inspect with firebug the divs show up in the correct places but none of the content is visible.
Here is the HTML:
<div id="content_window">
<div id="carousel">
<div id="p_home" class="pane">
Home!
</div>
<div id="p_about" class="pane">
About!
</div>
<div id="p_services" class="pane">
Services!
</div>
<div id="p_contact" class="pane">
Contact!
</div>
</div>
</div>
And the CSS:
#content_window
{
position:relative;
width:100%;
overflow:hidden;
}
#carousel
{
position:absolute;
width:400%;
top:50px;
left:0;
overflow:hidden;
}
.pane
{
float:left;
width:25%;
color:White;
text-align:left;
margin-top:50px;
}
If I take the overflow:hidden off of #content_window then the content in the panes becomes visible but horizontal scrollbars are added and you can scroll across and see all the panes. Does anyone know what I'm doing wrong?
When a div contains nothing except floated or positioned elements, its height becomes 0. That is the problem with div#content_window. Try adding a height to that div:
#content_window
{
height: 120px;
}
There's no need to use absolute positioning at all. Just have the content_window clip the viewport for the carousel. See http://jsbin.com/uhubij/edit#html.
The CSS is much simpler:
#content_window {
width:100%;
overflow:hidden;
}
#carousel {
width:400%;
}
.pane {
float:left;
width:25%;
text-align:left;
margin-top:50px;
}
To switch between the panes, add a margin-left to #carousel. The first pane is at margin-left: 0% (default). The second pane is at margin-left: -100%;. The third pane is at margin-left: -200%;, etc... For example, here is pane 2: http://jsbin.com/uhubij/2/edit#html
The HTML is basically the same (except I added a clearing div for you):
<div id="content_window">
<div id="carousel">
<div id="p_home" class="pane">
Home!
</div>
<div id="p_about" class="pane">
About!
</div>
<div id="p_services" class="pane">
Services!
</div>
<div id="p_contact" class="pane">
Contact!
</div>
<div style="clear: both;"></div>
</div>
</div>