Search code examples
cssbackgroundrgba

Multiple Identical RGBA colours not working


basically I wanted to try have the same rgba value in three different areas. I wanted my body, nav and footer all to have rgba(0,0,0,.8).

My body works but the nav and footer just show was solid black without the transparency...

I've tried changing the transparency slightly so they're different but that doesn't work either.

Are you only allowed to use it once?

Joe

@font-face {
        font-family: 'telegraficoregular';
        src: url('../FONTS/telegrafico-webfont.eot');
        src: url('../FONTS/telegrafico-webfont.eot?#iefix') format('embedded-opentype'),
             url('../FONTS/telegrafico-webfont.woff2') format('woff2'),
             url('../FONTS/telegrafico-webfont.woff') format('woff'),
             url('../FONTS/telegrafico-webfont.ttf') format('truetype'),
             url('../FONTS/telegrafico-webfont.svg#telegraficoregular') format('svg');
        font-weight: normal;
        font-style: normal;

    }

    .cf:after {
      content: "";
      display: table;
      clear: both;
    }

    html, body, head, nav, article, aside, section, h3, h4, footer, ul, li {

    margin: 0;
    padding: 0;

    }

    /*Global Styles*/

    html {

    margin: 0;
    padding: 0;

    }


    body {

    width: 100%;
    margin: 0 auto;
    padding: 0;
    background:rgba(0,0,0,.9);
    font-family: serif, arial, helvetica, georgia;
    font-size: 16px;


    }

    h1 {

    font-family: telegraficoregular;
    font-size: 3em;
    color: rgb(50,153,187);
    padding: 0;
    margin:0;
    text-align: center;

    }

    h2 {

    font-family: telegraficoregular;
    font-size: 1em;
    font-style: italic;
    color: #003366;
    padding: 0;
    margin: 0;
    text-align: center;

    }

    p {

    font-family: serif;
    font-size: 1.1em;
    color: black;
    text-align:left;
    padding-left:70px;
    }

    h4 + p {

    font-family: serif;
    font-size: 1.1em;
    color: black;
    text-align:left;
    padding-left:70px;
    padding-top: 10px;
    }
    /*Nav Styles */

    header {

    background:rgb(233,233,233);
    width: 100%;
    height: 160px;
    margin:0 auto;

    }

    nav {

    background:rgba(0,0,0,.8);
    width: auto;
    height: 64px;

    }

    nav ul.TopMenu li {

    float: left;
    list-style: none;
    width: 150px;

    }

    nav ul.TopMenu {

    width: 600px;
    margin: 0 auto;

    }

    nav ul.TopMenu li a {

    display:block;
    line-height: 64px;
    padding:0 2em;
    text-align: center;
    font-family: telegraficoregular;
    font-size: 1.2em;
    text-decoration: none;
    }

    li {

    position: relative;

    }

    nav ul.SubMenu{

    float: none;
    text-align: center;
    border-bottom: 1px solid white;
    position: absolute;
    left: -9000em;
    top: 64px;
    height: auto;
    max-height: 0;
    -moz-transition: max-height 0.5s ease-in-out;
    -webkit-transition: max-height 0.5s ease-in-out;
    -o-transition: max-height 0.5s ease-in-out;
    transition: max-height 0.5s ease-in-out;
    overflow:hidden;
    z-index:999;
    }

    nav ul.SubMenu li{

    height: 32px;
    font-family: telegraficoregular;
    font-size: 1em;
    padding: 0;
    margin: 0;
    border-bottom: 1px solid white;

    }

    nav ul.SubMenu li a{

    display:block;
    line-height: 32px;
    padding: 0px;
    margin: 0;
    }





    .TopMenu li:hover ul{

    left: 0;
    max-height: 20em;

    }

    ul.SubMenu li a{

    background: rgba(0,0,0,.8);
    border-bottom: 1px solid white;


    }

    ul.SubMenu li a:visited {

    color: white;

    }

    ul.SubMenu li a:hover {

    background: rgba(255,165,0,.8);

    }


    a:visited {

    color: white;

    }

    a:hover {

    color: orange; 

    }


    /* Article Styles */

    article {

    width: 896px;
    padding: 32px;

    }


    /*Section Styles */


    section.China {

    text-align: center;
    margin: 20px auto;
    padding: 20px;

    }

    section h3 {

    font-family: telegraficoregular;
    font-size: 2em;
    border-bottom: 1px solid black;
    padding: 5px;
    }

    section h4 {

    font-family: telegraficoregular;
    font-size: 1.4em;
    padding-top: 60px;
    padding-left: 70px;
    text-align: left;
    text-decoration: underline;

    }

    section.China img {

    position: relative;
    top: 20px;
    border-radius: 5px;
    }

    section.Australia {

    text-align: center;
    margin: 20px auto;
    padding: 20px;

    }

    section.Australia img {

    position: relative;
    top: 20px;
    border-radius: 5px;
    }

    section.Thailand {

    text-align: center;
    margin: 20px auto;
    padding: 20px;

    }

    section.Thailand img {

    position: relative;
    top: 20px;
    border-radius: 5px;
    }


    /* Link Styles*/



    /* About Styles */



    #AboutContent{

    width: 960px;
    height: 1200px;
    margin: 0 auto;
    padding: 0;
    background: white;
    font-family: serif, arial, helvetica, georgia;
    font-size: 16px;
    color: black;

    }

    #AboutHeader {

    text-align: center;
    margin: 20px auto;
    padding: 20px;

    }

    #AboutHeader img {

    display: block;
    margin: 0 auto;
    text-align: center;

    }

    #AboutHeader h2 {

    font-family: telegraficoregular;
    font-size: 1.5em;
    text-decoration: underline;
    color: black;
    padding: 0;
    margin-top: 20px;
    text-align: center;

    }

    h2 + img {

    position: relative;
    top: 50px;
    border-radius: 5px;
    }

    #AboutHeader p {

    font-family: serif;
    font-size: 1.1em;
    color: black;
    text-align:left;
    padding:50px 0 0 100px;
    }

    /*Photos Content */

    #PhotoContent{

    width: 960px;
    height:auto;
    margin: 0 auto;
    padding: 0;
    background: white;
    font-family: serif, arial, helvetica, georgia;
    font-size: 16px;
    color: black;

    }

    /* Photos Gallery */

    #ChinaPhotos {

    width: 960px;
    height:1200px;
    margin: 0 auto;
    padding: 0;
    background: white;
    font-family: serif, arial, helvetica, georgia;
    font-size: 16px;
    color: black;

    }

    #ChinaPhotos h3 {

    font-family: telegraficoregular;
    font-size: 2em;
    border-bottom: 1px solid black;
    padding: 5px;
    text-align: center;
    margin-top: 20px;

    }

    #ChinaPhotos img {

    margin-top: 20px;
    border: 1px solid black;

    }

    #ChinaPhotos a .Thumb:hover {

    width: 320px;
    height: 240px;

    }

    /* Container Styles */

    #Content {

    width: 960px;
    height: auto;
    margin: 0 auto;
    padding: 0;
    background: white;
    font-family: serif, arial, helvetica, georgia;
    font-size: 16px;
    color: black;

    }


    /* Footer Styles */

    .Footer {
    width: 100%;
    height: 80px;
    background: rgba(0,0,0,.7);
    }

    .Footer p {

    font-family: telegraficoregular;
    color: white;
    font-style: italic;
    line-height: 80px;
    text-align: center;

    }

Solution

  • So, it looks as though it's the overlap that is causing your problems (see comment above. I changed the background colours in the nav and footer and they show up just find.

    It's the fact that you have two elements with 80% opacity overlapped, and the outcome looks black.

        html, body, head, nav, article, aside, section, h3, h4, footer, ul, li {
    
        margin: 0;
        padding: 0;
    
        }
    
        /*Global Styles*/
    
        html {
    
        margin: 0;
        padding: 0;
    
        }
    
    
        body {
    
        width: 100%;
        margin: 0 auto;
        padding: 0;
        background:rgba(0,0,0,.9);
        font-family: serif, arial, helvetica, georgia;
        font-size: 16px;
    
    
        }
    
        h1 {
    
        font-family: telegraficoregular;
        font-size: 3em;
        color: rgb(50,153,187);
        padding: 0;
        margin:0;
        text-align: center;
    
        }
    
        h2 {
    
        font-family: telegraficoregular;
        font-size: 1em;
        font-style: italic;
        color: #003366;
        padding: 0;
        margin: 0;
        text-align: center;
    
        }
    
        p {
    
        font-family: serif;
        font-size: 1.1em;
        color: black;
        text-align:left;
        padding-left:70px;
        }
    
        h4 + p {
    
        font-family: serif;
        font-size: 1.1em;
        color: black;
        text-align:left;
        padding-left:70px;
        padding-top: 10px;
        }
        /*Nav Styles */
    
        header {
    
        background:rgb(233,233,233);
        width: 100%;
        height: 160px;
        margin:0 auto;
    
        }
    
        nav {
    
        background:rgba(255,0,0,.8);
        width: auto;
        height: 64px;
    
        }
    
        nav ul.TopMenu li {
    
        float: left;
        list-style: none;
        width: 150px;
    
        }
    
        nav ul.TopMenu {
    
        width: 600px;
        margin: 0 auto;
    
        }
    
        nav ul.TopMenu li a {
    
        display:block;
        line-height: 64px;
        padding:0 2em;
        text-align: center;
        font-family: telegraficoregular;
        font-size: 1.2em;
        text-decoration: none;
        }
    
        li {
    
        position: relative;
    
        }
    
        nav ul.SubMenu{
    
        float: none;
        text-align: center;
        border-bottom: 1px solid white;
        position: absolute;
        left: -9000em;
        top: 64px;
        height: auto;
        max-height: 0;
        -moz-transition: max-height 0.5s ease-in-out;
        -webkit-transition: max-height 0.5s ease-in-out;
        -o-transition: max-height 0.5s ease-in-out;
        transition: max-height 0.5s ease-in-out;
        overflow:hidden;
        z-index:999;
        }
    
        nav ul.SubMenu li{
    
        height: 32px;
        font-family: telegraficoregular;
        font-size: 1em;
        padding: 0;
        margin: 0;
        border-bottom: 1px solid white;
    
        }
    
        nav ul.SubMenu li a{
    
        display:block;
        line-height: 32px;
        padding: 0px;
        margin: 0;
        }
    
    
    
    
    
        .TopMenu li:hover ul{
    
        left: 0;
        max-height: 20em;
    
        }
    
        ul.SubMenu li a{
    
        background: rgba(0,0,0,.8);
        border-bottom: 1px solid white;
    
    
        }
    
        ul.SubMenu li a:visited {
    
        color: white;
    
        }
    
        ul.SubMenu li a:hover {
    
        background: rgba(255,165,0,.8);
    
        }
    
    
        a:visited {
    
        color: white;
    
        }
    
        a:hover {
    
        color: orange; 
    
        }
    
    
        /* Article Styles */
    
        article {
    
        width: 896px;
        padding: 32px;
    
        }
    
    
        /*Section Styles */
    
    
        section.China {
    
        text-align: center;
        margin: 20px auto;
        padding: 20px;
    
        }
    
        section h3 {
    
        font-family: telegraficoregular;
        font-size: 2em;
        border-bottom: 1px solid black;
        padding: 5px;
        }
    
        section h4 {
    
        font-family: telegraficoregular;
        font-size: 1.4em;
        padding-top: 60px;
        padding-left: 70px;
        text-align: left;
        text-decoration: underline;
    
        }
    
        section.China img {
    
        position: relative;
        top: 20px;
        border-radius: 5px;
        }
    
        section.Australia {
    
        text-align: center;
        margin: 20px auto;
        padding: 20px;
    
        }
    
        section.Australia img {
    
        position: relative;
        top: 20px;
        border-radius: 5px;
        }
    
        section.Thailand {
    
        text-align: center;
        margin: 20px auto;
        padding: 20px;
    
        }
    
        section.Thailand img {
    
        position: relative;
        top: 20px;
        border-radius: 5px;
        }
    
    
        /* Link Styles*/
    
    
    
        /* About Styles */
    
    
    
        #AboutContent{
    
        width: 960px;
        height: 1200px;
        margin: 0 auto;
        padding: 0;
        background: white;
        font-family: serif, arial, helvetica, georgia;
        font-size: 16px;
        color: black;
    
        }
    
        #AboutHeader {
    
        text-align: center;
        margin: 20px auto;
        padding: 20px;
    
        }
    
        #AboutHeader img {
    
        display: block;
        margin: 0 auto;
        text-align: center;
    
        }
    
        #AboutHeader h2 {
    
        font-family: telegraficoregular;
        font-size: 1.5em;
        text-decoration: underline;
        color: black;
        padding: 0;
        margin-top: 20px;
        text-align: center;
    
        }
    
        h2 + img {
    
        position: relative;
        top: 50px;
        border-radius: 5px;
        }
    
        #AboutHeader p {
    
        font-family: serif;
        font-size: 1.1em;
        color: black;
        text-align:left;
        padding:50px 0 0 100px;
        }
    
        /*Photos Content */
    
        #PhotoContent{
    
        width: 960px;
        height:auto;
        margin: 0 auto;
        padding: 0;
        background: white;
        font-family: serif, arial, helvetica, georgia;
        font-size: 16px;
        color: black;
    
        }
    
        /* Photos Gallery */
    
        #ChinaPhotos {
    
        width: 960px;
        height:1200px;
        margin: 0 auto;
        padding: 0;
        background: white;
        font-family: serif, arial, helvetica, georgia;
        font-size: 16px;
        color: black;
    
        }
    
        #ChinaPhotos h3 {
    
        font-family: telegraficoregular;
        font-size: 2em;
        border-bottom: 1px solid black;
        padding: 5px;
        text-align: center;
        margin-top: 20px;
    
        }
    
        #ChinaPhotos img {
    
        margin-top: 20px;
        border: 1px solid black;
    
        }
    
        #ChinaPhotos a .Thumb:hover {
    
        width: 320px;
        height: 240px;
    
        }
    
        /* Container Styles */
    
        #Content {
    
        width: 960px;
        height: auto;
        margin: 0 auto;
        padding: 0;
        background: white;
        font-family: serif, arial, helvetica, georgia;
        font-size: 16px;
        color: black;
    
        }
    
    
        /* Footer Styles */
    
        .Footer {
        width: 100%;
        height: 80px;
        background: rgba(0,0,255,.5);
        }
    
        .Footer p {
    
        font-family: telegraficoregular;
        color: white;
        font-style: italic;
        line-height: 80px;
        text-align: center;
    
        }
    <nav>
        <ul>
            <li>something</li>
            <li>something else</li>
        </ul>
    </nav>
    
    <footer class="Footer">
    This is a footer
    </footer>