当前位置:  开发笔记 > 前端 > 正文

如何为(8点星)css形状添加边框?

如何解决《如何为(8点星)css形状添加边框?》经验,为你挑选了2个好方法。

如何在这个8点星外面添加红色边框?或者有没有人知道的简单的svg解决方案?

IS: 在此输入图像描述 需要: 在此输入图像描述

JS小提琴

HTML

CSS

#star8 {
 border: 3px solid red;
 background: blue; width: 80px;
 height: 80px;
 position: relative;
 -webkit-transform: rotate(20deg);
 -moz-transform: rotate(20deg);
 -ms-transform: rotate(20deg);
 -o-transform: rotate(20eg);
 }
#star8:before {
 content: "";
 position: absolute;
 top: 0;
 left: 0;
 height: 80px;
 width: 80px;
 background: blue;
 -webkit-transform: rotate(135deg);
 -moz-transform: rotate(135deg);
 -ms-transform: rotate(135deg);
 -o-transform: rotate(135deg);
 }

G-Cyr.. 6

你可以使用mix-blend-mode,最后使用另一个伪:DEMO

#star8:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 80px;
  width: 80px;
  transform: rotate(135deg);
  box-shadow: 0 0 0 3px red;::* a border works too */
  mix-blend-mode:overlay;
}

#star8 {
  margin: 2em;
  border: 3px solid red;
  background: blue;
  width: 80px;
  height: 80px;
  position: relative;
  transform: rotate(20deg);
}

#star8:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 80px;
  width: 80px;
  background: blue;
  transform: rotate(135deg);
}

#star8:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 80px;
  width: 80px;
  transform: rotate(135deg);
  box-shadow: 0 0 0 3px red;
  mix-blend-mode:overlay;
}


没有mix-blend-mode,但z-index:after

#star8 {
  margin: 2em;
  border: 3px solid red;
  background: blue;
  width: 80px;
  height: 80px;
  position: relative;
  transform: rotate(20deg);
}

#star8:before {
  content: "";
  position: absolute;
  z-index:-1;
  top: 0;
  left: 0;
  height: 80px;
  width: 80px;
  background: blue;
  transform: rotate(135deg);
  box-shadow: 0 0 0 3px red;
}

#star8:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 80px;
  width: 80px;
  background: blue;
  transform: rotate(0deg);
}

你也可以只绘制部分bg (via linear-gradient)来隐藏不需要的边框部分,并在里面添加一些文字:http://codepen.io/gc-nomade/pen/KWNmqw



1> G-Cyr..:

你可以使用mix-blend-mode,最后使用另一个伪:DEMO

#star8:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 80px;
  width: 80px;
  transform: rotate(135deg);
  box-shadow: 0 0 0 3px red;::* a border works too */
  mix-blend-mode:overlay;
}

#star8 {
  margin: 2em;
  border: 3px solid red;
  background: blue;
  width: 80px;
  height: 80px;
  position: relative;
  transform: rotate(20deg);
}

#star8:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 80px;
  width: 80px;
  background: blue;
  transform: rotate(135deg);
}

#star8:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 80px;
  width: 80px;
  transform: rotate(135deg);
  box-shadow: 0 0 0 3px red;
  mix-blend-mode:overlay;
}


2> Persijn..:
SVG解决方案

这可以使用单个svg路径创建.添加轮廓可以通过向路径添加笔划属性来完成


  
推荐阅读
郑小蒜9299_941611_G
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有