0

Right now I am working with an iFrame for HTML and I am trying to center align this image. When I type in align = "middle" it doesn't seem to work. I wan to place this GIF in a website. Aligning it in the center would make it look nice.

<iframe src="http://gifyoutube.com/embed/mG9rRw" frameborder="0" scrolling="no" width='480' height='270' style="-webkit-backface-visibility: hidden;-webkit-transform: scale(1);" ></iframe>
Lal
  • 14,726
  • 4
  • 45
  • 70

2 Answers2

0

That is not a GIF. That is a video (either MP4 or WebM (depending on your browser)) which is embedded in the iframe. It's so small and could easily be converted into a GIF, but that's not the question here.

Add this CSS to your iframe and it should align it in the middle horizontally.

display: block;
margin: 0 auto;

http://jsfiddle.net/odezpjLy/

Check out the JSFiddle above for an example.

MortenMoulder
  • 6,138
  • 11
  • 60
  • 116
0

Place it in a div wrapper, and center the item in the <div>:

#wrapper
{
  text-align:center;
  width:100%;
}
<div id="wrapper">
<iframe src="http://gifyoutube.com/embed/mG9rRw" frameborder="0" scrolling="no" width='480' height='270' style="-webkit-backface-visibility: hidden;-webkit-transform: scale(1);" ></iframe>
</div>
Spencer Wieczorek
  • 21,229
  • 7
  • 44
  • 54
  • That's a hacky way and shouldn't be used. You should avoid `width: 100%` at all cost, if you can use `margin: 0 auto` instead. Also, adding a DIV around it just complicates things more. – MortenMoulder Aug 04 '15 at 17:13