Nicole
Nicole

Reputation: 247

CSS positioning images

I need to place the arrow at the bottom right of the fish inside the face of my scale. I made these two separate images because I wanted the arrow to move from 0 degrees to 270 degrees when you mouse over it.

I've gotten the animation to work but now I'm a bit stuck on how to position it inside my scale. This is the mobile first version (the site has to be responsive) so I'm worried that if I change the scales (There will be 5 scales) from standing underneath each other to next to each other, the positions will get messed up.

Also, Is there a way I can tell the animation to only play when you hover your mouse over it in CSS? Or do I have to do this with javascript/jquery?

enter image description here

CSS3:

#bluearrow{
    animation: animationFrames ease 4s;
  animation-iteration-count: 1;
  transform-origin: 50% 100%;
  animation-fill-mode:forwards; /*when the spec is finished*/
  -webkit-animation: animationFrames ease 4s;
  -webkit-animation-iteration-count: 1;
  -webkit-transform-origin: 50% 100%;
  -webkit-animation-fill-mode:forwards; /*Chrome 16+, Safari 4+*/ 
  -moz-animation: animationFrames ease 4s;
  -moz-animation-iteration-count: 1;
  -moz-transform-origin: 50% 100%;
  -moz-animation-fill-mode:forwards; /*FF 5+*/
  -o-animation: animationFrames ease 4s;
  -o-animation-iteration-count: 1;
  -o-transform-origin: 50% 100%;
  -o-animation-fill-mode:forwards; /*Not implemented yet*/
  -ms-animation: animationFrames ease 4s;
  -ms-animation-iteration-count: 1;
  -ms-transform-origin: 50% 100%;
  -ms-animation-fill-mode:forwards; /*IE 10+*/
}

@keyframes animationFrames{
  0% {
    left:0px;
    top:0px;
    opacity:1;
    transform:  rotate(0deg) scaleX(1) scaleY(1) ;
  }
  100% {
    left:0px;
    top:0px;
    opacity:1;
    transform:  rotate(270deg) scaleX(1) scaleY(1) ;
  }
}

@-moz-keyframes animationFrames{
  0% {
    left:0px;
    top:0px;
    opacity:1;
    -moz-transform:  rotate(0deg) scaleX(1) scaleY(1) ;
  }
  100% {
    left:0px;
    top:0px;
    opacity:1;
    -moz-transform:  rotate(270deg) scaleX(1) scaleY(1) ;
  }
}

@-webkit-keyframes animationFrames {
  0% {
    left:0px;
    top:0px;
    opacity:1;
    -webkit-transform:  rotate(0deg) scaleX(1) scaleY(1) ;
  }
  100% {
    left:0px;
    top:0px;
    opacity:1;
    -webkit-transform:  rotate(270deg) scaleX(1) scaleY(1) ;
  }
}

@-o-keyframes animationFrames {
  0% {
    left:0px;
    top:0px;
    opacity:1;
    -o-transform:  rotate(0deg) scaleX(1) scaleY(1) ;
  }
  100% {
    left:0px;
    top:0px;
    opacity:1;
    -o-transform:  rotate(270deg) scaleX(1) scaleY(1) ;
  }
}

@-ms-keyframes animationFrames {
  0% {
    left:0px;
    top:0px;
    opacity:1;
    -ms-transform:  rotate(0deg) scaleX(1) scaleY(1) ;
  }
  100% {
    left:0px;
    top:0px;
    opacity:1;
    -ms-transform:  rotate(270deg) scaleX(1) scaleY(1) ;
  }
}

#bluescale{
    position: absolute;
}

HTML:

<section id="Skills">

    <h3>Html/css</h3>
    <img alt="blue scale" id="scale_blue" src="images/bluescale.svg">
    <img alt="blue scale" id="bluearrow" src="images/bluearrow.svg">
    <h3>Jquery</h3>
    <img alt="pink scale" id="scale_pink" src="">
    <h3>Javascript</h3>
    <img alt="purple scale" id="scale_purple" src="">
    <h3>Photoshop</h3>
    <img alt="green scale" id="scale_green" src="">
    <h3>Illustrator</h3>
    <img alt="orange scale" id="scale_orange" src="">


</section><!--/skills-->

Here's the rest of my code:

http://jsfiddle.net/29yuj/

I have two css files. Don't know how to upload both to fiddle. The second css file is posted in my question. Basically just for my animation

Upvotes: 3

Views: 155

Answers (1)

Pat Dobson
Pat Dobson

Reputation: 3299

Add the following CSS:

#skills{ position: relative; }

And

#scale_blue{ position: absolute; top: 10px; left: 10px; }
#bluearrow{ position: absolute; top: 10px; left: 10px; }

And then, adjust Top & Left for the two elements to suit your needs.

Upvotes: 1

Related Questions