A couple of HTML and CSS questions

From C++ to PHP, debugging to webhosting; help and discussion about writing your latest program to running your website. NOT for help when your PC won't work.

Announcements Posted on
Please change your TSR password 23-05-2013
Enter our travel-writing competition for the chance to win a Nikon 1 J3 camera 20-05-2013
Sign in to Reply
  1. Faustus500's Avatar
    • Junior Member
    • Posts: 31
    A couple of HTML and CSS questions
    Morning all.

    Firstly, I have strange issue with the website I'm creating. All of the HTML pages link to the same CSS document. However, one page insists on having a slightly different margin-left to the others (on the CSS the margins are set to auto.)?

    Secondly: I want to overlay a nav bar on top of a background image that forms the top half of a site. I also want to make the nav bar translucent. How would I go about doing this? And would I need Javascript or something

    Cheers!
  2. estel's Avatar
    • TSR Idol
    • Location: Bristol
    • Posts: 9,352
    Re: A couple of HTML and CSS questions
    Can you link to a working demo?

    A translucent nav-bar can be achieved using the background-color: rgba(255, 255, 255, .5) attribute.
  3. Dez's Avatar
    • TSR Group Staff
    • The square root of rope is string.
    • Location: The South
    • Posts: 8,169
    Re: A couple of HTML and CSS questions
    (Original post by Faustus500)
    Morning all.

    Firstly, I have strange issue with the website I'm creating. All of the HTML pages link to the same CSS document. However, one page insists on having a slightly different margin-left to the others (on the CSS the margins are set to auto.)?

    Secondly: I want to overlay a nav bar on top of a background image that forms the top half of a site. I also want to make the nav bar translucent. How would I go about doing this? And would I need Javascript or something

    Cheers!
    I'm guessing the first issue is probably because one page has a scrollbar present, and the rest don't.

    For a transparent background your best bet is to use rgba(), but make sure you've got a solid colour fallback, e.g.

    Code:
    .nav-bar {
        background-color: #ffffff;
        background-color: rgba(255, 255, 255, 0.5);
    }
  4. Faustus500's Avatar
    • Junior Member
    • Posts: 31
    Re: A couple of HTML and CSS questions
    (Original post by Dez)
    I'm guessing the first issue is probably because one page has a scrollbar present, and the rest don't.
    [/code]
    The page did indeed have a vertical scroll bar... why does this change the horizontal position of the stuff ??

    Thanks to the both of you as I know have transparency
  5. Faustus500's Avatar
    • Junior Member
    • Posts: 31
    Re: A couple of HTML and CSS questions
    (Original post by estel)
    Can you link to a working demo?

    A translucent nav-bar can be achieved using the background-color: rgba(255, 255, 255, .5) attribute.
    Unfortunately the site is not online yet... However, I have done some Googling and realised that I need to use z-indexs to change where divs are on top of each other... However when I do this it screws up the whole site.

    Argh. Any tips??
  6. Dez's Avatar
    • TSR Group Staff
    • The square root of rope is string.
    • Location: The South
    • Posts: 8,169
    Re: A couple of HTML and CSS questions
    (Original post by Faustus500)
    Unfortunately the site is not online yet... However, I have done some Googling and realised that I need to use z-indexs to change where divs are on top of each other... However when I do this it screws up the whole site.

    Argh. Any tips??
    "Screws up the site" isn't really descriptive enough for us to help you. If you can't post a HTML file, can you at least post a screenshot?
  7. fran.ha's Avatar
    • TSR Demigod
    • Location: Kent
    Re: A couple of HTML and CSS questions
    (Original post by estel)
    Can you link to a working demo?

    A translucent nav-bar can be achieved using the background-color: rgba(255, 255, 255, .5) attribute.
    I didn't think this was supported by IE?

    For that reason I always use a .png fallback for IE (I guess you could just use a .png for the entire thing but may as well futureproof it) along with any CSS3 opacity.
  8. Dez's Avatar
    • TSR Group Staff
    • The square root of rope is string.
    • Location: The South
    • Posts: 8,169
    Re: A couple of HTML and CSS questions
    (Original post by fran.ha)
    I didn't think this was supported by IE?

    For that reason I always use a .png fallback for IE (I guess you could just use a .png for the entire thing but may as well futureproof it) along with any CSS3 opacity.
    Transparent backgrounds are supported in IE9. For IE<9, I think a solid colour is enough of a suitable fallback, but it depends on your audience.
  9. fran.ha's Avatar
    • TSR Demigod
    • Location: Kent
    Re: A couple of HTML and CSS questions
    (Original post by Dez)
    Transparent backgrounds are supported in IE9. For IE<9, I think a solid colour is enough of a suitable fallback, but it depends on your audience.
    Yeah, in my job we have to make it as pixel-perfect as we possibly can back to IE7, so a .png would be the fallback rather than solid colour. Seeing as it'd only be a few more minutes work to put a 1px transparent .png in than just write the solid colour hex code in, I think it'd be worth it.
  10. Dez's Avatar
    • TSR Group Staff
    • The square root of rope is string.
    • Location: The South
    • Posts: 8,169
    Re: A couple of HTML and CSS questions
    (Original post by fran.ha)
    Yeah, in my job we have to make it as pixel-perfect as we possibly can back to IE7, so a .png would be the fallback rather than solid colour. Seeing as it'd only be a few more minutes work to put a 1px transparent .png in than just write the solid colour hex code in, I think it'd be worth it.
    You have my sympathy. :console:
  11. estel's Avatar
    • TSR Idol
    • Location: Bristol
    • Posts: 9,352
    Re: A couple of HTML and CSS questions
    Yeh, we charge a decent surcharge for IE7 support.
Sign in to Reply
Share this discussion:  
Useful resources
Article updates
Moderators

We have a brilliant team of more than 60 volunteers looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

Reputation gems:
The Reputation gems seen here indicate how well reputed the user is, red gem indicate negative reputation and green indicates a good rep.
Post rating score:
These scores show if a post has been positively or negatively rated by our members.