代码之家  ›  专栏  ›  技术社区  ›  Joe Consterdine

多个相同RGBA颜色不工作

  •  0
  • Joe Consterdine  · 技术社区  · 11 年前

    基本上,我想在三个不同的区域尝试使用相同的rgba值。我希望我的身体、导航和页脚都有rgba(0,0,0.8)。

    我的身体正常,但导航和页脚显示为纯黑色,没有透明度。。。

    我试过稍微改变一下透明度,这样它们就不同了,但这也不起作用。

    你只能使用一次吗?

    乔

    @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;
    
        }
    
    1 回复  |  直到 11 年前
        1
  •  0
  •   Patrick    11 年前

    所以,看起来好像是重叠导致了你的问题(见上面的评论)。我改变了导航和页脚的背景颜色,它们显示出来。

    事实上,你有两个80%不透明的元素重叠,结果看起来是黑色的。

        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>