小编sta*_*y90的帖子

Mongoid标准不返回任何内容

我需要创建一个mongoid标准,它不会返回任何内容.我找不到任何"无"方法,所以我做的是Model.where(id:nil)或Model.any_in(id:nil).但是这不好,还会查询数据库.

我想将自己的选择器添加到mongoid,它将返回一个空结果,甚至不查询db(例如Model.none()),但不知道在哪里/如何做.有人可以帮忙吗?

注意:我需要这个,因为调用者可能会链接标准而不必知道它已经是空的.

ruby-on-rails mongoid

5
推荐指数
1
解决办法
1085
查看次数

文本与背景颜色混合

我正在尝试设计一个进度条,如下所示:

进步

左侧部分可以有不同的颜色(绿色、橙色等),我希望文本根据下面的背景改变颜色。理想情况下,浅灰色的右侧部分应为黑色/深灰色(如示例中所示),当左侧部分较亮时应为黑色/深灰色,当左侧部分较暗时应为白色(如示例中所示)。示例中为绿色)。

我尝试了各种mix-blend-mode: difference组合color,但无法实现这一目标。这里只是一个例子 我也尝试了一些东西filter: grayscale(1) contrast(9);

.container {
  width: 200px;
  height: 20px;
  position: relative;
  background-color: #eee;
  text-align: center;
}

.progress {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background-color: #43a047;
}

.text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  mix-blend-mode: difference;
  color: white;
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
  <div class="progress"></div>
  <div class="text">Some text here</div>
</div>
Run Code Online (Sandbox Code Playgroud)

css

2
推荐指数
1
解决办法
2045
查看次数

标签 统计

css ×1

mongoid ×1

ruby-on-rails ×1