- This topic is empty.
-
AuthorPosts
-
June 21, 2011 at 12:29 pm #33210
Glenbot3000
MemberA bit of a rudimentary question, but I am a rookie after all. :3
So yeah, how can I align an image I have to the centre of the page (on all resolutions/browsers)?
June 21, 2011 at 12:36 pm #82000Jeager
MemberIs it a background image? Thrown in a div, how is it positioned? Im going to assume its a bg image, so in your css you can use something like:
body
{
background-image:url('smiley.gif');
background-repeat:no-repeat;
background-attachment:fixed;
background-position:center;
}And if I recall correction, you can do ‘center center’ for it to be vertically aligned also.
June 21, 2011 at 12:41 pm #82001Glenbot3000
Member
^ the HTML.
.banner {
position:absolute;
width:9999px;
height:99px;
top:0px;
left:0px;
background-repeat:repeat-x;
background-image:url(/PWR/pwr3.png);
overflow-x:hidden;
}
.logo {
}That’s my CSS. Not sure what to put in for the logo ID to make it centre, but as you can see, it’s not a background image.
June 21, 2011 at 12:43 pm #82002Glenbot3000
MemberOh, and if there’s a better way to have a banner stretch the page, would also be appreciated.
June 21, 2011 at 12:58 pm #82004Jeager
MemberOkay, get rid of the image in your markup.
.logo {
width: 235px;
height: 71px
background-image:url(/PWR/pwr_embossed.png);
margin:0 auto;
}Also change the banner width to 100%. Should work
June 21, 2011 at 1:02 pm #82005Glenbot3000
MemberShould I just add an extra div for the logo class?
June 21, 2011 at 1:03 pm #82006chrisburton
ParticipantWhat is the link to your code?
June 21, 2011 at 1:05 pm #82007Jeager
MemberYeah, add a div inside the banner and add the .logo class to it. Or at least, is how I would do it. Someone else may tell you a better way
June 21, 2011 at 1:13 pm #82008Glenbot3000
Memberproblem solved, anyway. obviously if there’s more to contribute, feel free. :)
June 21, 2011 at 1:24 pm #82009Jeager
MemberGlad to see, where did you find that snip of texture? I like it. Also, I would add a margin-top:14px; to the top, will center it on its y also.
June 21, 2011 at 1:53 pm #82010Glenbot3000
MemberI don’t remember the specific site, but I recoloured it to match the “My Beautiful, Dark, Twisted Fantasy” album cover.
Getting the embossed effect on the text was an absolute nightmare too, but well worth it.
June 21, 2011 at 2:28 pm #82011chrisburton
Participant@Glenbot3000 I completed the code using CSS3 Gradients and a little simple SEO enhancement. There is fallback so this should work in every browser including IE7+ (I did not test in IE6)
Update: View Source
June 21, 2011 at 6:43 pm #82023Glenbot3000
MemberWow, that’s awesome!
Thanks a lot, dude! Highly appreciated.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.