我在几个元素上使用以下关键帧动画:
@keyframes redPulse {
from { background-color: #bc330d; box-shadow: 0 0 9px #333; }
50% { background-color: #e33100; box-shadow: 0 0 18px #e33100; }
to { background-color: #bc330d; box-shadow: 0 0 9px #333; }
}
@-webkit-keyframes redPulse {
from { background-color: #bc330d; box-shadow: 0 0 9px #333; }
50% { background-color: #e33100; box-shadow: 0 0 18px #e33100; }
to { background-color: #bc330d; box-shadow: 0 0 9px #333; }
}
.event_indicator {
display: inline-block;
background-color: red;
width: 5px;
margin-right: 5px;
-webkit-animation-name: …Run Code Online (Sandbox Code Playgroud) 请考虑以下代码:
for (var i=0; i<100; i++) {
// your code here
}
// some other code here
for (var i=0; i<500; i++) {
// custom code here
}
Run Code Online (Sandbox Code Playgroud)
任何体面的lint工具(jslint,jshint或内置的IDE)都会告诉警告 - duplicate declaration of variable i.这可以通过使用带有另一个名称(k,j)或将声明移到顶部的变量来解决:
var i; // iterator
for (i=0; i<100; i++) {}
for (i=0; i<500; i++) {}
Run Code Online (Sandbox Code Playgroud)
我不喜欢这两个变种-我不顶部做出的声明通常(即使我做了我不希望看到有辅助变量- ,i,j)k真的没什么不好在这些例子事情改变的变量'的名字.
虽然我确实想要一个巨大的警告,以防我写这样的东西:
for (var i=0; i<100; i++) {
for (var i=0; i<500; i++) {} // now that's bad
} …Run Code Online (Sandbox Code Playgroud) 我有一个简单的contenteditable div,里面有一些文字.在onkeyup事件上,我想基于正则表达式替换div的整个内容(innerHTML).
例如,
HTML:
some text, more text and $even more text
Run Code Online (Sandbox Code Playgroud)
函数我计划用$($甚至在上面的例子中)获取所有文本并将其包装在span标记中:
div.onkeypress = function() {
div.innerHTML.replace(/(some_regexp)/, "<span class='class'>$1</span>");
};
Run Code Online (Sandbox Code Playgroud)
问题是在这样的替换光标跳转到div的开头之后.我希望它能保持原状.
我想我必须在更改之前保存光标的坐标,然后以某种方式使用它们设置光标,但我该怎么办?:)
我尝试保存范围对象,但编辑后我相信它指向无处.
谢谢!
我想为我的html对象设置几个变换选项,但具有不同的持续时间和延迟.
如果我尝试使用这样的东西:
-webkit-transition: -webkit-transform, opacity;
-webkit-transform: rotate(180deg) scale(2);
-webkit-transition-duration: 2000ms, 6000ms;
-webkit-transition-delay: 0ms, 6000ms;
Run Code Online (Sandbox Code Playgroud)
那么我将有不同的时间函数用于变换和不透明度,但我可以设置不同的旋转和缩放选项,例如旋转10秒和缩放20秒?
我试图分裂以下(或类似)字符串"08-27-2015 07:25:00 AM".目前我用
var parts = date.split(/[^0-9a-zA-Z]+/g);
Run Code Online (Sandbox Code Playgroud)
结果如何
["02", "27", "2012", "03", "25", "00AM"]
Run Code Online (Sandbox Code Playgroud)
问题出在00AM零件上.我希望它也能分开.所以完美的结果将是:
["02", "27", "2012", "03", "25", "00", "AM"]
Run Code Online (Sandbox Code Playgroud) 在Ruby Koans的帮助下尝试Ruby .那里有以下测试:
def test_method_names_become_symbols
symbols_as_strings = Symbol.all_symbols.map { |x| x.to_s }
assert_equal __, symbols_as_strings.include?("test_method_names_become_symbols")
end
# THINK ABOUT IT:
#
# Why do we convert the list of symbols to strings and then compare
# against the string value rather than against symbols?
Run Code Online (Sandbox Code Playgroud)
我尝试在irb控制台中执行相同的操作,并返回false未定义的方法.但后来我在一些test.rb文件中尝试了相同的操作,true并返回到现有和未完成的方法.
示例代码:
def test_method
end
symbols = Symbol.all_symbols.map { |x| x }
puts symbols.include?(:test_method) # returns true in both cases
puts symbols.include?(:test_method_nonexistant) # returns false in irb, true …Run Code Online (Sandbox Code Playgroud) 请考虑以下情况:
<ParentView>
<FilterSubview></FilterSubview>
<ListSubview></ListSubview>
</ParentView>
Run Code Online (Sandbox Code Playgroud)
给你举个例子:我有一个视图,它反过来显示带过滤器的视图(用户可以选择显示书籍,杂志或两者)和带有项目的列表.过滤器和列表都有相应的型号.过滤 - 我们可以过滤什么.列表 - 所有项目的列表.
用例:用户可以看到完整列表,然后只需选择所需的类别即可过滤结果.
问题:
我读过一篇文章,建议使用ems单元使字体大小可扩展到移动开发:
html {
font-size: 16px; /* our base font size */
}
body {
font-size: 62.5%; /* now our em = 10px */
}
/* and for example we want to make h1 = 30 pixels */
h1 {
font-size: 3em; /* target / context = 30 / 10 = 3
}
/* quite ugly in some cases */
h3 {
font-size: 0.6666666em; /* want 20 pixels, context 30 = 20/30 = 0.(6) */
}
Run Code Online (Sandbox Code Playgroud)
这当然很酷.问题是 - 如果我们使用一些CSS预处理(SASS,LESS,custom),那么我们甚至可能不需要这样的方法并且可以直接使用变量:
$base-font: 10px; …Run Code Online (Sandbox Code Playgroud)