html - 带有彩色标题的线性渐变的背景图像在移动浏览器上不起作用
问题描述
我正在尝试制作彩色标题,但它不适用于移动浏览器(标题不可见)。有人知道为什么会这样吗?非常感谢。
也许应该是因为我那里有其他代码。
来自 Next.Js 的 HTML
<div className={indexStyles.sliderWrapper}>
<div className="container">
<div className={indexStyles.sliderText}>
<h1>Autoslavkov</h1>
<ul>
<li>Autočalounictví</li>
<li>Autorizovaný chiptuning</li>
<li>Auto klimatizace</li>
<li>Renovace světel</li>
</ul>
</div>
</div>
<Image
src="/images/slid1.jpg"
alt=""
layout="fill"
objectFit="cover"
/>
</div>
和 CSS
.sliderWrapper{
width: 100%;
position: relative;
min-height: calc(100vh - var(--header-height) - var(--navInfo-height));
background-color: black;
overflow: hidden;
}
.sliderWrapper::after{
content: "";
position: absolute;
top:0;
left:0;
right: 0;
bottom: 0;
background-color: rgba(0,0,0,0.35);
}
.sliderText{
position: relative;
z-index: 1;
margin: 65px 0 50px;
font-family: 'Open Sans Bold', sans-serif;
}
.sliderText h1{
--hColor1: #bf1717;
--hColor2: #E73636;
background-image: -webkit-linear-gradient(to top, var(--hColor1), var(--hColor2) 50%, var(--hColor1));
background-image: linear-gradient(to top, var(--hColor1), var(--hColor2) 50%, var(--hColor1));
font-size: 30pt;
-webkit-text-fill-color: transparent;
background-clip: text;
-webkit-background-clip: text;
text-align: center;
padding: 5px;
}
.sliderText h1::after{
content: "";
display: block;
height: 3px;
width: 80px;
margin: 0 auto;
background-color: var(--hColor1);
}
这是它在电脑上的样子:
这里是它在移动设备上的样子:
解决方案
所以我发现该h1::after
物业正在这样做,但我不知道为什么。我将其更改为position:absolute
然后将其居中使用left:50%;
,transform: translateX(-50%);
现在它工作正常。
推荐阅读
- oop - 如何使用 OCAML 以函数式编程概念对我的游戏项目进行建模?
- database - (Laravel)在 DB::raw 中获取当前日期和给定日期的差异
- ios - 从 Swift 将视频上传到 Amazon S3
- html - 可访问性如何对评级组件起作用?
- excel - 无论我的 pivotItems 的值/更改如何,都将 Pivot 字段“公司代码”始终设置为 True(可见)
- android - Android 库活动应该以自己的主题独立打开
- javascript - Javascript:什么是回调?
- java - 无法使用 Lettuce 连接到本地 Redis 集群
- javascript - 如何使用 flatlist 集成 react-native-swiper
- c# - 如何在子级没有导航属性的情况下映射父级=>子级