【发布时间】:2019-08-28 20:27:45
【问题描述】:
我正在开发一个需要为投资组合项目提供整页滚动快照的网站。我得到了 snap-scroll 和 HTML smooth-scroll 设置并且工作正常。然后,我在 HTML 中添加了指向 Google 字体的链接,并在 CSS 中为该字体设置了一些文本。字体按预期显示,但似乎禁用了滚动捕捉行为。
我尝试了多种 Google 字体,每次都得到相同的结果。似乎只有在正确安装字体时才会禁用滚动捕捉。
HTML...
<link href="https://fonts.googleapis.com/css?family=IBM+Plex+Sans:100" rel="stylesheet">
<link rel="stylesheet" type="text/css" media="screen" href="assets/css/style.css">
CSS 下面...
body{
scroll-snap-type: y mandatory;
color: #222;
}
.tech-list-header {
font-size: 1.333em;
font-family: 'IBM Plex Sans';
}
#bgimg-1, #bgimg-2, #bgimg-3, #bgimg-4, #bgimg-5 {
/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
/* background-repeat: no-repeat; */
background-size: cover;
margin: 0px -10px;
position: relative;
min-height: 90vh;
scroll-snap-align: start;
scroll-snap-stop: normal;
}
似乎我应该能够同时使用 Google 字体和 Scroll-Snap,但我一次只能使用一个……有什么想法吗?谢谢!
【问题讨论】:
-
我也遇到过这个,看起来很奇怪。它似乎也发生在 Chrome 和 Firefox 中,在我看来,这似乎是 Google 字体的问题,而不是浏览器错误。对 Google Fonts 的调用只是一个简短的样式表,其中似乎没有任何与滚动捕捉冲突的内容。
标签: css scroll google-fonts