最佳答案
My understanding is that width: 100%
lets the element's width be the same as its parent's, whereas width: inherit
does that only when the parent's width is explicitly specified. Is this understanding correct?
If so, it looks to me that when width: inherit
works, then width: 100%
would always work, so you could always use the latter. Then, what is the purpose of writing width: inherit
? When does it become useful?
If my understanding is wrong, what is the difference between the two?
Similarly with height
.