Css 多个相同的RGBA颜色不起作用
基本上,我想尝试在三个不同的区域使用相同的rgba值。我希望我的身体、导航和页脚都有rgba0,0,0,8 我的身体工作,但导航和页脚只是显示纯黑色没有透明度 我尝试过稍微改变透明度,使它们不同,但这也不起作用 你只能用一次吗 乔Css 多个相同的RGBA颜色不起作用,css,background,rgba,Css,Background,Rgba,基本上,我想尝试在三个不同的区域使用相同的rgba值。我希望我的身体、导航和页脚都有rgba0,0,0,8 我的身体工作,但导航和页脚只是显示纯黑色没有透明度 我尝试过稍微改变透明度,使它们不同,但这也不起作用 你只能用一次吗 乔 所以,看起来似乎是重叠导致了您的问题,请参见上面的评论。我改变了导航和页脚的背景颜色,它们显示出来了 事实上,你有两个80%不透明度的元素重叠,结果看起来是黑色的 html、正文、标题、导航、文章、旁白、章节、h3、h4、页脚、ul、li{ 保证金:0; 填充:0;
所以,看起来似乎是重叠导致了您的问题,请参见上面的评论。我改变了导航和页脚的背景颜色,它们显示出来了 事实上,你有两个80%不透明度的元素重叠,结果看起来是黑色的 html、正文、标题、导航、文章、旁白、章节、h3、h4、页脚、ul、li{ 保证金:0; 填充:0; } /*全局样式*/ html{ 保证金:0; 填充:0; } 身体{ 宽度:100%; 保证金:0自动; 填充:0; 背景:rgba0,0,0,9; 字体系列:serif,arial,helvetica,georgia; 字体大小:16px; } h1{ 字体系列:telegraficoregular; 字号:3em; 颜色:RGB50153187; 填充:0; 保证金:0; 文本对齐:居中; } 氢{ 字体系列:telegraficoregular; 字号:1em; 字体:斜体; 颜色:003366; 填充:0; 保证金:0; 文本对齐:居中; } p{ 字体系列:衬线; 字体大小:1.1米; 颜色:黑色; 文本对齐:左对齐; 左侧填充:70px; } h4+p{ 字体系列:衬线; 字体大小:1.1米; 颜色:黑色; 文本对齐:左对齐; 左侧填充:70px; 填充顶部:10px; } /*导航样式*/ 标题{ 背景:RGB233233; 宽度:100%; 高度:160px; 保证金:0自动; } 导航{ 背景:rgba255,0,0,8; 宽度:自动; 高度:64px; } 导航ul.TopMenu li{ 浮动:左; 列表样式:无; 宽度:150px; } 导航ul.TopMenu{ 宽度:600px; 保证金:0自动; } 导航ul.TopMenu li a{ 显示:块; 线高:64px; 填充:0.2em; 文本对齐:居中; 字体系列:telegraficoregular; 字体大小:1.2米; 文字装饰:无; } 李{ 位置:相对位置; } 导航ul子菜单{ 浮动:无; 文本对齐:居中; 边框底部:1px纯白; 位置:绝对位置; 左:-9000em; 顶部:64px; 高度:自动; 最大高度:0; -moz过渡:最大高度0.5s缓进缓出; -webkit过渡:最大高度0.5s缓进缓出; -o型过渡:最大高度0.5s缓进缓出; 过渡:最大高度0.5s缓进缓出; 溢出:隐藏; z指数:999; } 导航ul子菜单li{ 高度:32px; 字体系列:telegraficoregular; 字号:1em; 填充:0; 保证金:0; 边框底部:1px纯白; } 导航ul子菜单li a{ 显示:块; 线高:32px; 填充:0px; 保证金:0; } .TopMenu li:悬停ul{ 左:0; 最大高度:20em; } ul.子菜单li a{ 背景:rgba0,0,0,8; 边框底部:1px纯白; } ul子菜单li a:已访问{ 颜色:白色; } ul.子菜单li a:悬停{ 背景:RGBA255165,0,8; } a:参观了{ 颜色:白色; } a:悬停{ 颜色:橙色; } /*文章风格*/ 文章{ 宽度:896px; 填充:32px; } /*剖面样式*/ 第三节中国{ 文本对齐:居中; 保证金:20px自动; 填充:20px; } 第h3节{ 字体系列:telegraficoregular; 字号:2em; 边框底部:1px纯黑; 填充物:5px; } 第h4节{ 字体系列:telegraficoregular; 字号:1.4em; 填充顶部:60px; 左侧填充:70px; 文本对齐:左对齐; 文字装饰:下划线; } 第三节中国国际货币基金组织{ 位置:相对位置; 顶部:20px; 边界半径:5px; } 第二节澳大利亚{ 文本对齐:居中; 保证金:20px自动; 填充:20px; } 第节澳大利亚img{ 位置:相对位置; 顶部:20px; 边界半径:5px; } 第二节泰国{ 文本对齐:居中; 保证金:20px自动; 填充:20px; } 第节泰国img{ 位置:相对位置; 顶部:20px; 边界半径:5px; } /*链接样式*/ /*关于风格*/ 关于内容{ 宽度:960px; 高度:1200px; 保证金:0自动; 填充:0; 背景:白色; 字体系列:serif,arial,helvetica,georgia; 字体大小:16px; 颜色:黑色; } 大约{ 文本对齐:居中; 保证金:20px自动; 填充:20px; } 关于下img{ 显示:块; 保证金:0自动; 文本对齐:居中; } 关于下h2{ 字体系列:telegraficoregular; 字号:1.5em; 文字装饰:下划线; 颜色:黑色; 填充:0; 边缘顶部:20px; 文本对齐:居中; } h2+img{ 位置:相对位置; 顶部:50px; 边界半径:5px; } 关于西德p{ 字体系列:衬线; 字体大小:1.1米; 颜色:黑色; 文本对齐:左对齐; 填充:50px 0 100px; } /*照片内容*/ 光含量{ 宽度:960px; 高度:自动; 保证金:0自动; 填充:0; 背景:白色; 字体系列:serif,arial,helvetica,georgia; 字体大小:16px; 颜色:黑色; } /*照片库*/ 中国照片{ 宽度:960px; 高度:1200px; 保证金:0自动; 填充:0; 背景:白色; 字体系列:serif,arial,helvetica,georgia; 字体大小:16px; 颜色:黑色; } 中国照片h3{ 字体系列:telegraficoregular; 字号:2em; 边框底部:1px纯黑; 填充物:5px; 文本对齐:居中; 边缘顶部:20px; } 中国图片img{ 边缘顶部:20px; 边框:1px纯黑; } 拇指:悬停{ 宽度:320px; 高度:240px; } /*容器样式*/ 内容{ 宽度:960px; 高度:自动; 保证金:0自动; 填充:0; 背景:白色; 字体系列:serif,arial,helvetica,georgia; 字体大小:16px; 颜色:黑色; } /*页脚样式*/ .页脚{ 宽度:100%; 高度:80px; 背景:rgba0,0255,5; } .页脚p{ 字体系列:telegraficoregular; 颜色:白色; 字体:斜体; 线高:80px; 文本对齐:居中; } 某物 别的 这是一个页脚
如果看不到html,很难判断,但元素可能重叠,因此颜色会变暗,因为它是加性的。重叠的两个不透明度为80%的元素将显示为黑色。尝试另一种完全不透明度的颜色进行调试。您肯定可以在多个元素上使用rgba。@Patrick-但它们并不仅仅是加在一起的。也就是说,将一个50%不透明的子对象放置在一个50%不透明的父对象上并不能得到100%不透明的结果。但是,如果与单个75%不透明元素的结果进行比较,结果是相同的。在2元素情况下,最终不透明度由parentOpacity+child_opacity*1-parentOpacity-或使用上图确定:0.5+0.5*1-0.5=0.5+0.5*0.5=0.5+0.25=0.75。如果我们对每个元素使用25%,则一个43.75%的不透明元素是相同的。即0.25+0.25*1-0.25=0.25+0.25*0.75=0.25+0.1875=0。4375@enhzflep哈哈,是的。为了解释清楚,我很简单。他想知道为什么会发生这种情况,所以我给出了最容易理解的答案,尽管技术上并不准确。谢谢你的澄清。@Patrick-谢谢你让我进一步思考和调查是的,似乎是这样!我将导航和页脚设置为透明度“.1”,这似乎足够体面了!还有其他解决办法吗?谢谢您有两个选项,可以使用元素的固定或绝对位置来避免堆叠,而不是设置实体样式。
@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;
}