html - 如何创建双轮廓边框?

标签 html css reactjs

我正在使用 radium 在 JS 中编写我的 CSS,因此,我不能使用伪类 :after:before(这本来可以使解决方案非常简单)。我应该如何创建边框,如下图所示。

enter image description here

这里,灰色边框与主背景颜色相同,由白色边框分隔。

到目前为止我的 CSS 看起来像这样

upload: {
    position: "absolute",
    left: "0",
    top: "0",
    overflow: "hidden",
    width: "100%",
    height: "100%",
    borderRadius: "50%",
    backgroundColor: "#ccdde5",
    cursor: "pointer"
}

这将产生这样的输出

enter image description here

最佳答案

尝试使用嵌套的框阴影:

.circle-border-2 {
  border-radius: 50%;
  width: 200px;
  height: 200px; 
  margin: 10px;
  background-color: #ccdde5;
  box-shadow: 0 0 0 5px  white, 
              0 0 0 10px #ccdde5;
}
<div class="circle-border-2"></div>

这种方法甚至允许您添加多个边框:

.circle-unicorn {
  border-radius: 50%;
  width: 200px;
  height: 200px; 
  margin: 50px;
  background-color: white;
  box-shadow: 0 0 0 5px #9932FF, 
              0 0 0 10px #B231FD, 
              0 0 0 15px #FF31EB,
              0 0 0 20px #FF3291,
              0 0 0 25px #FE3030,
              0 0 0 30px #FE6031,
              0 0 0 35px #FFC132,
              0 0 0 40px #30FE5B,
              0 0 0 45px #5230FF,
              0 0 0 50px #3E25BF;
}
<div class="circle-unicorn"></div>

关于html - 如何创建双轮廓边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36451732/

相关文章:

html - 嵌套的 div 不会在框内创建框?

html - 自举井上方的标题导致未对齐

reactjs - 解析错误 : JSX value should be either an expression or a quoted JSX text

html - 我将如何重新排列 CSS 中内联 block 的顺序?

javascript - 当灯箱处于事件状态时使页面停止滚动

javascript - 仅使用 css 将按钮跨到对面

javascript - 绝对位置下的 Touchables 在 IOS 上不起作用,但在 Android 上运行良好

jquery - 在单个 http 请求中加载所有 css/js

html - 中心缩放动画css3

java - 如何在 React 应用程序中使用 Java 并使用 MySQL 作为数据库。有什么建议吗?