html - 你能有背景图片 : linear-gradient( to center. ..);

标签 html css

我有一个带有 background-image: linear-gradient( to bottom, red, blue); 的 div
但我想要 to bottom成为 to center但它不起作用。
赖特,现在看起来像这样
1
我希望它看起来像这样
2
有谁知道如何做到这一点请帮助我?

最佳答案

你展示的是一个经典的边框:

.box {
  border:40px solid blue;
  height:50px;
  width:50px;
  background:red;
}
<div class="box"></div>

但我怀疑您想要褪色,所以您想要的是 radial-gradient
.box {
  height:200px;
  width:200px;
  background:radial-gradient(farthest-side,red,blue);
}
<div class="box"></div>

或者像下面这样:

.box {
  height: 200px;
  width: 200px;
  background: linear-gradient(to right, blue, red, blue);
  position: relative;
}

.box::before {
  content: "";
  display: block;
  height: 100%;
  background: linear-gradient(blue, red, blue);
  clip-path: polygon(0 0, 100% 100%, 0 100%, 100% 0);
}
<div class="box"></div>

或者像这样:

.box {
  height: 200px;
  width: 200px;
  background: 
     linear-gradient(to top right   , red, blue) top right,
     linear-gradient(to top left    , red, blue) top left ,
     linear-gradient(to bottom left , red, blue) bottom left,
     linear-gradient(to bottom right, red, blue) bottom right;
  background-size:50% 50%;
  background-repeat:no-repeat;
}
<div class="box"></div>

还使用 box-shadow
.box {
  height: 200px;
  width: 200px;
  background: red;
  box-shadow: 0 0 50px 35px blue inset;
}
<div class="box"></div>

关于html - 你能有背景图片 : linear-gradient( to center. ..);,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65623383/

相关文章:

css - 右侧的 HTML/CSS : Boostrap3 div placement with 2 on left, 1

html - <div> 和 <section> 之间的确切区别是什么?就像我知道 Section 有 'meaning' 而 div 没有,但这是什么意思?

html - 在 iis 上托管基本的 html 站点

javascript - Colspan修改依赖CSS3 @media Query

php/jquery 缓冲区已满?页面未完全加载

javascript - 在 javascript 函数中包含 CSS 设置

javascript - 显示隐藏按钮时未内联

javascript - 将 div 从列表移动到另一个位置

javascript - MD Datepicker 在月历和年历模式中选择月和年后显示完整日期

jquery - 如何重叠多个div?