javascript - 我想为这个径向渐变和 div 生成边框

标签 javascript jquery html css

这是我的代码。

div {
  height: 150px;
  margin: 5em 2em;
  background: radial-gradient(circle at top center, transparent, transparent 70px, black 70px, black);
  border-radius: 8p## Heading ##x;
  position: relative;
}

.circle {
  width: 120px;
  height: 120px;
  background: red;
  border-radius: 50%;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
}

body {
  background-image: url(http://www.fillmurray.com/1000/1000);
  background-size: cover;
}
<div>
  <span class="circle"></span>
</div>

<!--  this creates the cut in a div placing a circle on the cut and i need to put a border for the whole div even in the cut part of div.  -->

最佳答案

你的意思是这样的吗?

div {
  height: 150px;
  margin: 5em 2em;
  background: radial-gradient(circle at top center, transparent, green 70px, black 70px, black);
  border-radius: 8p## Heading ##x;
  position: relative;
  border: 10px solid green;
}

.circle {
  width: 120px;
  height: 120px;
  background: red;
  border-radius: 50%;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
}

body {
  background-image: url(http://www.fillmurray.com/1000/1000);
  background-size: cover;
}
<div>
  <span class="circle"></span>
</div>

<!--  this creates the cut in a div placing a circle on the cut and i need to put a border for the whole div even in the cut part of div.  -->

关于javascript - 我想为这个径向渐变和 div 生成边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42497281/

相关文章:

c# - 使用 WPF 在 C# 中静默打印 HTML 文件

javascript - javascript中函数的含义是什么?

javascript - 如何在事件处理程序中访问变量 "this"

JavaScript - 将 PDF 文件从 URL(跨域)加载到变量中

javascript - 在新窗口中提交表单并重定向当前页面在 Chrome 中不起作用

javascript - HTML - 来自一个 div 的子元素覆盖另一个 div

javascript - 如何在选项卡中创建幻灯片

javascript - JQUERY,需要不支持 IE6 的警告用户

php - 使用其他选择框更改选择框值

javascript - 我可以在 JS 对象中设置文本样式吗?