【问题标题】:SVG path to border radius [closed]SVG路径到边界半径[关闭]
【发布时间】:2015-02-07 10:46:16
【问题描述】:

是否可以仅使用 CSS 边框半径制作这样的形状http://grab.by/Efqk?

这是小提琴:http://jsfiddle.net/9tjgof09/

.avatars {
    padding: 50px;
    overflow: hidden;
    list-style: none;
}

.avatars strong {
    display: block;
}
.avatars li {
    float: left;
    width: 100px;
    margin-right: 40px;
}

.avatar {
    position: relative;
    width: 100px;
    height: 100px;
    overflow: hidden;
}

.avatars img {
    width: 100%;
    height: 100%;
    vertical-align: top;
}

.avatar-border {
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 100px;
}

.avatar-css img {
    border-radius: 25px/25px;
}

【问题讨论】:

  • 是的,你试过什么?请提供您尝试的代码。你知道border-radius 有多个值,对吧? MDN Border-radius
  • 这是我目前拥有的(包括 SVG 代码)jsfiddle.net/9tjgof09

标签: html css svg css-shapes


【解决方案1】:

你可以用 css 做各种形状,看看我放在你底部的头像,第一个长度到边界半径是水平,第二个垂直。 fiddle

#myAvatar{
    border-top-left-radius:5px 25px;
    border-top-right-radius:20px 55px;
    border-bottom-left-radius:30px 25px;
    border-bottom-right-radius: 50px 25px;
}
 <img id="myAvatar" src="http://lorempixel.com/100/100" />

【讨论】:

  • 看起来不一样
【解决方案2】:

这是可能的,但您需要使用的不仅仅是边界半径。这是一个例子:

fiddle link

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

【讨论】:

猜你喜欢
  • 2019-02-04
  • 1970-01-01
  • 1970-01-01
  • 2012-09-06
  • 2014-04-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多