December 1, 201114 yr hey all, Is it possible to float a div, inside a div that contains an image? <div id="content"> <img src="images/bg_02.png" alt="" width="960" height="499" /> (This image is to have hotspots, which is why I haven't got it as a background image) </div> I need some text to appear over part of the image.... Thanks Gecko
December 1, 201114 yr As they say in Mexico "todo es posible!" You may need to play with the z-index and position to get it where you want it, but yes you can do that no probs.
December 1, 201114 yr How about an image map? If you have Dreamweaver it's dead easy to generate - you basically just draw out your hotspots and it'll create the links for you. If you're wanting to put text over the image then you could still have the image as a background image, and then absolutely position divs over it... <div id="my-image"> <ul> <li class="hotspot-1">Hotspot 1</li> <li class="hotspot-2">Hotspot 2</li> </ul> </div> #my-image { background:url(images/myimage.jpg); width:500px; height:500px; position:relative; } #my-image ul { margin:0; padding:0; } #my-image ul li { list-style:none; display:block; position:absolute; } #my-image ul li.hotspot-1 { width:10px; height:20px; top:10px; left:25px; } #my-image ul li.hotspot-2 { width:15px; height:10px; top:40px; left:125px; } And if you only want your hotspots to show when you've hovered over them #my-image ul li { display:none; } #my-image ul li:hover { display:block; } Ideally, if your hotspots contain links then it's better, because you're not relying the :hover pseudo-selector on the <li> and you can apply the styles to the <a> tag instead... <div id="my-image"> <ul> <li class="hotspot-1"><a href="#hotspot-1">Hotspot 1</a></li> <li class="hotspot-2"><a href="#hotspot-2">Hotspot 2</a></li> </ul> </div> #my-image { background:url(images/myimage.jpg); width:500px; height:500px; position:relative; } #my-image ul { margin:0; padding:0; } #my-image ul li { list-style:none; } #my-image ul li a { display:none; position:absolute; } #my-image ul li a:hover { display:block; } #my-image ul li.hotspot-1 a { width:10px; height:20px; top:10px; left:25px; } #my-image ul li.hotspot-2 a { width:15px; height:10px; top:40px; left:125px; } Or you can add a bit of jQuery to make things a little easier and cross-browser compatible (with the reliance on jQuery)... #my-image { background:url(images/myimage.jpg); width:500px; height:500px; position:relative; } #my-image ul { margin:0; padding:0; } #my-image ul li { list-style:none; display:none; position:absolute; } #my-image ul li:hover, #my-image ul li.hover { display:block; } #my-image ul li.hotspot-1 { width:10px; height:20px; top:10px; left:25px; } #my-image ul li.hotspot-2 { width:15px; height:10px; top:40px; left:125px; } $(document).ready(function) { $('#my-image ul li').hover(function() { } $(this).addClass('hover'); , function() { //on blur $(this).removeClass('hover'); }); }); I've written the code in this box so it's untested and might have a couple of typos, but it gives you the right idea. If you can't get it working let me know!
Create an account or sign in to comment