sprite-margin-top attribute with negative px-value

79 views
Skip to first unread message

MaggB

unread,
Jan 17, 2014, 2:44:09 AM1/17/14
to smartsprites-css...@googlegroups.com
I am new to smartsprites and I am trying to implement it to an existing website. The CSS needs to be adjusted and this is where I encounter some problems.
Some of my images needs to have a negative pixel-value in the background-position attribute (f x "background-position 0px -1px) to move the image up 1px. 
I noticed the attribute "sprite-margin-top" (bottom/left/right), but I am not allowed to put negative values here. How can I solve this?

Stanislaw Osinski

unread,
Jan 19, 2014, 10:42:24 AM1/19/14
to SmartSprites CSS Sprite Generator Users and Developers
Hello,

Apologies for a delayed reply. Would you be able to prepare a small design (HTML, CSS, image) illustrating your use of negative background offsets?

Thanks,

Staszek

--
You received this message because you are subscribed to the Google Groups "SmartSprites CSS Sprite Generator Users and Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smartsprites-css-sprit...@googlegroups.com.
To post to this group, send email to smartsprites-css...@googlegroups.com.
Visit this group at http://groups.google.com/group/smartsprites-css-sprite-generator.
For more options, visit https://groups.google.com/groups/opt_out.

MaggB

unread,
Jan 20, 2014, 2:22:34 AM1/20/14
to smartsprites-css...@googlegroups.com
CSS:
#home a{
background-repeat:no-repeat;
background-attachment: scroll;
background-position: 0px -1px;
background-color: transparent;
background-image: url(/imagesP/icons/Home-icon2.gif); /** sprite-ref:gif_sprite; sprite-margin-top:-1px */
}

HTML:
<div id="home"><a href="/en/">Home</a></div>

I need the image to have a background-position of "left -1px" or "0px -1px" after the sprite is done. That is, the image needs to move 1px to the top.
Hope you understand what I mean...?

Thanks for your help.

/Margareta

Stanislaw Osinski

unread,
Feb 12, 2014, 8:33:01 AM2/12/14
to SmartSprites CSS Sprite Generator Users and Developers
Hello,

Once again apologies for a delayed reply.

I'd have to see a specific working example (HTML, CSS, image) to see what you're trying to achieve. Is your goal to truncate the image by 1 pixel from the top? Or the specific layout ensures that even after shifting to the top, the whole image will still be shown?

Negative background positions are a bit tricky with SmartSprites because we'd need to make sure the other images in the sprite don't show through because of the negative offset. I you haven't yet solved the problem and could could provide the specific example HTML, CSS and image, I may be able to find a solution not requiring negative offsets.

Staszek

Tengiz Tutisani

unread,
Feb 12, 2014, 10:30:54 PM2/12/14
to smartsprites-css...@googlegroups.com, stanisla...@carrotsearch.com
Hi Stanislaw,

I have the same issue.
Sorry have no example though.

However, you mentioned right, I need to probably truncate an image from the top side, because the original CSS has:

background-position: 0px -3px;


What would be the workaround, if any?


Thanks,
Tengiz

MaggB

unread,
Feb 13, 2014, 3:08:09 AM2/13/14
to smartsprites-css...@googlegroups.com, stanisla...@carrotsearch.com
I'm basically only trying to adjust the image (in this case move it 1px to the top), not truncate it. I can adjust the image any other direction, which means I'm risking the next image to "show through" anyway.
Thanks for your help, it is very much appreciated!
/Margareta
Home-icon2.gif
TEST.html
TEST_Css.css

Stanislaw Osinski

unread,
Feb 13, 2014, 4:33:26 AM2/13/14
to SmartSprites CSS Sprite Generator Users and Developers
Hello,

Your original design actually does truncate the image off the top by one pixel: http://screencast.com/t/bdUlRywHNi. If that's your intention, you'd need to truncate the source image manually in a graphic program, SmartSprites cannot do that.

Stanislaw

--

MaggB

unread,
Feb 25, 2014, 6:57:58 AM2/25/14
to smartsprites-css...@googlegroups.com, stanisla...@carrotsearch.com
Sorry, I missed one thing in the css: #home a should have this sprite code: /** sprite-ref:gif_sprite; sprite-margin-top:-1px; */  (see encl css-file). When I run SmartSprites I receive a warning about the negative value, and the sprite adds: background-position: left -0px;

TEST_Css.css

MaggB

unread,
Apr 2, 2014, 3:25:16 AM4/2/14
to smartsprites-css...@googlegroups.com, stanisla...@carrotsearch.com
Hello Stanislaw,
Thanks for your help so far, do you have a reply or comment on my last post from the 25 feb? :)
Kind regards

Stanislaw Osinski

unread,
Apr 7, 2014, 6:38:12 AM4/7/14
to SmartSprites CSS Sprite Generator Users and Developers
Hello,

Thanks for your help so far, do you have a reply or comment on my last post from the 25 feb? :)

As I said earlier -- if your intention is to truncate the image (and this is what your CSS is doing), then you have to truncate the image in a graphics program -- SmartSprites does not support truncating the images and hence will not accept negative offsets.

Stanislaw

Reply all
Reply to author
Forward
0 new messages