首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

div设置宽度无效解决方法

2013-10-21 
div设置宽度无效css文件body{margin:0padding:0font-size:16pxbackground-image:url(/CMS/view/image/b

div设置宽度无效
css文件

body{
margin:0;
padding:0;
font-size:16px;
background-image:url(/CMS/view/image/background.jpg);
z-index:0;
}
#body{
margin:auto;
width:100%;
height:auto;
}
.nav{
width:100%;
height:30px;
background-color:DAECFE;
position:fixed;
top:0;
z-index:100;
}

#centent{
margin-top:34px;
margin-left:auto;
margin-right:auto;
width:1024px;

border:solid #C9C9C9;
height:600px;
}
#footer{
margin-top:5px;
margin-left:auto;
margin-right:auto;
width:1024px;
height:60px;
border:solid #C9C9C9;
}

html文件

<html>

<head>
<meta charset="utf-8">
<title> cms管理系统</title>
    <link href="/CMS/view/css/index.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div alt="div设置宽度无效解决方法" />
,宽度无效,也没剧中显示。
把footer加入浮动float:left属性后宽度有效。如图div设置宽度无效解决方法

求大神解答。
css html
[解决办法]

引用:
Quote: 引用:

/CMS/view/css/index.css

这个 标签先删除

或者 你看浏览器 元素调试
看那些样式被影响了
谢谢了,解决了。在footer中加入display:block;属性就可以正常显示了。但我不晓得原因。

所以说 你被其他地方的样式 影响了
[解决办法]

引用:
Quote: 引用:

/CMS/view/css/index.css

这个 标签先删除

或者 你看浏览器 元素调试
看那些样式被影响了
谢谢了,解决了。在footer中加入display:block;属性就可以正常显示了。但我不晓得原因。

好多浏览器对div的宽度,要指定百分比的形式,必须写display:block 

热点排行