The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Iframe Center Align (Horizontal)

4 posters

Go down

Solved Iframe Center Align (Horizontal)

Post by FineryWorkshop February 14th 2015, 4:19 am

So, I'm trying to center my iframe and every tutorial I've looked up so far hasn't worked. I know it sounds stupid that I can't do it, but I'm having trouble with it :/ Here's the code I have:
Code:
<style>
iframe{
  align: center !important;
  position: center !important;
}
</style>

<iframe src="http://apps.pixlr.com/editor/" width="1500" height="600" frameborder="0" ></iframe>
I tried putting it in a table, and a ton of other things. But it just doesn't want to center Sad I also tried it as a simple HTML file off my website and it doesn't work, so it's not something on my website.


Last edited by FineryWorkshop on February 15th 2015, 12:34 am; edited 1 time in total
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Iframe Center Align (Horizontal)

Post by _Twisted_Mods_ February 14th 2015, 4:40 am

have u tried wrapping the iframe with <center> </center> tags
_Twisted_Mods_
_Twisted_Mods_
Helper
Helper

Male Posts : 2083
Reputation : 336
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: Iframe Center Align (Horizontal)

Post by FineryWorkshop February 14th 2015, 5:19 am

_Twisted_Mods_ wrote:have u tried wrapping the iframe with <center> </center> tags
Yes, still no difference :/
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Iframe Center Align (Horizontal)

Post by _Twisted_Mods_ February 14th 2015, 5:27 am

well y im already on ur forum wheres this iframe located?
_Twisted_Mods_
_Twisted_Mods_
Helper
Helper

Male Posts : 2083
Reputation : 336
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: Iframe Center Align (Horizontal)

Post by SLGray February 14th 2015, 9:27 am

Code:
<center><iframe src="http://apps.pixlr.com/editor/" width="1500" height="600" frameborder="0" ></iframe></center>


Iframe Center Align (Horizontal) Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51555
Reputation : 3524
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: Iframe Center Align (Horizontal)

Post by Ange Tuteur February 14th 2015, 9:42 pm

If you want to center an element with CSS use margin:0 auto; or margin:auto;
( note : that the element should be block-level )
Code:
iframe {
  margin:0 auto;
  display:block;
}

Now if you wanted to center the content inside another element, you can use text-align:center;

HTML :
Code:
<div class="center">
  <iframe src="/null"></iframe>
</div>

and CSS :
Code:
.center { text-align:center }
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Iframe Center Align (Horizontal)

Post by FineryWorkshop February 15th 2015, 12:33 am

Thank you all so much all your help. I figured out the problem. (At least I think, it works now.) I made the width too long for the link so it just didn't carry on and so when I centered it it was centering the iframe not the link Smile

And here's the code I ended up with for future viewers (?)
Code:
<style>
.center {
  text-align:center;
  width:100%;
}
iframe{
  width: 1000px;
}
</style>

<div class="center">
 <iframe style="align: center;" src="http://apps.pixlr.com/editor/" width="1500" height="600" frameborder="0"></iframe>
</div>
FineryWorkshop
FineryWorkshop
Forumember

Female Posts : 48
Reputation : 1
Language : English
Location : USA

http://NOTREADY.forumotion.com

Back to top Go down

Solved Re: Iframe Center Align (Horizontal)

Post by Ange Tuteur February 15th 2015, 1:38 am

You're welcome, that will work fine. Wink

By default the <div> element should span the entire width of its parent container, -- similar to 100% width -- because it's a block-level element. This gives a pretty good explanation on block-level and inline elements. Smile
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Iframe Center Align (Horizontal)

Post by _Twisted_Mods_ February 15th 2015, 4:13 am

Topic solved and archived
_Twisted_Mods_
_Twisted_Mods_
Helper
Helper

Male Posts : 2083
Reputation : 336
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum