Hi,
I have a script on my page that toggles the visibility of content inside of a <div> tag when a link is clicked. I have an image inside this hidden content that I would like to center but just can’t. I have looked all through Google to try to find the answer and I have tried every solution I could find, but nothing works. The example code is below. Please help!
CSS:
<style>
.centeredImage{
text-align:center;
margin-top:0px;
margin-bottom:0px;
padding:0px;
}
</style>
Script:
<script type=”text/javascript”>
<!–
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == ‘block’)
e.style.display = ‘none’;
else
e.style.display = ‘block’;
}
//–>
</script>
HTML:
<a href=”#” onclick=”toggle_visibility(‘toggle’);return false;”>Link to toggle display</a>
<div id=”toggle” style=’display:none; margin:auto’ class=”data”>text content here<br>
<p class=”centeredImage”><a href=”thankyou.html”><img src=”IMAGE-THAT-SHOULD-BE-CENTERED.gif” class=”centeredImage” width=”150″ height=”44″ border=”0″ id=”Image1″ onmouseover=”MM_swapImage(‘Image1′,”,’image.gif’,1)” onmouseout=”MM_swapImgRestore()” /></a></p>
</div>
PLEASE HELP!!! I’ve been working on this for forever!