直播页面在这里.
鉴于此HTML页面:
section[role=main] {
margin: 1em;
width: 95%;
border: 1px solid #999;
}
section[role=main] article {
width: 40%;
height: 180px;
margin: 1em;
display: inline-block;
border: 1px solid black;
}Run Code Online (Sandbox Code Playgroud)
<section role="main">
<article>Java</article>
<article></article>
</section>
<section role="main">
<article>Java</article>
<article>JavaScript</article>
</section>Run Code Online (Sandbox Code Playgroud)
我希望我的两篇文章都是一致的,但正如我在下面的截图中看到的那样,只有当我的两篇文章都有文本时,这些<article>元素才是中心对齐的:

是什么导致了这种行为,以及如何解决?
目前,如果books表没有created_at或updated_at字段,当前迁移可能会失败:
class AddTimestampIndexes < ActiveRecord::Migration
def up
remove_index :books, :created_at
remove_index :books, :updated_at
add_index :books, :created_at
add_index :books, :updated_at
end
def down
remove_index :books, :created_at
remove_index :books, :updated_at
end
end
Run Code Online (Sandbox Code Playgroud)
remove_index如果无法删除索引而不是引发错误,是否采取任何选项以静默方式继续?
我无法垂直对准文本的背景图像,而不会分配常数(因此,不自动和可重复使用)值height或line-height.我想知道是否有一种方法可以垂直居中对齐bg图像,例如和a元素, with its text without assigning constant values to线高度or`?
现场演示如下:http://cssdesk.com/8Jsx2.
这是HTML:
<a class="">background-position: center</a>
<a class="contain">background-size: contain</a>
<a class="line-height">Constant line-height</a>
Run Code Online (Sandbox Code Playgroud)
这是CSS:
a {
display: block;
margin: 10px;
width: 200px;
padding-left: 34px;
font-size: 14px;
background: url('http://cdn1.iconfinder.com/data/icons/freeapplication/png/24x24/Thumbs%20up.png');
background-repeat: no-repeat;
background-position: 5px center;
border: 1px solid black;
}
/* I don't want to use constant line-height */
.line-height {
line-height: 24px;
}
/* I don't want to use this, …Run Code Online (Sandbox Code Playgroud) 我使用CQ5原型创建了一个新的Maven项目,并将其导入IntelliJ IDEA.IntelliJ标记某些类的用法,例如org.apache.felix.annotations.Component,org.apache.felix.annotations.ReferenceIntellIJ与以下错误消息一样错误:
The package is not exported by the bundle dependencies
Run Code Online (Sandbox Code Playgroud)

引用规范:
块级框是参与块格式化上下文的框.每个块级元素生成一个主块级框,其中包含后代框和生成的内容,也是任何定位方案中涉及的框.除了主框:'list-item'元素之外,一些块级元素可能会生成其他框.这些附加盒子相对于主盒子放置.
它们基本上是一回事吗?
我是Apache Sling,CQ5等的新手.
在我们的代码库中,我们有一个类似于此的代码段:
void perform(SlingHttpServletRequest request, SlingHttpServletResponse response) {
ResourceResolver resourceResolver = request.getResourceResolver();
Session session = resourceResolver.adaptTo(Session.class);
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
}
Run Code Online (Sandbox Code Playgroud)
什么adapTo在这里做什么?
还有一个很好的文档/用户手册我可以阅读开始使用Sling,CQ5等?
假设我有一个这样的方法:
def foo
Rails.cache.fetch("cache_key", :expires_in => 60.minutes) do
return_something
end
end
Run Code Online (Sandbox Code Playgroud)
return_something有时会返回一个nil值。发生这种情况时,我不希望nil将该值缓存 60 分钟。相反,下次我调用 时,我希望再次执行传递foo给的块。fetch
默认情况下是Rails.cache.fetch这样工作的吗?或者我必须实现这个功能吗?
事实证明,答案是否定的,至少在使用 Memcached 时是这样。
这可能是由于边缘崩溃,我知道边缘折叠,至少它如何影响相邻元素,但我不明白当涉及负边距时它如何在嵌套元素上起作用.
例如,在此标记和随附的CSS中:
<div class="parent">
<div class="child">
Child 1
</div>
</div>
<div class="parent">
<div class="child negative">
Child 1
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
body {
background: white;
padding: 45px;
}
.parent {
border: 1px solid black;
margin-bottom: 10px;
}
.negative {
margin-bottom: -1px;
}
Run Code Online (Sandbox Code Playgroud)
这里有实例.
当我检查第二个.parentdiv 的高度时,我注意到它比第一个div小1个像素.发生这种情况是因为其.negative内部元素的负余量.我快速浏览了W3C,找不到这种行为的解释.
有人可以解释一下这里发生了什么,并为我提供了W3C规范部分的链接吗?
我使用这个CSS/HTML组合来模拟两列布局:
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div class="two-cols">
<div class="left-col">
<img src="http://stott.customer.netspace.net.au/images/aurora2.jpg" alt="Image"/>
</div>
<div class="right-col">
Text
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
.two-cols {
border: 1px solid black;
display: table;
width: 100%;
}
.left-col, .right-col {
display: table-cell;
width: 50%;
}
img {
width: 300px;
height: 200px;
padding: 0;
margin: 0;
}
Run Code Online (Sandbox Code Playgroud)
JSBin 在这里.
但是我的图像底部有一个不需要的填充:

任何想法为什么我得到那个,我怎么能摆脱它?
如果您查看Backbone.js的源代码,您会看到此模式的多种用法:
this.initialize.apply(this, arguments);
Run Code Online (Sandbox Code Playgroud)
例如,这里:
var Router = Backbone.Router = function(options) {
options || (options = {});
if (options.routes) this.routes = options.routes;
this._bindRoutes();
this.initialize.apply(this, arguments);
};
Run Code Online (Sandbox Code Playgroud)
为什么不写this.initialize(arguments)呢?