[英]How to get the gradient color from top right to bottom left corner
I have trying to get the css
gradient as like in the below bootstrap icon. 我试图获得css
渐变,就像下面的bootstrap图标一样。
I just want two solutions from this code. 我只想要这个代码中的两个解决方案。
1.)How to make gradient color as like in icon(From top right to bottom left)? 1.)如何像图标一样制作渐变色(从右上角到左下角)?
2.)Vertical alignment of text within div(Possibility without using flex property) 2.)div内文本的垂直对齐(不使用flex属性的可能性)
Thanks in advance :) 提前致谢 :)
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>
to top right
keyword for directing gradient to move from bottom left corner to top right corner. 使用to top right
关键字来指示渐变从左下角移动到右上角。 background: linear-gradient(to top right, #2F2727, #1a82f7);
line-height
equal to height
. 使用等于height
line-height
height
。 More Information about css gradient is here . 有关css渐变的更多信息,请点击此处 。
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>
try this: 试试这个:
div {
background: -webkit-linear-gradient(45deg, #2F2727, #1a82f7);
}
You should use radial gradient positioning - top right
for this, like: 您应该使用径向渐变定位 - top right
,例如:
background: linear-gradient(
to top right,
#0F0437, #612D50
);
Have a look at the snippet below: 看看下面的代码:
.box { display: inline-block; padding: 50px 70px; font-size: 100px; border-radius: 20px; color: white; background: linear-gradient( to top right, #0F0437, #612D50 ); }
<div class="box">B</div>
Hope this helps! 希望这可以帮助!
Use to top right
for a diagonal angle (alternatively 45deg
), and line-height
equivalent to your height
value to vertically center the letter. 使用to top right
的对角(或者45deg
)和line-height
相当于你的height
值垂直居中信。
Here it is with colors sampled from your image: 这是从您的图像中采样的颜色:
div { background: linear-gradient(to top right, #080135 0%, #612d50 100%); width: 100px; height: 100px; border-radius: 4px; color: white; font-family: sans-serif; text-align: center; font-weight: bold; font-size: 60px; line-height: 100px; }
<div>B</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.