- This topic is empty.
-
AuthorPosts
-
November 13, 2012 at 6:39 am #40764
plaedien
ParticipantHi guys,
This is driving me nuts, and after an exhaustive google search, I cant seem to find a solution to this particular problem.
I have background image in the
tag,html, body {
background-color: #ffffff;
background: url(images/background-bamboo.png) top right no-repeat fixed;
font-family: sans-serif;
position: relative;
width: 100%;
height: 100%;
min-height: 100%;
display: table;
behavior: url(PIE.php);
}
which works fine when scrolling up and down, but the problem is when the browser is resized horizontally the background image slides across, when I really want it positioned so that it never leaves the side of the
div that sits on top of it. Here is the site at the moment.
at a browser width of about 1525px, this is how I would want the background image to sit.
Any ideas? I know it’s most likely something simple, but its doing my head in.
thanks :)
November 13, 2012 at 6:43 am #114129Watson90
MemberMaybe try;
html, body { background: url(“images/background-bamboo.png”) no-repeat;
background-position: right top;
background-attachment: fixed;November 13, 2012 at 6:50 am #114156plaedien
Participantwhoops my code looks messed up, should’ve previewed first!
Isn’t what I’ve written already basically the same thing?
html, body {
background-color: #ffffff; background: url(images/background-bamboo.png) top right no-repeat fixed;
font-family: sans-serif;
position: relative;
width: 100%;
height: 100%;
min-height: 100%;
display: table;
behavior: url(PIE.php); }
November 13, 2012 at 6:54 am #114157plaedien
Participanthtml, body {
background-color: #ffffff;
background: url(images/background-bamboo.png) right top no-repeat fixed;
font-family: sans-serif;
position: relative;
width: 100%;
height: 100%;
min-height: 100%;
display: table;
behavior: url(PIE.php);
}November 13, 2012 at 6:57 am #114158Paulie_D
MemberYou’re going to have to put that image on something else than the body to do that. It’s sticking exactly where you told it to…the top right of your body (viewport).
November 13, 2012 at 7:00 am #114159plaedien
ParticipantI’ve tried putting it in a separate div before the main container, but it pushes the rest of the site down and I cant seem to wrestle any kind of positioning control from it, for examples float right, margins etc.
November 13, 2012 at 7:15 am #114161Paulie_D
MemberWell the only thing I can think of is to make it REALLY wide and fix it to the left.
That’s still not going to pin it to the side of the container and it will slide off to the right side on re-size.
November 13, 2012 at 7:58 am #114168plaedien
Participantok i got it to stick to the container using a src image:
Code:
#container {
width: 960px;
padding: 0;
margin: auto;
position: relative;
z-index: 10;
}#bg-pic-div {
width: 960px;
padding: 0;
margin: auto;}
.bg-pic {
width: 478px;
height: 970px;
position: absolute;
margin-left: 750px;
}Now the problem is the bamboo image is causing a horizontal scroll bar. Which means at smaller resolutions the whole site is now off centre….
live view: http://onthemend.com.au/test/
November 13, 2012 at 8:00 am #114170Paulie_D
MemberFrankly, if that’s the only problem, I’d leave it.
With a width of 960px on your container it’ll get a scroll bar anyway once you get near that width.
November 13, 2012 at 8:06 am #114172plaedien
Participantsorry for the weird posts, i dont know what the hell is going on with the giant lettering
November 13, 2012 at 8:18 am #114171Paulie_D
MemberNot a problem
For CSS you just have to type it out, select it all with your mouse and hit the Code button.
It will indent it all and make it show up correctly.
This usually won’t work for HMTL.
Frankly, it’s much easier to put it in Codepen and link that…it also lets us play with it.
November 14, 2012 at 7:23 am #114289plaedien
ParticipantI couldnt deal with the scroll bar, so i ended up biting the bullet and doing a large background image which is mostly white – turns out it was only 10kb more than the bamboo by itself anyway – so what the hell. Found this code that makes it work perfectly:
html, body {
background: #fff url(images/background-bamboo-large.png) no-repeat center top;
padding: 0;
margin: 0;
width: 100%;
display: table;
height: 100%;
min-height: 100%;
font-family: sans-serif;
behavior: url(PIE.php);
}thanks for your suggestions though :)
November 14, 2012 at 7:25 am #114290plaedien
Participantfrom this site:
[Your text to link here…](http://webdesignerwall.com/tutorials/how-to-css-large-background “Large backgrounds”) -
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.