GithubHelp home page GithubHelp logo

使用雪碧图自动化工具,是不是要求构建前的图片背景不得设置background-position? about grunt-css-sprite HOT 3 CLOSED

laoshu133 avatar laoshu133 commented on September 26, 2024
使用雪碧图自动化工具,是不是要求构建前的图片背景不得设置background-position?

from grunt-css-sprite.

Comments (3)

stoneChen avatar stoneChen commented on September 26, 2024

即使原来使用独立背景时,background-position是0,0, 如果该元素高宽比背景本身大很多,那么在使用雪碧图后,“隔壁”的背景会错误的出现在该元素上。所以还是必须要用这个“额外的小元素”。您说是吗?

from grunt-css-sprite.

laoshu133 avatar laoshu133 commented on September 26, 2024

我们这里和 grunt-spritesmith 解决的其实是两个方向的问题;
关于你的另一个问题,请参见 #27

from grunt-css-sprite.

stoneChen avatar stoneChen commented on September 26, 2024

@laoshu133
嗯,的确是两种不同的解决思路,grunt-spritesmith是先合并出雪碧图,再开发(调用生成的class即可),grunt-css-sprite是先开发再合并出雪碧图(修改css代码,添加background-position),各有优劣。但共同点是,都要求使用背景的元素高宽等于背景本身的高宽(适当大于也可以,看场景)。昨天折腾一下午,把grunt-css-sprite整合进构建流程。但后来还是觉得grunt-spritesmith的方式更加直观,更加接近最终效果,开发页面时,不需要每次都手动设置应用背景元素的高宽(生成的css里已经全部自动化设置好)。构建时,只需简单copy+cssmin即可。

可能我这边的场景更适合grunt-spritesmith吧,@laoshu133 的插件也很棒,谢谢分享。

from grunt-css-sprite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.