设置子元素的高度或父元素的高度是最佳做法吗?

时间:2017-02-26 22:37:11

标签: css

最佳做法是设置父元素的高度并根据父元素调整所有子元素吗?例如

#parent {
    width: 100%;
    height: 50px;
}
.childOne {
    height: 50%;
}
.childTwo {
    height: 100%;
}

或者,由于父元素会自动调整为与最大子元素相同的高度,因此最佳做法是设置子元素大小并允许父元素相应调整吗?例如

#parent {
    width: 100%;
}
.childOne {
    width: 100%;
    height: 100px;
}
.childTwo {
    width: 100px;
    height: 50px;
}

0 个答案:

没有答案