/    Sign up×
Community /Pin to ProfileBookmark

Centering vertically within a floated div?

I’m failry new to CSS, just read through Eric Meyer’s Definitive Guide and browsed in a few other places.

I’m building a site for a graphic designer friend.

I had created a layout based on absolute positioning, but realised that it would be better to use floated elements to solve a problem with fonts forcing areas to overlap when resizing a window.

I previously had this arrangement to center a large image both vertically and horizontally within a div, basing the markup & styles on this [URL=”http://www.w3.org/Style/Examples/007/center-example.html”]http://www.w3.org/Style/Examples/007/center-example.html[/URL]

It’s clearly a horrible case of div-itis… 😮

div#viewing {position:absolute;top:0;right:0;bottom:0;left:24%;}
div#outer {display:table;width:100%;height:100%;}
div#inner {display:table-cell;vertical-align:middle;}
img.fullimage {display:block;min-width:100px;width:512px;margin-left:auto;margin-right:auto;}

<div id=”viewing” >
<div id=”outer” >
<div id=”inner” >
<img class=”fullimage” href=”…” alt=”…” />
</div>
</div>
</div>

really ugly but it worked, the problem is I have now changed the style:

div#viewing {[COLOR=”SeaGreen”]float:right[/COLOR];min-width:77%;}

and this breaks the vertical centering.

Can anyone help?

Thanks

to post a comment
CSS

0Be the first to comment 😎

×

Success!

Help @sundaydeveloper 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 5.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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...