Home  >  Article  >  Web Front-end  >  Sharing about how to control the background with css

Sharing about how to control the background with css

不言
不言Original
2018-06-20 11:55:172184browse

This article mainly introduces the example of css control background. Here is the method of setting background image and setting background color with css. Friends who need it can refer to it

1. Set the background color: background -color

Hexadecimal background-color:#ff0000;
English name background-color:red;
Three primary colors background-color:rgb(255,0,0)
transparent background-color:transparent;transparent



    

李克强主持召开国务院常务会议

2. Set the background image:

1. Introduce the background image: background-image
URL background- image:url("bg.jpg")
none Do not set the background image

2. Set the tiling method of the background image: background-repeat
repeat Fill the entire background with the background pattern.
repeat-x Fills the background pattern in the horizontal direction
repeat-y Fills the background pattern in the vertical direction.
no-repeat The pattern appears only once.

3. Set the position of the background image: background-position
top left Set the background pattern to appear on the top left.
top center sets the background pattern to appear in the top center.
top right Set the background pattern to appear on the top right.
center left Sets the background pattern to appear in the center left.
center center sets the background pattern to appear in the middle of IE.
center right Set the background pattern to appear in the center right.
bottom left Sets the background pattern to appear at the bottom left.
bottom sets the background pattern to appear directly below.
bottom right Set the background pattern to appear on the bottom right.

You can also accurately locate the position of the picture through coordinates (x, y) x horizontal position y vertical position, the unit is pixels (px)

4. Set the background image Whether it will scroll as the window scrolls: background-attachment
scroll sets the background image to move as the window scroll bar moves (default).
fixed The background image will not move with the movement of the window scroll bar.

Simplified format of background pattern: color background picture repeat attachment position



48、完美的男友:不吸烟,不喝酒,不欺骗。不存在!

 

49、人生就像一块破铜烂铁,把它扔进火里,敲敲打打,也能炼出一副精品!

 

50、话说动物园有一只猴子,奇丑无比,人见人吐!第二天我去看了,我吐了!第三天你去了,猴子吐了!

25、哥是文明人,所有脏话均已使用唾液消毒。  

26、名人名言,你得先是名人了那才是名言,别人的屁都是名屁!你能比吗?  

27、您都好意思撒谎了,我哪敢好意思不信呢?  

28、为什么我眼里常含眼屎,那是我对睡眠爱的深沉。   

29、别以为你比我年轻,你就能多蹦跶几天,棺材装的是死人不是老人!  

30、我是穷人,请勿盗墓!

 31、有时候老天下一场雨,是因为世界需要洗一洗;有时候眼睛下雨了,是因为心需要洗一洗!  

32、站在岁月的岸边,向自己的过往打个水漂吧……

33、2011我娶你,2012我保护你,2013爱你一生,2014爱你一世!  

34、人生就像一场旅行,在乎的不是目的地。而是沿途的"SB",以及对付"SB"时的心情!  

35、臭男人都喜欢骚女人。

 36、系好安全带,前方也许有场爱情正等着你。  

37、枕着打印机睡,就能打印出一整夜的梦吧?  

38、没有强大的主人,别以为你是狗就可以乱咬人!

 39、我只顾着往后看,却没有在意前面的路有多长。  

40、最近神马开始变驴腿了,浮云变雨水了!

 41、昨天是历史,今天是开始,明天谁都不好使!  

42、还是10086对我好,我给他发一条对短信,他给我回3条。  

43、靠山吃山,靠水吃水,今天抢劫,不许不给,谁要反抗,让他见鬼。  

44、今天MM的生日,为了第一个送上祝福,凌晨我准时拿起手机发了一条信息:沙发。  

45、知道高晓松为啥喝醉酒不?那是因为药家鑫想让他唱一首"同牢的你"。

 46、地铁上的广告:挤吗?买辆车吧!出租车上的广告:赌吗?坐地铁吧!靠,忽悠我还是怎么着!  

47、一般般的我,一般般的亮。一般般的你,我看不上!



35、臭男人都喜欢骚女人。

36、系好安全带,前方也许有场爱情正等着你。

37、枕着打印机睡,就能打印出一整夜的梦吧?

38、没有强大的主人,别以为你是狗就可以乱咬人!

39、我只顾着往后看,却没有在意前面的路有多长。

40、最近神马开始变驴腿了,浮云变雨水了!

41、昨天是历史,今天是开始,明天谁都不好使!

42、还是10086对我好,我给他发一条对短信,他给我回3条。

43、靠山吃山,靠水吃水,今天抢劫,不许不给,谁要反抗,让他见鬼。

44、今天MM的生日,为了第一个送上祝福,凌晨我准时拿起手机发了一条信息:沙发。

45、知道高晓松为啥喝醉酒不?那是因为药家鑫想让他唱一首"同牢的你"。

46、地铁上的广告:挤吗?买辆车吧!出租车上的广告:赌吗?坐地铁吧!靠,忽悠我还是怎么着!

47、一般般的我,一般般的亮。一般般的你,我看不上!

3. Exercise:

1. Use span to better control the text in local areas of the text

文本内容

pspan{background:red}


35、臭男人都喜欢骚女人。

2. Use the display attribute to provide block conversion


span{
color:#0C0;
width:100px;
height:100px;
background-color:#900;
display:block;/*内联转换为区块*/
}
p{
background-color:#F63;
width:300px;
height:50px;
display:inline;/*区块转换为内联,width和height的属性就无效了*/
}


使用span更好的控制文本中局部区域的文本
使用display属性提供区块转换

使用display属性提供区块转换

3. Add a small icon to the title (it is best to use the background to add the icon)


h5{
background:url(das.gif)no-repeatleftcenter;
padding-left:20px;
}


给我加个小图标吧

Above That’s the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to use CSS to control front-end image HTTP requests

The above is the detailed content of Sharing about how to control the background with css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn