css中边框我没有设颜色,但是显示的效果是有颜色的。颜色为黑色。

html-css014

css中边框我没有设颜色,但是显示的效果是有颜色的。颜色为黑色。,第1张

任何一个css属性都是有默认值的,也就是说,即使你不设置,它这个值也是存在的。border的颜色默认就是黑色,但由于border的width默认为0,style默认为none,所以在默认情况下看不到边框,但并不等于边框的颜色就不存在。一旦把边框的width设为1px,style设为solid,黑色的边框就出现了。

Dreamweaver软件自带的 这个说法是错误的,实际上这跟浏览器有关,不同的浏览器,css属性的默认值有可能不同,但大部分都是相同的。

上传到网上则是没有的 这个说法也是错误的,原因同上。

补充说一下:你用浏览器的开发者模式去检查一下网页上的元素,就会发现,任何一个元素它的所有css属性都是有值的,即使没有进行过任何的设置。就好比字体的颜色,它默认就是黑色的啊,边框的颜色也一样的道理!

IE6.0的缺陷,float后会导致有误差,最好把margin和border,padding全部设置为0,另外float后加上display:inline我改好了如下(注意在多种浏览器看看)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<title>QQ娱乐网</title>

<style type="text/css">

<!--

body{background:#DCD800margin:0px}

.all{width:720pxheight:720pxbackground:#FFFAB3margin:auto}

.top{width:720pxheight:200pxbackground:red}

.top1{width:720pxheight:70pxbackground:bluemargin:0 0border:0display: inline}

.top1left{width:120pxheight:70pxbackground:#ffffffmargin:0 0border:0float:leftdisplay: inline}

.top1right{width:600pxheight:70pxbackground:#000000margin:0 0border:0float:leftdisplay: inline}

-->

</style>

</head>

<body>

<div class="all">

<div class="top">

<div class="top1">

<div class="top1left">

</div><!--top1left-->

<div class="top1right">

</div><!--top1right-->

</div><!--top1-->

</div><!--top-->

</div><!--all-->

</body>

</html>