怎么对png文件设置渐变
are a hot topic right now and why shouldn't they be? CSS gradients save time by not making you create an image, they save a request to that image, and the code to create them is smaller than the image's file size. If you've been using image-based gradients and are looking to move your web apps to CSS-based gradients, there's a great new project aimed at automating PNG gradients into CSS gradients called pngtocss
. pngtocss
is easy to obtain, configure, and use!
现在是一个热门话题,为什么不应该呢? CSS渐变通过不创建图像来节省时间,它们将请求保存到该图像,并且创建它们的代码小于图像的文件大小。 如果您一直在使用基于图像的渐变,并且希望将您的Web应用程序移动到基于CSS的渐变,那么有一个伟大的新项目旨在将PNG渐变自动转换为称为pngtocss
CSS渐变。 pngtocss
易于获取,配置和使用!
下载和配置 (Download and Configuration)
The pngtocss project is , for your forking pleasure. You can go the GitHub and download a zip or simply clone the project to your machine:
pngtocss项目 ,以供您欣赏。 您可以转到GitHub并下载一个zip或简单地将项目克隆到您的计算机上:
git clone https://github.com/bluesmoon/pngtocss.git
One you've cloned the repo, navigate to the src directory where you'll find a pngtocss.c file
, which you'll have to make
. Before making pngtocss
, you must confirm that your system has the zlib
and libpng
libraries installed. I use MacPorts so I typed:
一个你克隆回购,浏览到src目录,你会发现一个pngtocss.c file
,你就必须make
。 在制作pngtocss
之前,必须确认系统已安装zlib
和libpng
库。 我使用MacPorts,所以输入:
sudo port install zlibsudo port install libpng
With those two libraries present, I was ready to make
:
在存在这两个库的情况下,我准备make
:
make pngtocss.c
If everything installed as it should have, you're ready to start converting PNG gradients to CSS gradients! To convert your PNG gradient images into CSS gradients, run the following command:
如果一切都已安装,您就可以开始将PNG渐变转换为CSS渐变了! 要将PNG渐变图像转换为CSS渐变,请运行以下命令:
#pngtocss {file}pngtocss mypng.png#output:.mypng { background-image: -moz-linear-gradient(top, #02469a, #bcf3cb); background-image: -webkit-gradient(linear, left top, left bottom, from(#02469a), to(#bcf3cb)); background-image: -webkit-linear-gradient(top, #02469a, #bcf3cb); background-image: -o-linear-gradient(top, #02469a, #bcf3cb); background-image: linear-gradient(top, #02469a, #bcf3cb);}
That's it! Pretty sweet! Like any early project, however, pngtocss
isn't perfect and it doesn't support radial gradients yet. pngtocss
is, however, a promising start and is an excellent utility for helping developers move from images to CSS. Cheers to Phillip Tellis for creating this awesome utility!
而已! 真可爱! 但是,像任何早期项目一样, pngtocss
是完美的,它还不支持径向渐变。 pngtocss
是一个有前途的起点,并且是一个出色的实用程序,可帮助开发人员将图像从图像转移到CSS。 感谢Phillip Tellis创建这个超赞的实用程序!
翻译自:
怎么对png文件设置渐变