我使用 CSS 的时间很短,我正在尝试制作一个普通的盒子,但左上角以 45 度角切掉。数额也不小;我正在看那个角度的一个相当大的切角。这个效果:
我该怎么办?
描述
倾斜(http://meyerweb.com/eric/css/edge/slantastic/demo.html)支持旧浏览器。对于 CSS3 特定的,尝试 CSS 多边形:https://alastairc.uk/2007/02/dissecting-css-polygons/.
Code
HTML:
<div class="cornered"></div>
<div class="main">Hello</div>
The CSS:
.cornered {
width: 160px;
height: 0px;
border-bottom: 40px solid red;
border-right: 40px solid white;
}
.main {
width: 200px;
height: 200px;
background-color: red;
}
结果:http://jsfiddle.net/mdQzH/
替代代码
要在边框部分使用透明边框和文本... 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>
The 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;
}
结果:http://jsfiddle.net/76EUw/2
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)