我正在使用Bootstrap,它是水平形式的演示:
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="inputEmail1" class="col-lg-2 control-label">Email</label>
<div class="col-lg-10">
<input type="email" class="form-control" id="inputEmail1">
</div>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
但是我不想为每个创建ID <input>,所以
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="block">
<span class="col-lg-2 control-label">Email</span>
<div class="col-lg-10">
<input type="email" class="form-control">
</div>
</label>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
但display:block不能在里面display:inline,所以我用CSS
.block {
display: block;
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,但它是否正确?因为我听说我们不应该将display:block元素放入display:inline元素(label)
我想将多个模块合并到一个文件中,但我找不到关于如何操作的官方文档.现在我使用下面的方法,它的工作原理,但我想知道以下内容:
的index.html
<script src="require.js"></script>
<script>
requirejs.config({
paths: {
'a': 'test',
'b': 'test'
}
});
require(['a', 'b'], function () {
console.log('a & b loaded');
});
</script>
Run Code Online (Sandbox Code Playgroud)
test.js
console.log('loading test.js');
// I have some init here, like "Avoid `console` errors in IE"
define('a', function () {
console.log('a module');
});
define('b', function () {
console.log('b module');
});
Run Code Online (Sandbox Code Playgroud) loop { break } 可以正常工作,但是
block = Proc.new { break }
# or
# block = lambda { break }
loop(&block) # => LocalJumpError: break from proc-closure
Run Code Online (Sandbox Code Playgroud)
有可能break在一个block variable?
更新:
一个例子来解释更多:
def odd_loop
i = 1
loop do
yield i
i += 2
end
end
def even_loop
i = 2
loop do
yield i
i += 2
end
end
# This work
odd_loop do |i|
puts i
break if i > 10
end
# This doesn't …Run Code Online (Sandbox Code Playgroud) 我知道我可以检查是否jQuery UI的核心加载jQuery.ui,但如何检查,如果一个widget( draggable)被加载时,我使用的typeof($('something').draggable) == 'function',是没有更好的办法来做到这一点?
如果用户没有选择表单中的文件(等于PHP UPLOAD_ERR_NO_FILE
),request.files['file']还要返回一个FileStorage对象,我request.files['file'].filename == ''用来检查,还有更好的方法吗?我见过Flask Doc但找不到答案.
'file' in request.files 用户不会选择文件,浏览器也会提交0长度和文件名等于''(空字符串)部分.
如何检测上传文件只是部分上传错误(等于PHP UPLOAD_ERR_PARTIAL)?
这是基准
require 'benchmark'
# create random array
arr = 40000.times.map { rand(100000).to_s }
r1 = ''
r2 = ''
r3 = ''
Benchmark.bm do |x|
x.report {
r1 = (arr.map { |s|
"[#{s}]"
}).join
}
x.report {
r2 = arr.inject('') { |memo, s|
memo + "[#{s}]"
}
}
x.report {
r3 = ''
arr.each { |s|
r3 << "[#{s}]"
}
}
end
# confirm result is same
puts r1 == r2
puts r2 == r3
Run Code Online (Sandbox Code Playgroud)
这是结果
user system total real …Run Code Online (Sandbox Code Playgroud) 当将结果调整到 400px 以下时,@media not (min-width: 400px)不起作用,我知道我可以使用@media (max-width: 399px),但我想知道为什么不起作用
在Ruby 1.8中,retry可以使用如下:
for i in 0..4
puts i
retry if i == 4
end
Run Code Online (Sandbox Code Playgroud)
但是在Ruby 1.9中,它会抛出一个错误:无效的重试,retryRuby 1.9中的用法是什么?我retry在http://www.ruby-doc.org上找不到=(
ruby ×3
css ×2
benchmarking ×1
file-upload ×1
flask ×1
html ×1
javascript ×1
jquery ×1
jquery-ui ×1
python ×1
requirejs ×1