Mac*_*ach 20 css css3 css-shapes
我一直在玩CSS很短的时间,我试图有一个正常的盒子,但左上角切成45度角.也不少; 我正在看那个角度的一个很大的角落.这个效果:

我该怎么办呢?
Ray*_*oal 20
Slantastic(http://meyerweb.com/eric/css/edge/slantastic/demo.html)支持旧浏览器.对于CSS3特定的,请尝试CSS多边形:http://alastairc.ac/2007/02/dissecting-css-polygons/.
HTML:
<div class="cornered"></div>
<div class="main">Hello</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.cornered {
width: 160px;
height: 0px;
border-bottom: 40px solid red;
border-right: 40px solid white;
}
.main {
width: 200px;
height: 200px;
background-color: red;
}
Run Code Online (Sandbox Code Playgroud)
在边框部分使用透明边框和文字... HTML:
<div class="outer">
<div class="cornered">It's possible to put text up here, too
but if you want it to follow the slant you have to stack
several of these.</div>
<div class="main">Hello hello hello hello
hello hello hello hello hello</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.outer {
background-color: #ccffff;
padding: 10px;
font-size: x-small;
}
.cornered {
width: 176px;
height: 0px;
border-bottom: 40px solid red;
border-left: 40px solid transparent;
}
.main {
width: 200px;
height: 200px;
background-color: red;
padding: 0 8px;
}
Run Code Online (Sandbox Code Playgroud)
结果:http://jsfiddle.net/76EUw/2
JBE*_*JBE 10
这可以使用svg来完成clip-path.
好处:
以下CSS将塑造div的右下角切断,以便您可以放置任何背景:
-webkit-clip-path: polygon(100% 0, 100% 65%, 54% 100%, 0 100%, 0 0);
clip-path: polygon(100% 0, 100% 65%, 54% 100%, 0 100%, 0 0);
Run Code Online (Sandbox Code Playgroud)
在线有多个SVG生成器: