Break letters of second child div

后端 未结 6 1228
臣服心动
臣服心动 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:18

    Look at my latest comment for the Fiddle link. I changed some things in the html too. Did set the value div inside the first div to use it's width and added word-wrap to the value div.

    .main {
        display: inline-block;
        background-color: cornflowerblue;
        position: relative;
    }
    .first {
        width: 50px;  /* I don't know this width */
        position: relative;
        background-color: grey;
    }
    
    .first p {
        margin-bottom: 30px;
        margin-top: 0;
    }
    
    .value {
        max-width: 100%;
        word-wrap:break-word;
        background-color: cornflowerblue;
    }
    

    html:

    first

    valuevalue

    http://jsfiddle.net/jxw4q/12/

提交回复
热议问题