Dynamically changing height of div element based on content

前端 未结 3 1713
有刺的猬
有刺的猬 2021-01-14 05:28

I\'m working on a Facebook-like toolbar for my website.

There\'s a part of the toolbar where a user can click to see which favorite members of theirs are online.

相关标签:
3条回答
  • 2021-01-14 05:34

    You should take out the CSS height:25px property in the toolbar, the contents will expand the container. Also, ID selector tags are unique and you can specify directly to them without having to reference the ancestor:

    INCORRECT:

     #toolbar #popUpAction  { /*some css */ }
    
     #toolbar #popUpAction a  { /*some css */ }
    

    CORRECT:

     #popUpAction  { /*some css */ }
    
     #popUpAction a  { /*some css */ }
    
    0 讨论(0)
  • 2021-01-14 05:41

    Make it a float element and don't use a clearing element after it.

    0 讨论(0)
  • 2021-01-14 05:45

    Maybe you could remove the height property (make sure it's not set in the CSS) and let the DIV expand in height by itself.

    0 讨论(0)
提交回复
热议问题