[英]how to create angular div in html5 css3
I need help in creating diagonal div as shown in the picture. 如图所示,我在创建对角div时需要帮助。 i have diagonal design with triangles at top right and bottom left with using absolute positioning and z-index.
我使用对角线设计,使用绝对定位和z-index在右上和左下三角形。 And this div will be the main div having content in it.
并且该div将是其中包含内容的主要div。 I need to make a div similar to the picture.
我需要使div类似于图片。 i tried using transform skew property but that does not help.
我尝试使用transform歪斜属性,但这无济于事。 Any help will be appreciable.
任何帮助将是可观的。 The div will have something like this
股利将有这样的事情
<div class="tr-corner"><img src="tr.png"></div>
<div class="main">
<div class="content">
Blah blah blah
</div>
</div>
<div class="bl-corner"><img src="bl.png"></div>
CSS 的CSS
.tr-corner{
position:absolute;
top:0;
right:0;
z-index: 1;
}
.bl-corner{
position:absolute;
bottom:0;
left:0;
z-index: 3;
}
Now i need to create the div with id "main" to be diagonal as shown below. 现在,我需要创建ID为“ main”的div,使其对角线如下所示。
You can use skew()
to achieve that 您可以使用
skew()
来实现
div {
height: 200px;
border: 2px solid #aaa;
background: linear-gradient(to bottom, #ffffff 0%,#e5e5e5 100%);
transform: skew(20deg,0);
}
Make sure you add proprietary properties as well, so that old browser versions don't fail to render. 确保还添加了专有属性,以确保旧版本的浏览器不会渲染。
div {
height: 200px;
border: 2px solid #aaa;
background: linear-gradient(to bottom, #ffffff 0%,#e5e5e5 100%);
-webkit-transform: skew(20deg,0);
-moz-transform: skew(20deg,0);
transform: skew(20deg,0);
}
Demo 2 (Added proprietary properties.. especially for chrome users) 演示2 (添加了专有属性。.特别是对于chrome用户)
Browser compatibility is pretty sweet.. 浏览器兼容性非常好。
Credits : Mozilla Developer Network 鸣谢: Mozilla开发人员网络
You need to use css3's skew: 您需要使用css3的偏斜:
div {
-ms-transform: skew(30deg,20deg); /* IE 9 */
-webkit-transform: skew(30deg,20deg); /* Chrome, Safari, Opera */
transform: skew(30deg,20deg);
}
dont forget to fill in the div with colors :) 不要忘记用颜色填充div :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.