Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. CSS only Transparent background in DIV with child elements opaque

CSS only Transparent background in DIV with child elements opaque

Scheduled Pinned Locked Moved Web Development
helphtmlcssquestion
15 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Dave McCool

    I have a slight issue, tried everything to make this work, half the time I can get the background to be 100% transparent so you don't see it and have the other child elements opaque, but all I want is the background to be 50% transparent so the main background is showing through it. First, here is an image of one of the pages. I want the black border to be semi transparent (50%) but everything else inside this area to appear as it is 100% opaque (that is all child elements inside the body_wrapper): http://img697.imageshack.us/img697/8008/webpage.jpg[^] Here is the code in my CSS file that controls the DIV tag (the "background: #000000;" is the black background code that I wanted to have semi transparent:

    .body_wrapper {

    padding: 0 20px 20px;
    background: #000000;
    -webkit-border-radius: 5px;
    \_display: inline;
    

    }

    The only thing is that I can't modify anything on my HTML pages as I have too many and have to do all this with my CSS file. I have been looking all over and tried a few things but nothing seems to work, can anyone help?

    In the end we're all just the same

    D Offline
    D Offline
    dawmail333
    wrote on last edited by
    #6

    Try this:

    .body_wrapper
    {
    background-color: rgba(0,0,0,0.5);
    }

    It will work in browsers that support CSS3, which is becoming more common. Don't know about earlier IE's in particular though, I'm sorry to say. The above code simply sets the div to have a semi-transparent background (approx. 50% black). It's called ARGB. HTH.

    modified on Saturday, August 7, 2010 3:11 AM

    D 1 Reply Last reply
    0
    • D dawmail333

      Try this:

      .body_wrapper
      {
      background-color: rgba(0,0,0,0.5);
      }

      It will work in browsers that support CSS3, which is becoming more common. Don't know about earlier IE's in particular though, I'm sorry to say. The above code simply sets the div to have a semi-transparent background (approx. 50% black). It's called ARGB. HTH.

      modified on Saturday, August 7, 2010 3:11 AM

      D Offline
      D Offline
      Dave McCool
      wrote on last edited by
      #7

      Thanks all got it :) . I tried the rgba(0,0,0,0.5); and it worked, but not on IE so I thought and then did this and now it works in IE: .Body_Wrapper { background-color: rgba(0,0,0,0.5); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#80000000,endColorstr=#80000000); zoom: 1; /* Force hasLayout in IE. */ }

      In the end we're all just the same

      D 1 Reply Last reply
      0
      • D Dave McCool

        Thanks all got it :) . I tried the rgba(0,0,0,0.5); and it worked, but not on IE so I thought and then did this and now it works in IE: .Body_Wrapper { background-color: rgba(0,0,0,0.5); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#80000000,endColorstr=#80000000); zoom: 1; /* Force hasLayout in IE. */ }

        In the end we're all just the same

        D Offline
        D Offline
        dawmail333
        wrote on last edited by
        #8

        Glad to help. ;)

        Posted from SPARTA!!!!!!!!!! 2.0. Don't forget to rate my post if it helped! ;)

        D 1 Reply Last reply
        0
        • D dawmail333

          Glad to help. ;)

          Posted from SPARTA!!!!!!!!!! 2.0. Don't forget to rate my post if it helped! ;)

          D Offline
          D Offline
          Dave McCool
          wrote on last edited by
          #9

          I have only one issue with the code, although it works and now works on IE, on IE any text in child elements does not look smooth: Page on IE: http://img339.imageshack.us/img339/5572/webpageie.jpg[^] Same page on Google Chrome: http://img839.imageshack.us/img839/985/webpagechrome.jpg[^] Is there any way of making the text in the child elements appear normal in IE?

          In the end we're all just the same

          D L 2 Replies Last reply
          0
          • D Dave McCool

            I have only one issue with the code, although it works and now works on IE, on IE any text in child elements does not look smooth: Page on IE: http://img339.imageshack.us/img339/5572/webpageie.jpg[^] Same page on Google Chrome: http://img839.imageshack.us/img839/985/webpagechrome.jpg[^] Is there any way of making the text in the child elements appear normal in IE?

            In the end we're all just the same

            D Offline
            D Offline
            dawmail333
            wrote on last edited by
            #10

            Using proprietary filters in IE generally causes strange side effects. All I can say: http://dowebsitesneedtolookexactlythesameineverybrowser.com/ ;P

            Posted from SPARTA!!!!!!!!!! 2.0. Don't forget to rate my post if it helped! ;)

            D 1 Reply Last reply
            0
            • D Dave McCool

              I have only one issue with the code, although it works and now works on IE, on IE any text in child elements does not look smooth: Page on IE: http://img339.imageshack.us/img339/5572/webpageie.jpg[^] Same page on Google Chrome: http://img839.imageshack.us/img839/985/webpagechrome.jpg[^] Is there any way of making the text in the child elements appear normal in IE?

              In the end we're all just the same

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #11

              Browsers do not render all content exactly the same. But using a reset.css such as via here http://meyerweb.com/eric/tools/css/reset/[^] does help.

              D 1 Reply Last reply
              0
              • L Lost User

                Browsers do not render all content exactly the same. But using a reset.css such as via here http://meyerweb.com/eric/tools/css/reset/[^] does help.

                D Offline
                D Offline
                Dave McCool
                wrote on last edited by
                #12

                I already use a reset CSS, but thanks

                In the end we're all just the same

                1 Reply Last reply
                0
                • D dawmail333

                  Using proprietary filters in IE generally causes strange side effects. All I can say: http://dowebsitesneedtolookexactlythesameineverybrowser.com/ ;P

                  Posted from SPARTA!!!!!!!!!! 2.0. Don't forget to rate my post if it helped! ;)

                  D Offline
                  D Offline
                  Dave McCool
                  wrote on last edited by
                  #13

                  However, IE being the default broswer that a lot use, I would like the transparacy to work well in it, I use google analytics and more people view my current site in IE than in other browsers, and if the text doesn't look smooth and normal on it, its not really going to help much, its not so much important that the website doesn't look 100% in other browsers as I can say this on my home page.

                  In the end we're all just the same

                  D 1 Reply Last reply
                  0
                  • D Dave McCool

                    However, IE being the default broswer that a lot use, I would like the transparacy to work well in it, I use google analytics and more people view my current site in IE than in other browsers, and if the text doesn't look smooth and normal on it, its not really going to help much, its not so much important that the website doesn't look 100% in other browsers as I can say this on my home page.

                    In the end we're all just the same

                    D Offline
                    D Offline
                    dawmail333
                    wrote on last edited by
                    #14

                    All I can say mate, is good luck. IE is a bitch to design for. End of story. Until IE9 is mainstream, IE is going to be the most hated browser for web designers. Trust me, not-so-smooth text seriously is the least of your worries. People aren't going to immediately leave because of it.

                    Posted from SPARTA!!!!!!!!!! 2.0. Don't forget to rate my post if it helped! ;)

                    D 1 Reply Last reply
                    0
                    • D dawmail333

                      All I can say mate, is good luck. IE is a bitch to design for. End of story. Until IE9 is mainstream, IE is going to be the most hated browser for web designers. Trust me, not-so-smooth text seriously is the least of your worries. People aren't going to immediately leave because of it.

                      Posted from SPARTA!!!!!!!!!! 2.0. Don't forget to rate my post if it helped! ;)

                      D Offline
                      D Offline
                      Dave McCool
                      wrote on last edited by
                      #15

                      Thanks, your right. I'll see what I can do, I know IE is annoying. Its just that the tex seems harder to read this way and if people find the text a bit hard to read, they won't stay long. I'll see what I can do.

                      In the end we're all just the same

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups