slanted div top and bottom CSS

流过昼夜 提交于 2019-12-05 09:07:41

Simply change skewY for .slanted:after to a negative number and adjust the height accordingly (numbers below just an example - adjust to how you want it):

.slanted:after {
    content: "";
    background: red;
    height: 80px;
    transform: skewY(-5deg);
    position: absolute;
    left: 0;
    right: 0;
    z-index: -1;
}

Updated Fiddle

There is a borders sollution too, create a long left one in color and make the top and the bottom transparent.

#trap {
	height: 100px;
	border-top: 20px solid transparent;
	border-left: 500px solid aqua;
	border-bottom: 30px solid transparent;
}
		
<div id="trap"></div>

You can use the CSS3 clip-path property to achieve the desired outcome. Below is a working js fiddle.

clip-path: polygon(0% 0%, 100% 20%, 100% 85%, 0 100%);
-webkit-clip-path: polygon(0% 0%, 100% 20%, 100% 85%, 0 100%);

http://jsfiddle.net/niteshp27/fgdcq3qp/5/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!