Ioa*_*a S 5 html css css3 css-shapes
我有一个问题,我想有一个圆角渐变边框,但显然border-radius不能使用border-image.
我附上了结果,我希望方形边框是圆的.
先谢谢你.
.luna-icon-wrap{
  float: right;
  padding: 5px 5px;
  -webkit-border-radius: 50% 50%;
  -moz-border-radius: 50% 50%;
  border-radius: 50% 50%;
  border: 2px solid transparent;
  -moz-border-image: -moz-linear-gradient(top, #3acfd5 0%, #3a4ed5 100%);
  -webkit-border-image: -webkit-linear-gradient(top, #3acfd5 0%, #3a4ed5 100%);
  border-image: linear-gradient(to bottom, #3acfd5 0%, #3a4ed5 100%);
  border-image-slice: 1;
}	
.luna-featbox2-icon{	
  width: 70px;
  height: 70px;
  text-align: center;
  -webkit-border-radius: 50% 50%;
  -moz-border-radius: 50% 50%;
  border-radius: 50% 50%;
  background: #43257f; /* For browsers that do not support gradients */
  background: -webkit-linear-gradient(left top, #43257f, #40c4ff); /* For Safari 5.1 to 6.0 */
  background: -o-linear-gradient(bottom right, #43257f, #40c4ff); /* For Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(bottom right, #43257f, #40c4ff); /* For Firefox 3.6 to 15 */
  background: linear-gradient(to bottom right, #43257f, #40c4ff); /* Standard syntax */
}<div class="luna-icon-wrap">
  <div class="luna-featbox2-icon">
    <i class="fa fa-diamond"></i>
  </div>
</div>我建议你用它SVG来创建这个形状.它提供简单性和可扩展性.
我们可以使用SVG's circle元素创建一个像上面这样的形状,并用一些纯色,渐变或图案填充/描边.
以下代码将创建圆形:
<circle cx="50" cy="50" r="39" fill="blue" />
以下是上述代码中使用的参数的简要说明:
cx定义x圆的位置.cy定义y圆的位置.r 定义圆的半径.要使用渐变填充闭合形状,我们需要创建一个渐变对象:
<defs>
    <linearGradient id="grad1" x1="1" y2="1">
      <stop offset="0" stop-color="#3acfd5" />
      <stop offset="1" stop-color="#3a4ed5" />
    </linearGradient>
</defs>
这个对象可以使用like 或者在形状中引用fill和stroke属性.和梯度的方向可通过其进行控制,,和属性.idfill="url(#grad1)stroke="url(#grad1)x1y1x2y2
输出图像:
工作实例:
<svg width="100" height="100" viewBox="0 0 100 100">
  <defs>
    <linearGradient id="grad1" x1="1" y2="1">
      <stop offset="0" stop-color="#3acfd5" />
      <stop offset="1" stop-color="#3a4ed5" />
    </linearGradient>
    <linearGradient id="grad2" y2="1">
      <stop offset="0" stop-color="#43257f" />
      <stop offset="1" stop-color="#40c4ff" />
    </linearGradient>
  </defs>
  <circle cx="50" cy="50" r="45" fill="none" stroke="url(#grad1)" stroke-width="2" />
  <circle cx="50" cy="50" r="39" fill="url(#grad2)" />
</svg>有用的资源:
以下是一些有用的链接SVG:
这可以通过 CSS 使用伪类(如:before.
遗憾的是,它的边框和圆圈本身之间没有透明部分,但如果您知道它始终位于某种彩色背景上,那应该不是问题。
.luna-icon-wrap{
  float: right;
  padding: 1px 1px;
  -webkit-border-radius: 50% 50%;
  -moz-border-radius: 50% 50%;
  border-radius: 50% 50%;
  border: 2px solid transparent;
  position: relative;
}	
.luna-icon-wrap:before {
content: '';
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: -2px;
  right: -2px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e5799 0%,#7db9e8 100%);
  z-index: -2;
}
.luna-featbox2-icon{	
  width: 70px;
  height: 70px;
  text-align: center;
  -webkit-border-radius: 50% 50%;
  -moz-border-radius: 50% 50%;
  border-radius: 50% 50%;
  border: 4px solid white;
  background: #43257f; /* For browsers that do not support gradients */
  background: -webkit-linear-gradient(left top, #43257f, #40c4ff); /* For Safari 5.1 to 6.0 */
  background: -o-linear-gradient(bottom right, #43257f, #40c4ff); /* For Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(bottom right, #43257f, #40c4ff); /* For Firefox 3.6 to 15 */
  background: linear-gradient(to bottom right, #43257f, #40c4ff); /* Standard syntax */
}<div class="luna-icon-wrap">
  <div class="luna-featbox2-icon">
    <i class="fa fa-diamond"></i>
  </div>
</div>| 归档时间: | 
 | 
| 查看次数: | 1304 次 | 
| 最近记录: |