html - 如何获取从右上角到左下角的渐变色

标签 html css

我正在尝试获取 css 渐变,如下面的 Bootstrap 图标所示。

logo

我只想从这段代码中得到两个解决方案。

1.)How to make gradient color as like in icon(From top right to bottom left)?

2.)Vertical alignment of text within div(Possibility without using flex property)

提前致谢:)

div{
  width:100px;
  height:100px;
  background: -webkit-linear-gradient(left, #2F2727, #1a82f7);
  border-radius:4px;
}
div p{
  color:white;
  text-align:center;
  text-transform:uppercase;
  font-weight:bold;
  font-size:42px;
}
<div>
 <p>
   b
 </p>
</div>

最佳答案

  1. 使用 to top right 关键字来引导渐变从左下角移动到右上角。
    背景:线性渐变(到右上角,#2F2727,#1a82f7);
  2. 使用 line-height 等于 height

有关 css 渐变的更多信息是 here .

div{
  width:100px;
  height:100px;
  background: linear-gradient(to top right, #2F2727, #1a82f7);
  border-radius:4px;
}
div p{
  color:white;
  text-align:center;
  text-transform:uppercase;
  font-weight:bold;
  font-size:42px;
  line-height: 100px;
}
<div>
 <p>
   b
 </p>
</div>

关于html - 如何获取从右上角到左下角的渐变色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41380985/

相关文章:

javascript - 在静态 html 页面中保存计数器

html - 具有负 z-index 的元素上的单击事件

html - 如何将 CSS 用于特定字符代码?

html - 将 CSS 应用于名称带数字的类

html - 使用 Foundation 自定义菜单

css - Angular Material slider 方向问题

html - 无法在按钮内移动文本

html - IE8 中没有边框半径,css3PIE 不工作?

css, li 全宽 ul

html - 滚动条未完全显示 Div 中的值