css怎么放图片


本文摘自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和css重难点知识点总结

css如何修改滚动条箭头样式

css如何实现底部tapbar栏效果

一招搞定css定位元素的背景图像

css page-break-inside属性怎么用

css怎么让字体变细

css怎么清除空白

css怎么将字和图对齐

如何使用css更改占位符颜色?(代码示例)

html中是如何引入css样式?以及link与@import的区别(代码实例)

更多相关阅读请进入《css》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...