Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
148
rated 0 times [  154] [ 6]  / answers: 1 / hits: 10829  / 10 Years ago, tue, march 25, 2014, 12:00:00

I have a button on my site, on clicking it will show/hide a google map div (embedded using iframe). It is working fine except the border-radius is working only during jquery animate. Once the animation is done, the iframe becomes square.



I have setup a jsFiddle demo



HTML



<div id=layer-2>
<span id=moreInfo>
<iframe src=https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d12242.306455925878!2d-75.12138282383809!3d39.90611059880662!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x3e48fdca1ebac4d0!2sWalt+Whitman+Bridge!5e0!3m2!1sen!2sin!4v1395728987250 width=300 height=200 frameborder=0 style=border:0></iframe>
</span>
</div>
<button>Show</button>


Javascript



$(function () {
$(button).on(click, function () {
if(parseInt($(#moreInfo).css(opacity))) {
$(button).text(Show);
$(#moreInfo).css({opacity:1,top:0,height:200,display:'inline'});
$(#moreInfo).animate({opacity: 0,top: 100,height: 100}, 100, function () {$(#moreInfo).hide();});
} else {
$(button).text(Hide);
$(#moreInfo).css({opacity:0,top:100,height:100,display:'inline'});
$(#moreInfo).show();
$(#moreInfo).animate({opacity: 1,top: 0,height: 200}, 100);
}
});
});


CSS



#moreInfo {
position: absolute;
opacity: 0;
top: 0px;
left: 10px;
width: 300px;
height: 200px;
background-color: blue;
border-radius: 50%;
}
#layer-2 {
height: 200px;
}
body {
background-color: #aaa;
}



Note: Please don't mark this duplicate, I have gone through a number of stack overflow answers, but none of them helped. Also please don't suggest for any other google maps api integration, I need to use the iFrame implementation.



More From » jquery

 Answers
2

It does work, you need to use overflow: hidden; for the span element as your iframe overflows out of the span element, and since you don't have border-radius applied on the iframe, it renders as a rectangle block...



#moreInfo {
position: absolute;
opacity: 0;
top: 0px;
left: 10px;
width: 300px;
height: 200px;
background-color: blue;
border-radius: 50%;
overflow: hidden;
}


Demo






If you don't want to use overflow: hidden; for the parent, than use the border-radius for the iframe as well... and get rid of blue background color...



#moreInfo iframe {
border-radius: 50%;
}


Demo 2 (As you commented, fails on Chrome, will look into it soon)


[#46579] Sunday, March 23, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
devinjadong

Total Points: 711
Total Questions: 117
Total Answers: 100

Location: Andorra
Member since Sat, May 27, 2023
1 Year ago
;