How to rotate the background image in css?
Tags: html,css,css3,css-animations
Problem :
I have a custom radiobutton image. I am trying to rotate the background image alone when some one chooses the option. But it rotates the the whole div.
here is my partially working jsFiddle
ul.pt-answers > li > label > input:checked +img {
background: url(http://www.opinionpoll.in/files/images/vote_symbol.png);
background-repeat: no-repeat;
background-position:center center;
background-size:30px 30px;
-webkit-animation:spin 0.5s ease 1 both;
-moz-animation:spin 0.5s ease 1 both;
animation:spin 0.5s ease 1 both;
border:none;
}
@-moz-keyframes spin { 100% { -moz-transform: rotate(30deg); } }
@-webkit-keyframes spin { 100% { -webkit-transform: rotate(30deg); } }
@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(30deg); } }
Solution :
I suggest you use the <div>
element tag instead of <img>
so you can create a pseudo ::before
element in it. You can specify the css select to create the pseudo ::before
element, assign the background properties and apply the spin, viola!
You can see what I mean in your updated fiddle here.
Get additional information here.
edit: spelling
CSS Howto..
You mention non-webkit, non-Firefox browsers appear to do the same thing. Have you looked using their developer tools? Both IE (except for 7; 6 has it as an addon; 8...
Demo Hi now your markup is wrong please change to your markup html and css write as like this HTML <div> <p> <label>Name: </label> <span>John</span> <label>Age: </label><span>35</span></p> <p><label>Level: </label><span>60</span>...
you can use javascript setTimeout functions. For example setTimeout("changeBackground()",3000); // call changeBackground() function , 3 seconds later. ...
you can't change the color of the circle (since it's part of the image) but you can : 1 - add a css border circle (and then change the color):...
try putting them in an other div <div class="panel-heading">DIT LOGS <div class="pull-right"> <button type="button" class="btn btn-danger btn-rad btn-xs"><span class="glyphicon glyphicon-record"></span></button> <button type="button" class="btn btn-primary btn-rad btn-xs"><span...
If you want to override style in any case irrespective of which order style is applied, consider applying style inline in the div. <div class="someClass" myAttributeDirective style="position:absolute;"></div> ...
Give this a shot: html { min-height: 100%; background-size: cover; background-image: url(steve1.png); background-repeat: no-repeat; background-position: right bottom; } body{ min-height:100%; } ...
It's just text[attr] for an attribute selector and > for child of... g > g > g > text[text-anchor] {display:none} <svg> <g><g> <text text-anchor="middle" x="100" y="30">now you see me</text> <g><text...
Assuming an unstyled off-canvas as shown in the doc, something like this should work. Updated CSS .move-right .exit-off-canvas { box-shadow: none; } .move-left .exit-off-canvas { box-shadow: none; } note make...
$('.LocationName').each(function(index){ $(this).css("background-image", "url('/Style Library/Images/design/icons/greymarker" + index + ".png')"); }); ...
To trigger your event on dynamically created elements you need to use event delegation. you can try updating your code like this $(document).on('click', '.quickview', function(){ alert("This is popping up :)");...
It's probably not feasible using CSS2 unless you could modify your HTML somehow, e.g. to include a first class to your first ul. Without being able to touch your HTML,...
There were some thing wrong with your code: You've 2 the same ID's (the A and the DIV), updated with data-target. You were searching for "#selected" instead of ".selected", updated...
The answer to my issue is that I had used page zoom (Ctrl+/-) at some point, and it was persisting. I feel silly missing something so simple. @Boris Zbarsky, Thank...
CSS .fix{clear:both} /*Use this to clear float*/ ul { border: 2px solid; border-top-left-radius: 2em; list-style-type: none; margin: 0; padding: 0%; background-color: #dddddd; } li { float: left; margin-left:16px; /*Adjust margin...
A quick media query should be enough. Add this after your CSS : @media screen and (max-width: 420px) { // adjust the width for your needs div.credits { display: none;...
Found the answer in another SO question, you have to add (2 * PI) if the result in radians is less than zero. This line: var angle = Math.round(Math.atan2(b, a)...
You're having that problem because the menu is being position relative to the body so as the window width changes the position of the menu moves. To solve this problem...
This http://jsfiddle.net/UvYxc/ is working HTML <table> <tr style="background:red;" id= "2977" class ="x y z a b c" > <td>RED</td> </tr> </table> JS document.getElementById("2977").style.backgroundColor="blue" alert(document.getElementById("2977").style.backgroundColor); Or...
You can do: <link rel="stylesheet" media="(min-width: 768px)" href="style.css" /> More documentation here...
Theres now an official sample ;) http://code.msdn.microsoft.com/ie/Scrolling-panning-and-6834aaf9/sourcecode?fileId=68336&pathId=380363024
This is a common problem. What I use is this: https://github.com/premasagar/cleanslate A common css reset stylesheet doesn't suffice. Those reset/normalize the browsers default styles. They don't clear those created by...
You have to give your body styles like so... body {width: 100%; height: 100%; min-height: 100%; height: auto;} As your body has a height of the viewport, anything that is...
To hide elements when printing, create a seperate CSS file called something like print.css and make sure its media type is print: <link href="print.css" rel="stylesheet" media="print" type="text/css" /> This stylesheet...
The problem is that Flex 4 components use the Spark theme to define their appearance by default and in this theme border hasn't backgroundImage property. But you can change theme...
This is what you're asking for, but it isn't best practice and I wouldn't recommend it. I would refer you to @nietonfir's suggestion (despite being a little harsh, he/she is...
Here's one trick using just css: .container-div { height:100%; overflow:hidden; } .tall-div { height:1000px; float:left; width:100px; background-color:blue; } .at-least-as-tall-div { min-height:100%; float:left; width:100px; background-color:red; padding-bottom:10000px; margin-bottom:-10000px; } check the fiddle:...
You can use CSS Flexbox. Make your parent a flex container & in your image use align-self: center. .img-holder { display: inline-flex; background: black; } img { align-self: center; margin:...
Try this: .nav { display: inline-block; margin-left: 5%; margin-bottom: 5px; margin-top: 5px; text-align: center; } Working Fiddle...
maybe: width:20px; height 10px; border: 1px solid #fff; color: white; padding-left: 10px; padding-top: 4px; font-size: 16px; line-height: 0px; work?...