Break letters of second child div

后端 未结 6 1201
臣服心动
臣服心动 2021-01-12 16:24

I have one requirement, where I need to apply width to the parent element which is equal to the first child element\'s width. This can be easily achieved using display

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-12 17:22

    I got the solution!!

    HTML

    first
    valuevalue

    CSS

    .main {
        overflow:hidden;
        width:1px;
        display:table;
        background-color: cornflowerblue;
    }
    .first {
        width: 50px;    /* I don't know this width */
        height: 50px;    /* I don't know this height */
        background-color: grey;
        display: inline-block;
    }
    .value {
        word-break: break-all;
    }
    

    Working Fiddle

    Related link

提交回复
热议问题