html - 淘汰赛文本混合模式不适用于
问题描述
我正在尝试创建一个带有剔除文本的导航栏。我已经使用<div>
带有<p>
内部的 a 测试了这段代码,并让它正常工作。但是,当我尝试<nav>
使用相同的技术设置元素的样式时,文本保持黑色而不是透明。
HTML:
<body>
<nav class="flex-row">
<a class="flex-center" href="index.html" class="logo"><img src="images/logo-no-bkg.png" style="height:15vh;"></a>
<a class="flex-center" href="about.html">about</a>
<a class="flex-center" href="team.html">team</a>
<a class="flex-center" href="services.html">services</a>
<a class="flex-center" href="contact.html">contact</a>
</nav>
<div class="background">
<div class="text flex-center">TEST</p>
</div>
</body>
CSS:
body {
width: 100vw;
height: 100vh;
background-image: url("../images/nyc.jpeg");
background-position: top;
background-size: cover;
}
nav {
justify-content: space-around;
color: black;
background: rgba(255,255,255,0.5);
mix-blend-mode: screen;
}
nav a {
height: 20vh;
width: 20vw;
font-family: 'Bebas Neue', cursive;
font-size: 50px;
align-self: stretch;
position: relative;
text-align: center;
}
.background {
width: 100vw;
height: 100vh;
background-image: url('../images/nyc.jpeg');
}
.text {
height: 100%;
margin: 10px solid;
font-family: 'Bebas Neue', cursive;
font-size: 400px;
color: black;
background: rgba(255,255,255,0.5);
mix-blend-mode: screen;
}
这是<nav>
条形图和我的 test的图像<div>
,<div>
正常工作而<nav>
条形图不工作:
解决方案
无论出于何种原因,它都不喜欢您使用您的<body>
元素来尝试执行此操作。将所有内容包装<body>
在一个单独的<div class="background-2">
部门中,并对其应用与正文完全相同的样式似乎可以解决问题:
.background-2 {
width: 100vw;
height: 100vh;
/* background-image: url("../images/nyc.jpeg"); */
background-image: url("https://via.placeholder.com/200/f00");
background-position: top;
background-size: cover;
}
nav {
justify-content: space-around;
color: black;
background: rgba(255,255,255,0.5);
mix-blend-mode: screen;
}
nav a {
height: 20vh;
width: 20vw;
font-family: 'Bebas Neue', cursive;
font-size: 50px;
align-self: stretch;
position: relative;
text-align: center;
color:black;
}
.background {
width: 100vw;
height: 100vh;
/* background-image: url("../images/nyc.jpeg"); */
background-image: url("https://via.placeholder.com/200/0f0");
}
.text {
height: 100%;
margin: 10px solid;
font-family: 'Bebas Neue', cursive;
font-size: 400px;
color: black;
background: rgba(255,255,255,0.5);
mix-blend-mode: screen;
}
<body>
<div class="background-2">
<nav class="flex-row">
<!-- <a class="flex-center" href="index.html" class="logo"><img src="images/logo-no-bkg.png" style="height:15vh;"></a> -->
<a class="flex-center" href="index.html" class="logo">
<img src="https://via.placeholder.com/200/000" style="height:15vh;">
</a>
<a class="flex-center" href="about.html">about</a>
<a class="flex-center" href="team.html">team</a>
<a class="flex-center" href="services.html">services</a>
<a class="flex-center" href="contact.html">contact</a>
</nav>
<div class="background">
<div class="text flex-center">TEST</p>
</div>
</div>
</body>
在全页模式下运行和查看代码片段以清楚地看到它。
推荐阅读
- android - 想要创建一个应用程序,它在中心垂直和水平显示 3 个按钮,但是当我尝试时只有第 3 个按钮在那里,
- javascript - 尽管将 Cors 与 Axios 一起使用,我仍然收到此错误:请求的资源上不存在“Access-Control-Allow-Origin”标头
- c++ - 使用“scanf”切换函数有一个奇怪的返回
- python - 如何仅使用上述/滞后值在 Pandas 中进行插值?
- html - CSS 布局,页眉,页脚,2 列,固定 100% 高度 - 计算机上没有垂直窗口滚动(设计器 GUI 布局)
- cplex - 是否可以使用 OPL 简化表达式?
- java - 以编程方式将 POST 二进制内容设置为 Jmeter 中的 HTTP 采样器
- c++ - 这是插入排序的正确实现吗?
- r - 将 for 循环生成的多个 ggplots 放入一个图像中
- javascript - 我在控制台中有此错误:$(...).datepicker 不是函数