css中给div加风格属性时,什么时候需要制定宽和高

日期:2016-07-31 20:16:37 人气:1

css中给div加风格属性时,什么时候需要制定宽和高

这样说吧: div在不设定长宽的情况下,以及不设定position:absolute、fixed或者float的情况下 默认display:block,即宽度 width:100%;高度 height:auto ; 而设定了position:absolute、fixed或者float的情况下 宽度就会变成 width:auto 了。 而你所说的什么时候需要制定高度和宽度,主要还是要看页面效果的需求。 例如你想div的宽度继承父元素的宽度,那就width:100%,或者不设定 例如
    A+
热门评论