This is a discussion on "repeat a horizontally centered background image" within the Web Page Design section. This forum, and the thread "repeat a horizontally centered background image are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
repeat a horizontally centered background image
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
repeat a horizontally centered background image
I'm trying to position a 770 wide by 1px high, repeating, background so it appears as a centered column the entire length of the page regardless of what height that may be.
I can't just use the value 'center' as this throws the column 1 pixel out of kilter with a sliced navigation bar going on top of it at the top of the page. The NavBar slices appear very nicely centered, at the top of the page, using:
It repeats, but the whole column appears on the left of the page. Little help? Btw, once I've done this, I predict my next question will be about putting accessibility navigation in the space above the NavBar. ![]() Last edited by Rob; Jul 13th, 2006 at 21:40. |
|
|
|
||||
|
Re: repeat a horizontally centered background image
background: url("background.jpg") top center repeat-y;
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
|
|||
|
Re: repeat a horizontally centered background image
what i see there is a box (body) that pulled left by the margin. have you tried getting rid of the margin? i think the bg will default to left: 0;
let me know if im not getting the issue. this is an interesting problem. btw. what doctype are you using? ~Pxl |
|
|||
|
Re: repeat a horizontally centered background image
Definitely get rid of the negative margin. All its doing is pulling the table left by that amount so about half of it is disappearing off to the left.
Quote:
Do your nav bar styling through css. Last edited by Rob; Jul 13th, 2006 at 21:40. |
|
|||
|
Re: repeat a horizontally centered background image
The margin thing is in order to center the image on the page though.
It works perfectly for the navbar. I'll try it on the bg image anyway and see if it helps. Thanks for the tips. I'm using the NavBar because I don't know enough about CSS yet to use that instead so I've had to create images in ImageReady with html, xhtml, css and javascript. I'd do it in CSS if it's possible (and if that's easier, and when I find out how). I'm afraid CSS and I haven't yet reached a stage where we have common reference points of understanding so it's all Chinese to me still. I had the page all nicely laid out and ready to publish using tables and html but I'm trying to convert it to CSS as an exercise (for myself really I suppose) to see; a) if I can do it, and b) if there actually is any benefit over the method I would use normally. |
|
|||
|
Re: repeat a horizontally centered background image
Okay, I cheated a bit;
I reduced the width of the NavBar so the two images weren't competing for the same co-ordinates and then (in case anyone else wants it) used the following code to centre the background behind NavBar.
Thanks for the clues and tips everyone, especially moojoo for the line I needed. I wouldn't have known where to begin this without all your replies (and last night's rest |
|
|||
|
Re: repeat a horizontally centered background image
Drop the css for * and make this code below your starting point. It will be the same for every layout you do apart from maybe chosing different fonts and setting the basic width and colours.
The text-align: center bit in the body styling is for IE's benefit. Proper browsers will respond to the margin: 0 auto style in the mainframe to centre that element. The text-align: left in the mainframe is to turn off the effect of text-align: center in the body. Add you background image code to the mainframe. Adjust the width to suit your needs. Keep the position: relative even if you don't know why for the moment. You'll need them down the line as a 'reference' point. Remember CSS stands for cascading style sheet. Operative word here being 'cascade'. I put a tutorial together on producing css driven menu systems. You can fine it here. http://1ontheweb.net/downloads/Creat...enu_system.pdf Work through that then come and ask questions. |
|
||||
|
Re: repeat a horizontally centered background image
The nagtive margin thing is ideal if you want to vert/hor center a layout with CSS. But for this purpose I don't think you need it as it is very simple to center a layout horizontally.
For example and this may be a bit off topic but eh. the following example will vertically and horizontally center a 400 x 200 box: #foo { width:400px; height:200px; position:absolute; top:50%; left:50%; margin:-100px 0 0 -200px; }
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
|
||||
|
Re: repeat a horizontally centered background image
One more thing. Changed up and lightened your code a bit:
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Last edited by Rob; Jul 14th, 2006 at 16:34. |
|
|||
|
Re: repeat a horizontally centered background image
I think I may be in for a bit of a rough time... everything after my last post made no sense to me whatever.
LMAO! Give me a few hours and I'll have a read through it all and compare it to the code I have and see what affects what and whether I get a sense of 'belonging' yet. *sigh* |
|
|||
|
Re: repeat a horizontally centered background image
Hey Moojoo I guess we could get into a philosophical about this code. I dont see why you have add the second 'text-align: center' in the body styling. I think the font-size in the body should be whatever the end user has set their base font size to be in their browser, then you use the em to go above and below that size as required. Ideally this would be set to 100% but the value used gets around yet another of those annoying little IE bugs. |
|
||||
|
Re: repeat a horizontally centered background image
Quote:
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
|
||||
|
Re: repeat a horizontally centered background image
Quote:
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
![]() |
| Tags |
| repeat, horizontally, centered, background, image |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ie 6 background-repeat does not work | AndrewChip | Web Page Design | 3 | May 4th, 2008 10:19 |
| BG image centered | afowler | Web Page Design | 3 | Oct 16th, 2007 16:34 |
| [SOLVED] CSS Background Repeat | Stuart | Web Page Design | 23 | Sep 29th, 2007 22:36 |
| background-repeat: repeat y not working properly | AdRock | Web Page Design | 12 | Feb 25th, 2007 22:17 |
| Background image left and right of centered div | AdRock | Web Page Design | 11 | Aug 15th, 2006 17:02 |