Mub*_*een 28 css svg border css3 css-shapes
我有一个css代码:
-moz-border-radius-topleft:50px;
Run Code Online (Sandbox Code Playgroud)
我得到了结果:
有没有可能这样给出:
Chr*_*ton 17
只是为了更新这个,似乎你可以通过多种方式.
HTML
<div><img src="https://s3.amazonaws.com/resized-images-new/23292454-E6CD-4F0F-B7DA-0EB46BC2E548" /></div>
Run Code Online (Sandbox Code Playgroud)
CSS
div {
width: 200px;
border-width: 55px;
-moz-border-image: url(http://i47.tinypic.com/2qxba03.png) 55 repeat;
-webkit-border-image: url(http://i47.tinypic.com/2qxba03.png) 55 repeat;
-o-border-image: url(http://i47.tinypic.com/2qxba03.png) 55 repeat;
border-image: url(http://i47.tinypic.com/2qxba03.png) 55 repeat;
margin: 50px auto;
}
Run Code Online (Sandbox Code Playgroud)
HTML
<div class="inner-round"></div>
Run Code Online (Sandbox Code Playgroud)
CSS
.inner-round {
background-image:
radial-gradient(circle at 0 0, rgba(204,0,0,0) 14px, #c00 15px),
radial-gradient(circle at 100% 0, rgba(204,0,0,0) 14px, #c00 15px),
radial-gradient(circle at 100% 100%, rgba(204,0,0,0) 14px, #c00 15px),
radial-gradient(circle at 0 100%, rgba(204,0,0,0) 14px, #c00 15px);
}
Run Code Online (Sandbox Code Playgroud)
Gaj*_*jus 16
在现代浏览器中,您可以使用mask-image
:
#aux-container {
width: 100px;
height: 100px;
background: #f00;
-webkit-mask-image: radial-gradient(circle 10px at 0 0, transparent 0, transparent 20px, black 21px);
}
Run Code Online (Sandbox Code Playgroud)
<div id="aux-container"></div>
Run Code Online (Sandbox Code Playgroud)
另外,请查看http://www.html5rocks.com/en/tutorials/masking/adobe/,其中介绍了如何使用获得类似结果mask-box-image
.
body{background:url('http://i.imgur.com/RECDV24.jpg');background-size:cover;}
svg{width:30%;}
Run Code Online (Sandbox Code Playgroud)
<svg viewbox="0 0 10 10">
<path d="M9 1 V9 H1 V3 Q3 3 3 1" fill="#fff"/>
</svg>
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我使用倒数圆边的三次贝塞尔曲线.
使用此方法,您还可以使用图像 或渐变填充形状:
body{background:url('http://i.imgur.com/RECDV24.jpg');background-size:cover;}
svg{width:30%;}
Run Code Online (Sandbox Code Playgroud)
<svg viewbox="0 0 10 6.7">
<defs>
<clipPath id="clip">
<path d="M9 1 V6.7 H1 V3 Q3 3 3 1" fill="#fff"/>
</clipPath>
</defs>
<image xlink:href="http://i.imgur.com/qi5FGET.jpg" x="0" y="0" height="6.7" width="10" clip-path="url(#clip)"/>
</svg>
Run Code Online (Sandbox Code Playgroud)
不幸的是,目前还没有基于官方或实施CSS规范的解决方案:(
但是,正如其他人已经添加的那样,有可能使用JS库或复杂的HTML/CSS实现来实现相同效果的解决方案(或作弊?).我在寻找一种方法来制作比OP更复杂的角而不使用图像时遇到了这个问题.
我已经在webkit网站上提交了一个错误(功能请求) - 因为似乎没有一个已经存档.
对于普通的背景颜色,您实际上可以使用伪元素和框阴影来绘制背景颜色,并且它不会隐藏父容器的背景,您将实际看到它们.
你需要的是一个理解的浏览器:before /:after和box-shadow :) ...
对于IE8,您可以绘制hudge边框而不是阴影.http://codepen.io/anon/pen/fFgDo
box-shadow方法:http://codepen.io/anon/pen/FwLnd
div {
margin:2em; /* keep it away from sides to see result */
padding:2em;/* for test to size it when empty */
position:relative; /* reference to set pseudo element where you wish */
overflow:hidden;/* you do not want the box-shadow all over the page */
}
div:before {
content:'';
position:absolute;
width:80px;
height:80px;
top:-40px;
left:-40px;
border-radius:100%;
box-shadow:0 0 0 2000px #1D005D;/* here draw the shadow inside its parent , maybe z-index will be required for content */
}
Run Code Online (Sandbox Code Playgroud)
伪元素可以采用任何形状,并通过css进行转换并设置其元素中的任何位置以绘制通孔:示例:http://codepen.io/gc-nomade/pen/nKAka
这可以通过径向渐变来完成。
div {
width: 20vw;
height: 20vw;
background: radial-gradient(circle at top left,transparent 4vw, darkblue 4.1vw);
}
Run Code Online (Sandbox Code Playgroud)
<div></div>
Run Code Online (Sandbox Code Playgroud)
只是为了好玩,可以通过定义多个背景来添加额外的倒角 - 每个角一个:
div {
width: 40vw;
height: 40vw;
position: relative;
background-color: darkblue;
--circle: radial-gradient(circle,white 8vw, darkblue 8.1vw);
}
div:before {
content: '';
position: absolute;
width: 100%;
height: 100%;
background-image: var(--circle), var(--circle), var(--circle), var(--circle);
background-size: 18vw 18vw;
background-position: -40% -40%, 140% -40%, -40% 140%, 140% 140%;
background-repeat: no-repeat;
}
Run Code Online (Sandbox Code Playgroud)
<div></div>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
36049 次 |
最近记录: |