I have used an image sprite that contains both buttons, but they appear smaller than the other buttons on the page and not sure why.
Please can someone help me acheive the rollover effect and make the buttons the same size as the others whilst still being responsive, I would really appreciate it.
You need to half the dimensions. The whole sprite is 125px high, so if you want to hide half of it, make the height of .sprite 62px and the hover shift (top) the same.
If you just want to change the colour of the image, this can be done to sgv without sprite sheets by altering the background and fill properties via css. But for this to work the svg must be inline.
Thanks for the response the second option sounds like it could be easier, how would I do this, the button code is being enetered into Wordpress Visual Composer.
I thought editing 2 lines of css was easier, but the second option is a more elegant solution.
.sprite img {
position: absolute;
width: 550px;
height: 62.5px;
-webkit-transition: all 0.1s linear;
-moz-transition: all 0.1s linear;
-o-transition: all 0.1s linear;
transition: all 0.1s linear;
}
.sprite:hover img {
top: -62.5px;
}
You would have to put the svg in the html inline, that is to image code in <svg> tags rather than an <img>. I tend to do this via a php include, just to keep the working code a bit tidier.
<?php include $_SERVER["DOCUMENT_ROOT"]."/images/icon.svg"; ?>
You can edit the svg to add classes to its elements, which you can then target with css selectors and alter various properties. Eg, you can alter the colour of the fill or stroke or whatever.
Sorry, the css I posted was wrong. I had it working fine in “Inspect”, but edited the wrong selectors in the code I copied from your post.
The height 62.5px should be on .sprite not .sprite img.
That was just an example include, it should contain the correct filepath to your svg.
This is only if you are going for the second, inline option, in which case you don’t want the sprite image, just the single image. The include should not be in the header, but in place of the <img> tag. But since you are struggling, maybe stick with the sprite method for now and forget the include.
It’s never going to be responsive if the dimensions are set in pixels. You need to set a max-width in px and use % for width and offsets and set the height using padding.
Which I personally don’t like, div within div within div etc, to one element. But in this case the max-width needs to be applied to a wrapper for .sprite for the padding trick to work when the max-width is exceded by the container.
There is already a <p> there not doing much. Maybe give that a class to apply the max-width to.
I think part of the problem is how you are editing the css. You seem to be appending the snippets of code to the file rather than editing the required rules in, replacing/removing existing ones.
As a result you have the selector for .sprite 3 times with different contradicting rules.
Consolidate all the rules into one selector and remove duplicate and redundant ones.
You have added the .spritewrap class to the css, but it’s not on the <p> element in the html.