我有一个 if/else 语句在 scss 的 each 函数中运行。
如果背景等于白色,我基本上希望它使文本变黑
@debug 指令告诉我我的语句正确返回,但所有按钮在悬停时都以黑色文本颜色结束?我在这里错过了什么吗?
//variables
$brand-primary: #37a2c6 !default;
$brand-success: #39c66a !default;
$brand-info: #5bc0de !default;
$brand-warning: #f7901e !default;
$brand-danger: #e42829 !default;
$brand-haze: #9e50da !default;
$color-white: #ffffff;
$color-black: #232323;
//map
$colors: (
("danger", $brand-danger, $brand-success), ("warning", $brand-warning, $brand-haze), ("success", $brand-success, $brand-primary), ("primary", $brand-primary, $brand-success), ("haze", $brand-haze, $brand-warning), ("pure", $color-white, $color-black)
);
//function
@each $color in $colors {
.btn--hollow {
background: none !important;
&.btn-#{nth($color,1)} {
color: #{nth($color,2)} !important;
&:hover {
background: #{nth($color,2)} !important;
@if #{nth($color,2)} == '#ffffff' …
Run Code Online (Sandbox Code Playgroud) 当我按下键盘上的箭头键时,我发现了一个移动div的小提琴,但是每次都需要按下才能获得流畅的动作.
那么你如何像下面的例子一样移动一个div,但是按下箭头键呢?
http://jsfiddle.net/ambiguous/N5Ltt/2/
jQuery的
$(document).keydown(function(e) {
switch (e.which) {
case 37:
$('div').stop().animate({
left: '-=50'
}); //left arrow key
break;
case 38:
$('div').stop().animate({
top: '-=50'
}); //up arrow key
break;
case 39:
$('div').stop().animate({
left: '+=50'
}); //right arrow key
break;
case 40:
$('div').stop().animate({
top: '+=50'
}); //bottom arrow key
break;
}
});
Run Code Online (Sandbox Code Playgroud)
HTML
div{
background:#ccc;
height:100px;
width:100px;
position: absolute;
top: 0;
left: 0;
}
Run Code Online (Sandbox Code Playgroud)