Forums

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

Home Forums CSS Keep absolutely positioned element's width dependent on its content width

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #166029
    zerobrainwash
    Participant

    Hi there,

    Let’s say I have a menu inside absolutely positioned element. Is there some way to make this absolutely positioned element expand relative to its content so I don’t have to give it a fixed width value?

    I can’t think of any way of how I could do that.

    #166032
    Atelierbram
    Participant

    You can try omitting width and height declarations, and try something width negative margins, something like::

    .absolute-positioned-element {
      top:0;right:0;bottom:0;left:0;
     margin-left: -5em;
     margin-bottom: -6em;
    }
    

    You will have to try this out to see if it will work in your case … , maybe in a codepen?
    Would like to see the result of this.

    #166035
    Paulie_D
    Member

    You can use % values for height & width…ditto for the positioning values.

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