jquery - Background-image + Making a Div into a link -


i created small box placed @ bottom right of map , have facebook logo background image , make div clickable directs site. tried adding code cannot seem either fb image nor link work.

fiddle

css (background image):

      #facebook {             background-image: url(http://www.ridersmatch.com/facebook_logo.png);          background-repeat: no-repeat;          height: 30px;         width: 30px;         margin-right: 5px;         margin-bottom: 5px;         background:#fff;         border: 1px solid #ccc;         border-radius: 10px;       } 

jquery (click function):

    map = new google.maps.map(document.getelementbyid("map_canvas"), map_options);     map.controls[google.maps.controlposition.top_left].push($('<div id="infowindow"/>')[0]);     map.controls[google.maps.controlposition.right_bottom].push($('<div id="facebook"/>')[0]);      $('#facebook').click(function() {          window.open('http://www.facebook.com');             }); 

check updated jsfiddle: http://jsfiddle.net/jw5vv/1/ within jsfiddle, make sure rightclick on facebook link , choose "open in new tab/page".

the problem you're first setting background-image, , set background #fff. last style applied.

also, since background picture quite large, need specify background-size.

use css:

#facebook {         background-image: url(http://www.ridersmatch.com/facebook_logo.png);      background-repeat: no-repeat;      background-size: 30px 30px;     height: 30px;     width: 30px;     margin-right: 5px;     margin-bottom: 5px;     border: 1px solid #ccc;     border-radius: 10px;       } 

to make facebook-logo clickable, wrap anchor so:

<a href="http://www.facebook.com">     <div id="facebook"></div> </a> 

you spare facebook div , apply #facebook id anchor directly.

either way, won't need javascript/jquery click function.

check updated jsfiddle: http://jsfiddle.net/jw5vv/1/


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -