本文摘自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>
|
效果图:
阅读剩余部分
相关阅读 >>
css中font属性能不按顺序吗
边框css四边怎么加
css怎么增加背景图片
css如何设置字体下划线
css right属性不起作用怎么办
html中弹性布局(flex)的介绍(附代码)
css代表什么意思
css样式怎么隐藏起来
css怎么设置边框阴影效果
svg和css3实现环形渐变进度条的代码示例
更多相关阅读请进入《css》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » css怎么放图片