Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set up div background Picture by css

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor will share with you the relevant knowledge points about how to set up div background pictures in css. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.

First, the basic grammar of background.

1. CSS word: to set backers for any object, use the round fancy word of back.

2. The grammatical structure of CSS background attributes

1) set only the color of the equipment:

Div {bac kilogram round: # 000}

The background of the div configuration is pure black (# 000). There is no need to configure and apply the background-color configuration background tone at this time, so you may save a few character codes.

2) configure the image as backup:

Div {background:url (Picture path) no-repeat 4px 5px}

The div is configured with a background image, which is used as a background (no-repeat). At the same time, it is used as a backstop image to cut off the origin of the div left spacing 4px, and the distance above the distance 5px begins to show.

II. Case collection of DIV set-up pictures and equipment

Set several different DIV boxes, separate from the picture as the DIV background, set CSS several times to tile the background picture, CSS does not repeat the tile background picture, CSS horizontal (from left to right) tile background picture, CSS vertical (from top to bottom) tile background picture, through the DIV configuration set picture difference state to master div css background style.

Here Thinkcss is equipped with four DIV boxes, the CSS frame, CSS height and CSS width are the same. At the same time, there are four different background picture styles mentioned above. Set up the LOGO picture of the equipment CSS5 as the background development case.

1. Complete case HTML code

CSS5 for online demonstration of backing pictures

Tile the entire DIV backing

Completely tiled all over DIV

DIV background pictures do not repeat tiling

Backup pictures are not tiled repeatedly

Tile the DIV background horizontally (from left to right)

Tile the picture as the horizontal degree of the backing of DIV

Tile DIV backing longitudinally (from top to bottom)

Tile the picture as the longitudinal level of the DIV backer.

Note: four DIV boxes are set up and the CSS is named ".box1", ".box2", ".box3" and ".box4". This case is implemented theoretically on the basis of  of CSS5 initialization template.

2. Complete case CSS code

@ charset "utf-8"; / * CSS5-CSS initialization template-css5.com.cn * / body, div {margin:0; padding:0;font-style: normal;font:16px/22px "\ 5B8B\ 4F53", Arial, Helvetica, sans-serif} ol, ul, li {list-style:none} img {border: 0; vertical-align:middle} body {color:#000000;bac kg round: # FFF; text-align:center} a {color:#000000 Text-decoration:none} a:hover {color:#BA2636;text-decoration:underline} .box1, .box2, .box3, .box4 {width:400px; height:200px; margin:0 auto Border:1px solid # 666} .box1 {bac kg round: url (CSS5-logo.gif)} .box2 {bac kg round: url (CSS5-logo.gif) no-repeat 10px center} .box3 {bac kg round:url (CSS5-logo.gif) repeat-x 0 30px} .box4 {bac kg round: url (CSS5-logo.gif) repeat-y center}

The above first part of the CSS is the initialization template with its own CSS style, the latter ".box1", ".box2", ".box3" and ".box4" separate settings, the DIV level of the equipment is in the center (the CSS organ is in the center), the width is 400px, the height is 200px, and the equipment is equipped with a black border.

3, the DIV+CSS case reveals that 1), .box1 {bac kilogram round: url (CSS5-logo.gif)} sets the equipment decoration picture as the set of ".box1", using only the bac kilogram round picture as the setting, and no additional value is configured, which represents that this picture is used as an arbitrary target after the setting to tile the entire object background.

These are all the contents of the article "how to set up div background pictures in css". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report