html - 制作 CSS 形状

标签 html css css-shapes

我试图制作这样的 CSS 形状 this icon .我需要精确制作附图中显示的形状。怎么做这个? 请帮忙。

fiddle 链接 link

CSS

#activityIcon {
  position: relative;
  width: 200px;
  height: 150px;
  margin: 20px 0;
  background: red;
  border-radius: 50% / 10%;
  color: white;
  text-align: center;
  text-indent: .1em;
}
#activityIcon:before {
  content: '';
  position: absolute;
  top: 10%;
  bottom: 10%;
  right: -5%;
  left: -5%;
  background: inherit;
  border-radius: 5% / 50%;
}

最佳答案

试试这个:

UPDATE...

enter image description here

标记:

<div id="activityIcon">
    <div class=concaveTop></div>
    &utrif;
</div>

风格:

#activityIcon {
    position: relative;
    width: 200px;
    height: 100px;
    background:#757575;
    border-radius: 0 0 30px 30px;
    margin:40px auto;
    color: #ccc;
    font-size: 6em;
    text-align: center;
    line-height: 100px;
}
#activityIcon:before,#activityIcon:after{
    content: '';
    position: absolute;
    width:0;
    height:0;
}
#activityIcon:before{
    border-left: 20px solid transparent;
    border-top: 81px solid #757575;
    left: -18px;
}
#activityIcon:after {
    border-right: 20px solid transparent;
    border-top: 81px solid #757575;
    right: -18px;
}
.concaveTop:before, .concaveTop:after{
    content: '';
    position: absolute;
    width: 34px;
    height: 32px;
}
.concaveTop{
    position: absolute;
    top: 0;
    width: 314px;
    height: 28px;
    left: -50px;
    overflow: hidden;
    box-shadow: 0 -4px 0 #757575;
}

.concaveTop:before{
    left: 1px;
    box-shadow: 20px -24px 0 3px #757575;
    border-radius: 50%;
}
.concaveTop:after{
    right: 15px;
    box-shadow: -18px -24px 0 3px #757575;
    border-radius: 50%;
    z-index: 1;
}

DEMO

标记:

<div id="activityIcon">
    &utrif;
</div>

风格:

#activityIcon {
    position: relative;
    width: 200px;
    height: 100px;
    background:#333;
    border-radius: 0 0 30px 30px;
    margin:40px auto;
    color: #ccc;
    font-size: 6em;
    text-align: center;
    line-height: 100px;
}
#activityIcon:before,#activityIcon:after {
    content: '';
    position: absolute;
    width:0;
    height:0;
}
#activityIcon:before{
    border-left: 20px solid transparent;
    border-top: 81px solid #333;
    left: -18px;
}
#activityIcon:after {
    border-right: 20px solid transparent;
    border-top: 81px solid #333;
    right: -18px;
}

enter image description here

关于html - 制作 CSS 形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25728823/

相关文章:

javascript - 尝试使用 javascript + html 返回上一页

javascript - 增加单选按钮的大小

php - 不想使用 strip_tags() 删除 CDATA

Internet Explorer (IE) 中的 JQuery 圆 Angular 搞砸了

html - 标题用线条填充两边的剩余空间

css - 具有 flex 边和尖 Angular 的矩形

html - CSS:页面底部而不是窗口的位置元素

jquery - 如何在angularjs中通过点击显示句子的隐藏内容

css - 如何修改 CSS heart 以插入图像?

html - float :left insive li in Chrome