Answer the question
In order to leave comments, you need to log in
How to correctly collect pictures in the project?
Good afternoon!
Please share your experience in assembling front projects.
I'm interested in how the pictures are assembled.
I looked at a lot of lessons and different templates... few places support sprites from dpi.
If you have implemented this correctly, share your ideas, I will be very grateful.
What specifically interests:
1 sprite assembly with support for various dpi --- if it is still relevant
2 inserting svg icons into html from a sprite
3 how to insert svg as a background? --- this is a very important question... (so that there are no unnecessary requests to the server)
Thank you all!
Answer the question
In order to leave comments, you need to log in
Depending on the tasks
1. gulp.spritesmith - collects png into one sprite
2. gulp-svg-sprite - collects svg into one sprite
3. Inserting svg sprites into the page
Now it may not be relevant anymore, but it has not taken root in my practice
Background svgs (bad cross-browser compatibility, cannot be styled from external styles)
base64 (Burning layout, the picture has changed - in all places you need to change the picture everywhere, I use it very rarely)
Inserting svg sprites on the page, I do it according to this practice:
On the page I make a container where I group all the sprites
<div data-ui="resources" style="display: none;">
<svg data-ui="icon-pack">
<g id="svg-search"><path d="M61.8,56.6l-15.1-15C50,37.2,52,31.8,52,26C52,11.7,40.3,0,26,0C11.7,0,0,11.7,0,26c0,14.3,11.7,26,26,26 c6,0,11.5-2,15.9-5.4l15,15L61.8,56.6z M26,44.9c-10.5,0-19-8.5-19-19C7,15.5,15.5,7,26,7c10.5,0,19,8.5,19,19 C45,36.4,36.4,44.9,26,44.9z"></path></g>
<g id="svg-img"><path d="M0.8,0C0.4,0,0,0.4,0,0.8v22.9c0,0.4,0.4,0.8,0.8,0.8h24.7c1.2,1.5,3,2.5,5,2.5c3.5,0,6.4-2.9,6.4-6.5c0-2.7-1.7-5.1-4-6.1V0.8C33,0.4,32.6,0,32.2,0H0.8z M1.6,1.6h29.8V14c-0.3,0-0.5-0.1-0.8-0.1c-1.2,0-2.3,0.4-3.3,0.9l-3-3.2c-0.2-0.2-0.4-0.3-0.7-0.2 c-0.2,0-0.3,0.1-0.5,0.2l-5.7,5.1l-7.2-8.3c-0.2-0.2-0.5-0.3-0.7-0.3c-0.2,0-0.3,0.1-0.5,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0,0,0c0,0,0,0,0,0c0,0,0,0,0,0c0,0,0,0,0,0l0,5.1l0,0.2C7.2,16.4,7.8,17,8.5,17 c0.8,0,1.4-0.6,1.4-1.4l0,0l0-5.2c0,0,0,0,0,0c0,0,0,0,0,0c0-0.3,0.2-0.5,0.5-0.5l0,0l5.1,0l0.2,0C16.4,9.9,17,9.2,17,8.5 C17,7.7,16.4,7.1,15.6,7.1L15.6,7.1z"></path></g>
</svg>
</div>
<button data-ui="search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 61.8 61.5"><use x="0" y="0" xlink:href="#svg-search"></use></svg>
</button>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question