CSS3 1px diagonal lines gradient

白昼怎懂夜的黑 提交于 2019-12-11 03:03:36

问题


I want to create a diagonal pattern using CSS3, something like this:

So 1px dark diagonal line, 1px light diagonal line and so on...

This is what i came up with, i feel like i'm close but something is defenitely not right:

background-color: #454545;
background-image: repeating-linear-gradient(-45deg, rgba(0,0,0,0.2), rgba(0,0,0,0.2) 1px, transparent 1px, transparent 4px);

Demo:

http://tinkerbin.com/6mTBtADt


回答1:


just use background-size with your exisiting code try to add this background-size: 8px 8px;




回答2:


Your code looks great in Firefox, but I can see the problem when I view it in Chrome.

It actually looks like your gradient is correct, because if you cause redraws on the browser (i.e. by resizing it) it sometimes looks close to the Firefox version. This leads me to believe it is a bug in Chrome.

If you increase from 1px to 4px you can see it is working, but very jagged.



来源:https://stackoverflow.com/questions/14585110/css3-1px-diagonal-lines-gradient

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