【问题标题】:blurred linear gradient background to solid color Css模糊的线性渐变背景到纯色 Css
【发布时间】:2018-03-21 19:50:18
【问题描述】:

我想在 div 中设置一个左灰线背景以显示这是一个线程......就像在 twitter 中一样。

我几乎明白了,但这条线看起来很模糊。我如何使它坚固?

.thread {
  height: 100px;
  width: 400px;
  border: 1px solid red;
}

.thread {
  background: linear-gradient(to right, 
      transparent 0%, 
      transparent calc(25px - 2px), 
      #E9EBEE calc(25px - 2px), 
      #E9EBEE calc(25px + 2px), 
      transparent calc(25px + 2px), 
      transparent 100%);
}
<div class="thread"></div>

【问题讨论】:

  • 我只是不知道如何用像这样的最少代码在该位置分配一条 2px 实线..你有什么想法吗?

标签: html css linear-gradients


【解决方案1】:

改为这样做:

.thread {
  height: 100px;
  width: 400px;
  border: 1px solid red;
}

.thread {
  background:linear-gradient(#E9EBEE,#E9EBEE) 25px 0/4px 100% no-repeat;
  /* OR
  background-image:linear-gradient(#E9EBEE,#E9EBEE);
  background-size:4px 100%;
  background-position:25px 0;
  background-repeat:no-repeat;
  */
}
<div class="thread"></div>

【讨论】:

  • 这太棒了。这是什么意思? 0/4px 谢谢。
  • @joe 我添加了更多细节;)/ 是大小和位置之间的分隔
猜你喜欢
  • 2013-07-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多