Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Transparent Boxes.. without transparent text

  • 28-08-2010 09:41PM
    #1
    Registered Users, Registered Users 2 Posts: 4,946 ✭✭✭


    .box
    {
    background-color:#151519;
    height: 50px;
    width: 300px;
    filter:alpha(opacity=50);
    opacity: 0.50;
    }



    h2
    {
    color:#FFF;
    filter:alpha(opacity=100);
    opacity: 1.00;
    -moz-opacity:1.0;
    -khtml-opacity: 1.0;
    }



    The above code is what i have so far on a box that i want to shade over a certain area of a page. However, the text thats inside that box (lets say h2) wont stay at full opacity.

    Any ideas?

    Cheers


Comments

  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    That's because h2's "100%" is "100% of the parent". That's the way CSS works.

    Try this : http://css-tricks.com/non-transparent-elements-inside-transparent-elements/


  • Registered Users, Registered Users 2 Posts: 4,946 ✭✭✭red_ice


    that was my understanding of it liam, and your reply was very helpful, however it leaves me with then problem of dynamic text not expanding the box that its covering.

    Any ideas?


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    Depends on whether you need to support IE

    http://greenevillage.net/csspages/rgba.aspx

    Other than that, you're looking at an image solution.


  • Registered Users, Registered Users 2 Posts: 8,488 ✭✭✭Goodshape


    Opacity isn't what you need. You're looking for background rgba colour.

    Background: rgba(255, 255, 255, 0.5), for instance. Google it :). Browser support ain't the best though.


  • Registered Users, Registered Users 2 Posts: 4,946 ✭✭✭red_ice


    Cheers fellas

    I've decided to scrap that idea now. Im trying to build a site from top to bottom in CSS/jquery without images. I had a subtle, tasteful idea, but the more it developed the more tacky it started to look.

    I've settled on full opacity colour, looks well.

    appreciate the help.


  • Advertisement
Advertisement