Maison  >  Article  >  interface Web  >  初学CSS一个问题?_html/css_WEB-ITnose

初学CSS一个问题?_html/css_WEB-ITnose

WBOY
WBOYoriginal
2016-06-24 12:08:58984parcourir

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

 


 

   float属性 

 

 


Head Line


初学CSS一个问题?_html/css_WEB-ITnose

The Internet Society's mission is to achieve a world in which everyone everywhere is connected to an open and universally accessible Internet.  Since its inception in 1992, ISOC has been at the forefront of global Internet education by bringing essential information and training to people throughout the world.The Internet Society's mission is to achieve a world in which everyone everywhere is connected to an open and universally accessible Internet.  Since its inception in 1992, ISOC has been at the forefront of global Internet education by bringing essential information and training to people throughout the world.







zen2.css
body {
background-image:url(bg-grad.gif)
/*background-repeat:repeat-x;*/
}

h1 {
/*background-color:#678; */
color:white;
text-align:center;

}

.p1 {
width:200px;
float:left;
margin:10px;
margin-left:0;
padding:10px;
border:3px gray double;
background:#9BD;
height:200px;

}

.p2 {
font-size:20px;
line-height:1.8;
background-color:white;
}

.firstLetter {
font-size:3em;
float:left;
}

img {
border:1px dashed gray;
margin:10px,10px,10px,0;
padding:5px;
float:left;
}

问题是这样,body里的背景图片如果不加background-repeat属性就能显示出来,如果加了用IE或FF死活就没图了。书上的例子是内嵌的CSS代码跟偶外部引用式的不一样,但用书上光盘里的例子程序打开又是正常的。百思不得其解?


回复讨论(解决方案)

可能是这个背景图片高度太小,repeat-x时看不出来罢了

你这样子让我很惆怅啊。

建议你把那些没用的样式先删除掉。然后一点一点的测试,不要让别的样式影响了。这样的话 你应该能很快的找到错误

LZ在写css的时候首先要注意你css中引用背景图片的路径时候正确,再看看你那个背景图会不会就横着一条件,repeat-x这样不仔细看的话会感觉没有图片的

repeat属性要随着图片尺寸来用的

background-image:url(bg-grad.gif) ;

是不是外部引用和内部的相对路径问题?不显示可能是这个原因。

body {
background-image:url(bg-grad.gif)
/*background-repeat:repeat-x;*/
}
少了一个结束符分号 ;

body 样式代码应该是这样的:
body {
background-image:url(bg-grad.gif);
/*background-repeat:repeat-x;*/
}

果然很纠结

纠结,背景样式不要拆分出来写,聚集到一起,如:
background:url(**.jpg) no-repeat left top;

初学者表示看不懂啊

body {
 background:url(bg-grad.gif)
 background-repeat:repeat-x;
}


改成这样看看,行不?

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn