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

php中文网
发布: 2016-06-24 12:08:58
原创
1145人浏览过

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;
}


改成这样看看,行不?

HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号