本文摘自PHP中文网,作者藏色散人,侵删。
css放图片的方法:1、使用background简写属性在设置背景时引入图片;2、直接使用background-image属性引入背景图片。
本文操作环境:windows7系统、HTML5&&CSS3版、Dell G3电脑。
css怎么放图片?
随着互联网的发展,网速不断提升,我们现在的网页也变的更加丰富起来,除了能够传输文字外,我们还可以传输图片。我们该如何使用css在网页中放图片?下面我们俩看一下使用css在网页中放图片的方法。
css可以使用background简写属性在设置背景时引入图片,也可以使用background-image属性引入背景图片。background-image属性为元素设置背景图像。
使用background简写属性引入图片:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <!DOCTYPE html>
<html>
<head>
<meta charset= "utf-8" >
<title></title>
<style>
body
{
background: #00ff00 url( 'img/3.jpg' ) no-repeat fixed center;
}
</style>
</head>
<body>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
<p>This is some text</p>
</body>
</html>
|
效果图:
阅读剩余部分
相关阅读 >>
html中表格tr的td单元格怎么设置宽度属性
css如何取消加粗
css怎么在图片上显示遮罩层
css如何设置英文首字母大写
css属性可分为哪几大类
js怎么改变css display属性的值
css换行代码是什么
css怎么让连续数字字母换行
css如何设置字体平滑
css如何实现鼠标经过样式改变
更多相关阅读请进入《css》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » css怎么放图片