Prevent a specific child div from expanding the parent div

前端 未结 2 422
傲寒
傲寒 2020-12-29 17:59

I\'m currently developping a website and encountered a problem with CSS.

I have a parent div containing 2 or more children: one containing the name of a

相关标签:
2条回答
  • 2020-12-29 18:36

    You can use Absolute positioning

    FIDDLE

    position:absolute;
    top:0;
    left:0;
    width:100%;
    

    and on the container div :

    padding-top: /*the height of the absolutly positioned child*/ ;
    position:relative;
    
    0 讨论(0)
  • 2020-12-29 18:45

    If you add the following styles you should achieve what you want:

    .user-match-container {
      position: relative;
      padding-top: 22px;
    }
    
    .match-owner {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      position: absolute;
      top: 4px;
      left: 0;
      right: 0;
    }
    

    Example

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