/    Sign up×
Community /Pin to ProfileBookmark

vertical center a iframe

hi,
does anyone know how i can center a iframe vertically?

i know how to do it horizontally, but what do i have to add to center it vertically???

[code=html]
#iframe{text-align:center;}[/code]

[code=html]<div id=”iframe”><iframe></iframe></div>[/code]

grzz,
knstr

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@EmerickSep 04.2007 — are you going to have header or/and footer?
Copy linkTweet thisAlerts:
@EmerickSep 04.2007 — if you post the whole source with the css in the same doc ill have a look at it.
Copy linkTweet thisAlerts:
@knstrauthorSep 04.2007 — here you are...

[code=html]<html>
<head>

<style type="text/css">
*{padding:0;margin:0;}
BODY { background-image: url(bg2.png); background-repeat: repeat-x; background-color: #000; }
#iframe{text-align:center;}
</style>

<script type="text/javascript" language="javascript">
<!--
function func()
{
if(document.body.clientHeight > (document.body.clientWidth/1.5))
{
height = (document.body.clientWidth/1.5)
width = document.body.clientWidth
}
else if((document.body.clientHeight*1.5) < document.body.clientWidth)
{
height = document.body.clientHeight
width = (document.body.clientHeight*1.5)
}
document.getElementById("myframe").height=height+"px";
document.getElementById("myframe").width=width+"px";
}
-->
</script>

</head>

<body onLoad="func()" onResize="func()" scroll="no">
<div id="iframe"><iframe id="myframe" height="0px" width="0px" src="http://www.google.com" frameborder="0" scrolling="no"></iframe></div>

</body>
</html>[/code]
×

Success!

Help @knstr spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...