Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS vertical centering nested content in a div

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #149973
    onebitrocket
    Participant

    Here is my example with the issue: http://codepen.io/onebitrocket/full/FulsL

    The top:-50px will not initially apply on the .featureText span. It only seems to work when I turn the property off and then on in fire bug. Strangely, ie7 renders this correctly.

    Has anyone else come across this issue?

    Thanks

    #149974
    Paulie_D
    Member

    To start with, why are you using spans and positioning there, that seems counter-productive?

    #149980
    Paulie_D
    Member

    I think a more standard structure might suit: http://codepen.io/Paulie-D/pen/zjsmn

    #149994
    onebitrocket
    Participant

    I’m using that markup for a specific reason as part of a larger project. There is some js which refers to all child divs, they then inherit the styles forced by that js.

    Thanks for your restructure, but it still has the same issue with vertically centering the featureText container with in the hight of the feature div regardless of the content within the featureText container.

    Did you check the page with firebug? Toggling off and on the top:-50% property fixes it in browser, but doesn’t explain while its not taking it into account when the page is loaded. I’ve check through the styles and I can’t see any inherency issues.

    #149996
    Paulie_D
    Member

    The top:-50px will not initially apply on the .featureText span.

    BTW…in the Codepen it’s given as -50% not px.

    Could that be it?

    #150003
    onebitrocket
    Participant

    Ah. No I did mean -50%.

    Is that a standard issue that causes the value not to initially apply on loading?
    If so i’ll need find a fix some how.

    I did use display:table/table-row/table-cell and vertical-align:middle, which works perfectly on modern browsers

    #150008
    Paulie_D
    Member

    I did use display:table/table-row/table-cell and vertical-align:middle, which works perfectly on modern browsers

    I’d go with that if for no other reason than it works without using any magic numbers.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘CSS’ is closed to new topics and replies.