first
valuevalue
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
I don't think you will be able to achieve it without a little help of javascript. Imagine the the following markup and css :
first
valuevalue
and then the following css :
.main{
background-color : red;
display: inline-block;
max-width: 50px;
}
.first{
background-color : blue;
}
.second{
background-color : green;
}
.content{
word-break: break-word;
}
Now all you gotta do is to set the max-width of your .main div to be equal to your first element and add the content class to each element. I suppose you are adding your elements dynamically.