微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

底部带有渐隐边框的圆圈

如何解决底部带有渐隐边框的圆圈

我正在尝试使用CSS(或SVG)绘制此输出。对我来说,最困难的部分是圆弧左侧和右侧的半弧。我应该坚持使用纯CSS还是使用图片更好?

感谢您的帮助...

Graphic with fadeout border on the bottom

这就是我设法做到的:

my design

这是代码

Sub PasteValues(ByVal Taregt As Range)
On Error GoTo ErrorHandler

If HasValidation(Range("DataValidationRange")) Then
        Exit Sub
    Else
        Application.Undo
        MsgBox "Error: You cannot paste data into these cells." & _
        "Please use the drop-down to enter data instead.",vbCritical
 If Application.ClipboardFormats(1) <> -1 Then
    If Application.CutcopyMode Then
        'Paste values,if in CutcopyMode
        Selection.PasteSpecial Paste:=xlPasteValues
        Application.CutcopyMode = False
    Else
        'Paste text,if from external source
        ActiveSheet.PasteSpecial Format:="Text"
    End If
End If
 End If
    GoTo FinishMacro

ErrorHandler:
    'Error will be caught,if there is nothing to paste
    Resume Next

FinishMacro:
End Sub
 
body {
  background-color: #002911 !important;
}

h3 {
  color: #ffd004;
}

#actions-container {
  margin-top: 30px;
}

#actions-container .action-icon {
  width: 200px;
  height: 200px;
  background-color: rgb(255,208,4);
  border-radius: 50%;
  Box-shadow: 5px -2px 6px 3px #0000004a;
  /* center contents*/
  display: flex;
  justify-content: center;
  align-items: center;
}

.right-arc {
  position: relative;
  display: inline-block;
  font-size: 30px;
  color: lightgreen;
  margin: 40px;
}

.right-arc::after {
  content: '';
  position: absolute;
  right: -150px;
  top: 57px;
  height: 300px;
  width: 300px;
  border-radius: 50% 50% 50% 50%;
  border-width: 0px 1px 0px 0px;
  border-style: solid;
  /*border-top: outset;*/
}


/*svg {
            width: 33%;
            height: auto;
        }*/

解决方法

您可以使用带有插入框阴影的伪元素在底部创建淡出边框,如下所示:

body {
  background: #232323;
}

.wrap {
  box-sizing: border-box;
  position: relative;
  width: 50%;
  border: 3px solid #ffd004;
  border-radius: 50%;
}

.wrap::before {
  content:'';
  display:block;
  padding-bottom:100%;
}

.wrap::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: -3px;
  right: -3px;
  height: 100%;
  z-index: 1;
  box-shadow: inset 0px -270px 70px -100px #232323;
}

.title {
  color: #ffd004;
  margin: 0;
  position: absolute;
  top: -3px;
  left: 0;
  width: 100%;
  text-align: center;
  z-index: 2;
  background: #232323;
}

.circle {
  position: absolute;
  top:15%;
  left:15%;
  width: 70%;
  height: 70%;
  border-radius: 50%;
  background: #ffd004;
  z-index: 2;
}
<div class="wrap">
  <h2 class="title">Title</h2>
  <div class="circle"></div>
</div>

请注意,这仅适用于纯色背景。如果您需要在渐变或图像上显示此图片,我强烈建议您使用SVG。

使用此答案中的“填充技术”来保持圆的纵横比:Maintain the aspect ratio of a div with CSS

,

如果需要透明度,可以使用线性渐变的mask-image

/* based on @web-tiki's implementation */
body {
  background: #232323;
}

.wrap {
  box-sizing: border-box;
  position: relative;
  width: 50%;
  padding: 60px;
}

/* the border */
.wrap::before {
  content:"";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 3px solid #ffd004;
  border-radius: 50%;
  -webkit-mask-image: linear-gradient(transparent 10%,black 10%,transparent 80% );
          mask-image: linear-gradient(transparent 10%,transparent 80% );
}

/* the circle */
.wrap::after {
  content:"";
  display:block;
  background: #ffd004;
  padding-top: 100%;
  border-radius: 50%;
  box-shadow: 6px 0px 10px black;
}

.title {
  color: #ffd004;
  margin: 0;
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  text-align: center;
}


body:hover {
  /* checkerboard pattern from https://stackoverflow.com/a/51054396/3702797 */
  background-image: /* tint image */
                    linear-gradient(to right,rgba(192,192,0.75),0.75)),/* checkered effect */
                    linear-gradient(to right,black 50%,white 50%),linear-gradient(to bottom,white 50%);
  background-blend-mode: normal,difference,normal;
  background-size: 2em 2em;
}
<div class="wrap">
  <h2 class="title">Title</h2>
</div>

,

尝试一下

body {
  background-color: #002911 !important;
}

h3 {
  color: #ffd004;
}

#actions-container {
  margin-top: 30px;
}

#actions-container .action-icon {
  width: 200px;
  height: 200px;
  background-color: rgb(255,208,4);
  border-radius: 50%;
  box-shadow: 5px -2px 6px 3px #0000004a;
  /* center contents*/
  display: flex;
  justify-content: center;
  align-items: center;
}
.action-icon-box{
  position: relative;
}
#actions-container .action-icon-box::after,#actions-container .action-icon-box::before{
  position: absolute;
  content: '';
  width: 300px;
  height:300px;
  border-radius: 50%;
  z-index:-1;
  top:0px;
  border: 2px solid;
  border-color:transparent;
}
#actions-container .action-icon-box::before{
  border-right-color: green;
  right: -60px;
}
#actions-container .action-icon-box::after{
  border-left-color: green;
  left: -60px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container" id="actions-container">
  <div class="d-flex justify-content-between">

    <div class="action-icon-box text-center ">
      <h3 class="text-center">Title</h3>

      <div class="p-1 action-icon text-center mt-4">
        <a href="#"><img class="center" src="/Content/images/lp-homepage/microphone.png" height="100" /></a>
      </div>
    </div>

  </div>
</div>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。