Home >Web Front-end >HTML Tutorial >Invalid solution for setting img image height to percentage
When using percentage as the width and height, because the percentage is relative to the width and height of its nearest parent element, first its parent element must have a width and height. The width is generally not set and will have a default value (such as the width of the entire screen). However, if the height is not set, there will be no default value. Therefore, if the parent element does not set a height value and its internal element uses a percentage as the height, it will have no effect