我有一个两列红色/黑色网格50/50%和高度100%,并有一个脚本,以便在加载页面时随机化两者的外观,所以左或右.我改变了两列网格后面的代码,从相对位置开始,向右浮动到固定绝对位置.这必须做,因为在移动时这种滚动行为这种方式更好.
下面的代码在使用浮动时工作正常,它向左或向右添加一个类,使得红色侧选择随机侧,黑色自动跟随,因为它是相对于彼此的.使用绝对和固定位置更改,它必须向左侧或右侧添加一个类才能工作.有人知道如何添加这个,所以当剩下红色时,黑色是正确的,反之亦然.
// Random red & black //
window.addEventListener('load', function() {
// This is a ternary operator, which is just a shorthand way to
// do an if/else statement. This basically says, if the random number
// is less than .5, assign "left" to the scenario variable.
// if it is greater (or equal to), assign "right" to the variable.
var scenario = Math.random() < .5 ? "left" : "right";
document.querySelector(".red", ).classList.add("" + scenario);
});
Run Code Online (Sandbox Code Playgroud)
.left {
left: 0;
} …
Run Code Online (Sandbox Code Playgroud)我从scroll event
方法开始这个问题,但是由于建议使用IntersectionObserver
似乎更好的方法,因此我试图以这种方式使其工作。
目标是什么:
我想改变风格(color
+ background-color
中的)header
这取决于电流div
/ section
通过查找(我在想的?),观察其class
或data
将覆盖默认header
样式(黑白色)。
标头样式:
font-color
:
根据内容(div
/ section
),默认值header
应该只能将font-color
变为两种可能的颜色:
background-color
:
根据内容的不同,background-color
颜色可能是无限的,也可能是透明的,因此最好将它们分开处理,这些可能是最常用的背景颜色:
CSS:
header {
position: fixed;
width: 100%;
top: 0;
line-height: 32px;
padding: 0 15px;
z-index: 5;
color: black; /* default */
background-color: white; /* default */
}
Run Code Online (Sandbox Code Playgroud)
默认标题的Div / section示例,内容无变化:
<div …
Run Code Online (Sandbox Code Playgroud) 我想在多个文件中查找和替换代码.
有谁知道Sublime Text 3中的"在多个文件中查找和替换"功能是否已经消失?
它曾经是ST2的一个功能(shift-command-F),见截图ST2和ST3.
或者还有其他方法可以做到这一点吗?
我好几次遇到这个,但我现在不知道究竟是什么?我认为它会覆盖一些东西,但我不确定.
.GridWrapper>* {
font-size: 14px
}
@media screen and (min-width:601px) {
.GridWrapper>* {
font-size: 17px
}
}
Run Code Online (Sandbox Code Playgroud)