javascript - 隐藏标题后面的所有文本透明但不是图像
问题描述
你好 !
我需要你的帮助来隐藏 透明标题后面的所有 文本 (示例)原因不可读..图像不是问题,但只有文本..我想保持标题透明..float-menu.container{background :rgba(255, 255, 255, 0.4);
我找不到解决办法。。
谢谢你..!
#myHeader {
width: 100%;
text-align: center;
background: rgba(255, 255, 255, 0.4);
position: fixed;
height: 50px;
top: 150px;
}
body {
height: 2000px;
background: red;
}
#paragraf {
padding-top: 200px;
}
<body>
<div id="myHeader">
This is my header element.
</div>
<p id="paragraf"><b>Note:</b> I want to hide all text</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
</body>
解决方案
对您的 CSS 和 HTML 进行了一些更改:
- 添加了一个带有
.wrapper
类的 div 并将所有 p 标签移入其中。 - 然后将此 CSS 样式添加到包装器中:
.wrapper {
position: absolute;
top: 50px;
overflow: scroll;
max-height: calc(100vh - 50px);
}
解释:
- 将绝对位置添加到包装器并设置
top: 50px
(header 的高度,以便它们不会相互重叠。 - 溢出设置为滚动,这样 p 标签内容在标题后面将不可见。
- 并且 max-height 设置为
calc(100vh - 50px)
,从整个视口高度(100vh)中减去 50px(标题高度)
我相信这就是您正在寻找的:
#myHeader {
width: 100%;
text-align: center;
background: rgba(255, 255, 255, 0.4);
position: fixed;
height: 50px;
top: 0;
}
body {
background: red;
margin: 0;
}
.wrapper {
position: absolute;
top: 50px;
overflow: scroll;
max-height: calc(100vh - 50px);
}
<body>
<div id="myHeader">
This is my header element.
</div>
<div class="wrapper">
<p id="paragraf"><b>Note:</b> I want to hide all text</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
<p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
</div>
</body>
推荐阅读
- java - 将最后一个 Maven SNAPSHOT 保留在存储库中吗?
- date - 如何判断 DateTime.Now() 是否在不同 DateTime 之后的一天
- react-native - 反应原生嵌套导航
- python - 使用 Matplotlib 预计算交互式图形的动画
- c - C:如何检查内存地址是否已写入?
- arrays - Marshal 一个 JSON Marshal 兼容映射到 XML
- php - MongoDB 在单个请求中使用 $in 2 次
- mysql - 无法在 PHP My Admin 中使用事件调度程序,如何为 cron 制作 PHP 文件?
- arrays - 如何转换 Hive 数组
在导出数据时键入 Vertica varchar - html - Safari 浏览器中的“高度:内在”是什么?