How to change CSS with our requirement - css

I am using sb-admin project how to set CSSpage wrapper ... it shows small background. I don't know why.
please check
body {
background-color: #000216;
height:100%;
}
#wrapper {
width: 100%;
height: 100%;
}
#page-wrapper {
padding: 0 15px;
min-height: 100%;
background-color: #F4E8FF;
}

If you're talking about the colored background not expanding with the content...I would try adding float:left on the wrapper and page-wrapper selectors in your CSS.

Related

Div not on absolute left of page

I'm working with a div that isn't positioned on the absolute left of the page, all I get is this.
Is there a way I can fix this? I've tried using many methods.
CSS:
#Hello {
background-color: #1c1c1c;
width: 200px;
height: 200px;
float: left;
}
Result
html, body { padding : 0; margin : 0; }
Add html, body { margin: 0; padding: 0 } to your styles. A common technique is to use a reset stylesheet like this to avoid these default browser styles.

Body not extending to bottom of the content

My body is extending only to the bottom of my browser, but not to the bottom of the content. I need to have the background one colour, and the body content another, but i can't seem to make it work.
Here is the css
* {
margin: 0px;
padding: 0px;
}
html, body {
height: 100%;
margin: 0px;
padding: 0px;
}
* html {
height: 100%;
margin: 0px;
padding: 0px;
}
html {
background-color: pink;
}
body {
margin: auto;
max-width: 500px;
min-width: 300px;
background-color: orange;
}
#header {
background: url('http://placehold.it/400x400/0191C8') center;
background-size: cover;
height: 50%;
}
#updown {
font-size: 150%;
}
http://jsfiddle.net/LPXVm/
JSFiddle
Wrap your content in a <section> (or <div> or whatever you want) and then give it the style:background-color:orange;.
Another alternative is to extend the closing </div> of updown and place it at the end of your content. Then give that a style of background-color:orange;.
But this will of course change the font-size of the whole thing.
JSFiddle - Second option.
"I need to have the background one colour, and the body content another".
This doesn't make any sense. The "background" is the . The is at the top of the DOM.
You should assign a background color to the body, and wrap all of your content in a wrapper div or content block then give that a different color.
See updated fiddle: http://jsfiddle.net/LPXVm/4/

CSS Fixed width container with child div auto expand

I am trying to create a simple page which has fixed width container, then inside the container a div which overflows to fill the browsers width. In the fiddle i am aiming to get the .content <div> to expand when the browser is resized width ways.
JSFiddle
Any help would be appreciated.
Have a look at this fiddle, is this what you're after?...alternatively- have a look at this one, which is an alternative take based on your question.
CSS
body {
font: 12px/18px Arial, sans-serif;
width: 100%;
height: 100%;
}
.header {
height: 150px;
background: #FFE680;
}
.content {
padding: 0 0 100px;
background-color: #DD0022;
}
.footer {
height: 100px;
background: #BFF08E;
}

Set Div to 100% of Body

I have a div called 'main-container' that I want to be the height of my content. At the moment, the div is only as tall as my browser window. I've tried to correct this like so:
html, body{
height: 100%;
background-color: $main-background-color;
}
#main-container {
width: 1024px;
height: 100%;
background-color: darken($main-background-color, 5%);
}
Unfortunately, this doesn't work. I've also tried:
#main-container {
width: 1024px;
min-height: 100%;
height:auto !important;
background-color: darken($main-background-color, 5%);
}
This has no effect, either. I've also reworked my layout not use floats, but that didn't solve the problem. After scouring the net, I haven't found any other solutions that work. Does anyone else have an idea?
Also, I don't know if this would affect things, but I'm using Rails 3.
At the bottom of your #main-container div, insert the following code:
<div id="push"></div>
Then in your CSS, add the following:
#push {
clear:both;
}
This should then push the whole container to the height of the content, regardless of floating divs.
I may be misunderstanding what you are trying to accomplish. But if all you want is for your div to be the height of the content, then simply do not declare a height...
html, body{
background-color: $main-background-color;
}
#main-container {
width: 1024px;
background-color: darken($main-background-color, 5%);
}
Try setting min-height:100% instead of height on html/body, as height:100% will limit its size to the viewport.
Your main-container should then be able to stretch it, when higher than the viewport.
html, body{
min-height: 100%;
background-color: $main-background-color;
}
#main-container {
width: 1024px;
background-color: darken($main-background-color, 5%);
}

100% height for multiple divs

I usually have my structure laid out something like this:
<div id="all">
<div id="page">
<div id="header"></div>
<div id="content"></div>
<div id="footer"></div>
</div>
</div>
Where the body will hold a background pattern, "all" will hold a dropshadow for the page going up and down, and "page" may often have a repeating-y background as well.
I have tried variations on using the css height/min-height properties:
html, body {
height:100%;
...
}
#all {
height:100%;
min-height:100%;
}
#page {
height:100%;
min-height:100%;
height:auto !important;
}
It seems like if I remove height:auto from "all" then it seems like it works UNTIL you scroll, then after the scroll the background for all dissappears
example
However if I keep the height:auto there then I get the problem of the background for page not working
example
Hopefully someone knows a fix?
Well, here's what I ended up with for the CSS:
html, body {
height:100%; /* IE6: treaded as min-height*/
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
color: #494949;
text-align: center;
background-color: #3f91a7;
background-image: url(images/bg_body.jpg);
background-repeat: repeat-x;
background-position: center top;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
#all {
margin: 0px;
padding: 0px;
height:100%; /* IE6: treaded as min-height*/
min-height:100%; /* real browsers */
height:auto !important;
background-image: url(images/bg_all.png);
background-repeat: repeat-y;
background-position: center top;
overflow: hidden;
}
#page {
width: 993px;
padding: 0 0 10000px;
margin-top: 0px;
margin-right: auto;
margin-bottom: -10000px;
margin-left: auto;
text-align: left;
background-color: #FFF;
background-image: url(images/bg_page.jpg);
background-position: center top;
background-repeat: repeat-y;
height:100%; /* IE6: treaded as min-height*/
min-height:100%; /* real browsers */
height:auto !important;
}
#header, #footer {
text-align: center;
font-size: 16px;
padding: 20px;
}
#content {
padding: 25px;
}
I haven't had a chance to test it in anything other than Firefox, but, hoipefully it will give you a good start.
I would just flip the location of your div#all and div#page...
<div id="page">
<div id="all">
<div id="header"></div>
<div id="content"></div>
<div id="footer"></div>
</div>
</div>
Although the question was posted some years ago, I ran into the same challenge and found this earlier thread today. Although I reckon there might be more fine solutions by now, I wanted to share the one I found today nevertheless.
Had the same problem, background 1 full screen, adaptive and fully below everything else and another repeating(-y) background number 2 should go on top, but not scroll out of sight because it was set to follow the height of the window which was given to the particular div which holds background 2.
Let's start with the divs I created:
<div id="full_background">
<img src="images/bkg_main.jpg" alt="" />
<div id="absolute">Contains background set to repeat-y</div>
<div id="content">Contains the content</div>
</div>
the css looks like this:
* { margin: 0px; padding: 0px; }
html { height: 100%; }
body { height: 100%; }
#full_background { width: 100%; min-height: 100%; position: relative; float: left; }
#full_background>img { position: absolute; top: 0; left: 0; position: fixed; width: 100%; z-index: 1; display: block; }
#full_background>div { position: relative; z-index: 2; }
#absolute { position: fixed !important; left: 0; width: 100%; height: 100%; background: url("../images/bkg2.png") top left repeat-y; }
#content { width: 290px; margin-left: 20px; padding: 30px; line-height: 1.7em; font-family: 'Lato', sans-serif; position: relative; float: left; }
First off, I added a full screen & resizing background image to my site (using the div full_background and the img tag) using the following solution (very easy css solution which works like a charm in every browser and most older versions down to for example IE7) - http://www.webdeveloper.com/forum/archive/index.php/t-256494.html > see last answer by aj_nsc
Next, using the following jQuery method - http://nicholasbarger.com/2011/08/04/jquery-makes-100-height-so-much-easier/ - I created a div with id = absolute, which is given the same height as the browser window (also on resizing). I placed my repeating(-y) background number 2 in here. Set this div to position:fixed and it will stay put when the div with the content is being scrolled through.
Then below this div you put the div with your content, which freely expands downwards beyond the browser window.
Upon scrolling, the two backgrounds will keep filling the full area of the browser window (vertically as well) at all times and stay put, with the content scrolling up and down over them.
This way, upon resizing, you also make sure that both backgrounds keep filling the full background area at all times.
I tested this solution in CH, FF, IE7-9 and Safari and it worked in all of them without any problems whatsoever.
Here's what's happening: You've set html & body to have a height of 100%, but that 100% is the height of the viewport, not the document. Since #all's height is set to 100%, it is set to 100% of the parent's height, which happens to be body, which is set at 100% of the height of the viewport. Everything's inheriting the height of the viewport.
The way to fix this problem is actually the same way you would fix clearing floats that have an outer container. All you have to do is put overflow:auto; on #all. You don't even need any height declarations on any other elements, and you may be able to eliminate either the #all or the #page div.
More info here: http://www.sitepoint.com/blogs/2005/02/26/simple-clearing-of-floats/
Have you tried:
html,
body {
margin: 0;
padding: 0;
height: 100%;
}
#all {
min-height: 100%;
}
? Only for IE 6, you should set height: 100%; for #all (because it interprets that basically as min-height (as a result of a bug). As IE6 doesn't understand the min-height attribute, height effectively becomes a replacement for min-height).
If you set height: 100%; for other browsers, they will take it as 100% height of the viewport, not 100% of the page, so scrolling won't work correctly.
My comment on the downvote:
It has become clear, that my answer doesn't solve the whole problem. What we have here, seems to be quite a complex case - at least no one here seems to have found an answer yet? I've even looked into Ingo Chao's excellent (German) book, which comes to the same conclusion: Setting the parent's height won't work, and setting the child's height won't work, if the parent's height wasn't set explicitly, but rather dynamically by the size of the content.
But my answer could still help to restrict the possibilities a little bit - because setting height on #all will most likely not work on any browser except IE 6. If you disagree, please post a comment, because in that case, I'd also like to learn more about this.
This worked for me:
#page {
width: 993px;
padding: 0px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
text-align: left;
background-color: #FFF;
background-image: url(http://jeffkilroy.com/hosted/layout1/images/bg_page.jpg);
background-position: center top;
background-repeat: repeat-y;
/* height:100%; IE6: treaded as min-height*/
height: expression(document.body.offsetHeight); /* sets min-height for IE */
overflow: auto;
min-height:100%; /* real browsers */
/* height:auto !important; */
}
Forget 100% on the divs, try moving your background image to the html element and the full height border to the body.
html {
height:100%;
background-color: blue;
}
body {
margin: auto auto;
padding: 0;
color: #494949;
/*min-height: 100%; */
height:100%; /*for ie6*/
border-left:solid 2px red;
border-right:solid 2px red;
background-color:#fff;
width: 960px;
}
Have you tried this :
function getWindowHeight() {
var windowHeight = 0;
if (typeof(window.innerHeight) == 'number') {
windowHeight = window.innerHeight;
}
else {
if (document.documentElement && document.documentElement.clientHeight) {
windowHeight = document.documentElement.clientHeight;
}
else {
if (document.body && document.body.clientHeight) {
windowHeight = document.body.clientHeight;
}
}
}
return windowHeight;
}
window.onload = init;
function init(){
document.getElementByID("all").style.height = getWindowHeight() + "px";
}
Or put page instead of all

Resources