0

How can I make the bigger KNIGHT-IMAGE responsive like the other images?

I have this site: http://stephaniie.com/_testlab/beta1/

Full html code: http://pastebin.com/u4HpxcB2

If you scroll down, on the right, there is Knight next to a Tower.

  • If you move your mouse from his right side.. an bigger KNIGHT-IMAGE appears. "Talking" starts and text + animation of the little pixel knight.

  • If you move the mouse away the bigger KNIGHT-IMAGE disappear he says "Goodbye" and animation + text stops.

This is made by some pretty easy coding.

For the bigger KNIGHT-IMAGE to appear/hide this CSS and JavaScript is used:

Original Source: http://clba.nl/sitepoint/img-hover-demo-js1.htm

<style>
    #img2{
        position: absolute;
        top: 1600px;
        left: 100px;
        display: none;
        width: auto;
        height: auto;
     }
</style>

<script>
    var img1 = document.getElementById("sol"),
    img2 = document.getElementById("img2");

    img1.onmouseover = function() {
        img2.style.display = "block";
        if (document.images) document.getElementById('img_id12').src = 'assets/images/text/day/12solaire-ani.gif';  PlaySound('solaire');
    }

    img1.onmouseout = function() {
        img2.style.display = "none";
        if (document.images) document.getElementById('img_id12').src = 'assets/images/no-text/day/12.gif'; StopSound('solaire'); PlaySound('solaire-stop');
    }   
</script>

For the music to start playing a PlaySound/StopSound JavaScript is used.

Original Source: Javascript play sound on hover. stop and reset on hoveroff

   <script>
    function PlaySound(soundobj) {
        var thissound=document.getElementById(soundobj);
        thissound.play();
    }
    function StopSound(soundobj) {
        var thissound=document.getElementById(soundobj);
        thissound.pause();
        thissound.currentTime = 0;
    }
    </script> 

How can I make the bigger KNIGHT-IMAGE responsive like the other images? If you re-size the screen you notice all images changes size, all but the bigger KNIGHT-IMAGE - which appear when you hover the smaller knight located right next to the tower. Otherwise, the scripts work perfectly.

  • Mouseover = bigger Knight-Image appear, Animation/Text appear on Knight, Sound start.
  • Mouseout = bigger Knight-Image hides, Animation/Text disappear from Knight, Sound stops, Goodbye sound start.

For HTML on the website I use <map> and <area> to make an Image map.

Code is:

<img src="assets/images/no-text/day/12.gif" usemap="#map12" id="img_id12"/>

<map name="map12" id="img_id12">
<area class="youtube" id="sol" href="https://www.youtube.com/embed/skV-q5KjrUA" coords="3890,23,3970,100" shape="rect" style="outline:none;" />
</map>  

The only thing I want is too make the bigger KNIGHT-IMAGE have responsive size.

Edit and more information

I'm also using two JavaScript tools called Colorbox and Responsive Image Map:

The code to use them on Index page is this.

<script>
$(document).ready(function(e) {
    $('img[usemap]').rwdImageMaps();
});
$(document).ready(function(){
    //Examples of how to assign the Colorbox event to elements
    $(".youtube").colorbox({iframe:true, innerWidth:1024, innerHeight:576});
});
/script>

Full code for Responsive Image Map script and Colorbox is found here.

Responsive Image Map script:

<script src="assets/js/jquery.rwdImageMaps.min.js"></script>

Link: http://pastebin.com/699T5kLY

Colorbox:

<link rel="stylesheet" href="assets/colorbox-assets/colorbox.css" />                                        <!-- COLORBOX -->

Link: http://pastebin.com/Jj4SQEhu

    <script src="assets/colorbox-assets/jquery.colorbox.js"></script>

Link: http://pastebin.com/bErhvPFA

Community
  • 1
  • 1
  • 1
    Where is your knight image? Can you take a screenshot to show us where it is? – Kevin Jantzer Apr 18 '17 at 22:06
  • its old thread :) - i finished the project months ago –  Apr 18 '17 at 22:08
  • 1
    Duoh! I hate when people edit old threads – Kevin Jantzer Apr 18 '17 at 22:08
  • 1
    here is the final result. https://twitter.com/Tettix/status/843910740796956672 : the knight is there as well =) –  Apr 18 '17 at 22:09
  • @KevinJantzer: editing old threads here is very normal. To my mind it serves three purposes: it makes an old question more answerable, it makes a post more readable for people who might learn from it in the future, and it shows the original poster what improvements we like to make here. I happily edit things that are several years old if necessary - if something is on-topic, a bit of maintenance is a good thing `:-)`. – halfer Apr 19 '17 at 07:25
  • you made me totally banned here. isnt it enough , @halfer –  Apr 19 '17 at 07:57
  • I'm sorry that's happened, @Stephanie, really. Part of my attempt to intervene/advise in a chatroom was specifically to stop that happening. I see people writing posts that don't quite meet the guidelines quite frequently, but your case was unusual because you'd created some ten new posts in a day or two, which is quite high - I tend to advise people to post slowly to start with, so that the community has chance to help move the new poster towards a more on-topic approach before they are banned. – halfer Apr 19 '17 at 14:06
  • As I recall I think I upvoted one of your posts and downvoted another (serial voting only one way on a user is frowned upon here) so my feedback has not been totally negative. You can escape out of the ban, in any case - the message that informs you of the ban should point you to directions on how to do that. – halfer Apr 19 '17 at 14:09

0 Answers0