Forums

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

Home Forums CSS Element not moving from top

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

    within a parent element position relative, i include position absolute in an p element but the p element not moving when i include “top” position..look at the code below..

    <div class="btnClass">
      <p>ghghg</p>
      </div>
    
    .btnClass{
      position: relative;
    }
    p{
      position: absolute;
      top: 20%; /*this is not working*/
      left: 15%;
      border: 1px solid red;
      display: block;
    }
    
    #249236
    Beverleyh
    Participant

    You’d have to declare a height for the parent otherwise it’s a case of “20% of what?”. The browser needs to calculate 20% of something.

    #249240
    Pranab
    Participant

    thanks..it’s working fine..one more question..
    what is “calc” in css? how to use that?
    like this –

    calc(100%-50px);
    
    #249244
    GMK Hussain
    Participant

    use like this

    .class{
            height:calc(100%-50px);
    }
    
    #249245
    Pranab
    Participant

    what’s this mean by the way..i googled this, but not understand..can anyone explain this to me?or if don’t have time then suggest me a good article about it…i see maximum developer uses this…any advantage for using this?

    #249247
    Beverleyh
    Participant

    That syntax isn’t correct – there should be spaces either side of the “-” symbol/operator; height:calc(100% - 50px);

    If you Google “uses for calc” you’ll find several good articles on the first page of results.

    #249248
    Shikkediel
    Participant

    Also beware of limited support with Android…

    http://caniuse.com/#feat=calc

    Quite a handy tool otherwise but I only use it after doing a feature test with JS and providing a fallback.

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