我的 HTML 看起来像这样:
<html>
<head>
<style>
.globalpopup {
margin: 0px;
padding: 2px;
position: absolute;
opacity: 1;
background: inherit;
}
</style>
</head>
<body>
<table class="globalpopup"><tr><td><span>!!</span></td></tr>
</table>
<div>This is a document. There's a ton of stuff here.
</body>
</html>
表格背景是透明的,即使其中文本(span 标签)的背景是不透明的。
如何在不设置背景颜色的情况下使表格完全不透明?任何地方都没有设置颜色;使用浏览器默认值。如果您认为您知道浏览器的默认设置是什么,那么您就不知道。
使用 JavaScript 从正文复制背景颜色没有帮助。 document.body.style.backgroundColor 是空字符串。
不久前有人问过类似的问题并得到了
background: inherit
的答案。这种情况有些不同,backgorund: inherit
不起作用。
根颜色可通过 Canvas 颜色值访问:
.globalpopup {
margin: 0px;
padding: 2px;
position: absolute;
opacity: 1;
background: Canvas;
}
<table class="globalpopup"><tr><td><span>!!</span></td></tr></table>
<div>This is a document. There's a ton of stuff here.