我想在单击时将心形变为黑色,但更改 .heart 的颜色不会影响它的 :before :after 选择器。有什么办法吗?
.heart {
background-color: red;
height: 60px; /*dimension of the square*/
position: relative;
top: 40px; /*position from top*/
transform: rotate(-45deg); /*negative = counter clockwise, put 0 to try*/
width: 60px; /*dimension of the square*/
transition: all 1s ease; /*length of animation*/
}
.heart:before,
.heart:after {
content:""; /*kosong, for it to exist*/
background-color: red;
border-radius: 50%; /*perfect round curve*/
height: 60px; /*dimension of the shape*/
position: absolute;
width: 60px; /*dimension of the shape*/
}
.heart:before { …Run Code Online (Sandbox Code Playgroud) 我正在尝试了解此代码段如何使多级/嵌套数组扁平化
有人可以帮忙详细说明吗?谢谢
var flatten = function(a, shallow,r){
if(!r){ r = []} //what does the exclamation mark mean here?...
if (shallow) {
return r.concat.apply(r,a); //I can't find what's .apply for concat method
}
for(var i=0; i<a.length; i++){
if(a[i].constructor == Array){
flatten(a[i],shallow,r);
}else{
r.push(a[i]);
}
}
return r;
}
alert(flatten([1, [2], [3, [[4]]],[5,6]]));
Run Code Online (Sandbox Code Playgroud)