Home Web Front-end CSS Tutorial How to tile css background-image?

How to tile css background-image?

Jun 21, 2017 pm 04:16 PM
background-image css how Tile

When doing web page layout in the past, one div could only set one background image. If multiple backgrounds were set, multiple divs must be nested to achieve better compatibility. If your website requires compatibility with lower browser versions, it is recommended to use this method. The emergence of CSS3 solves the problem that a div can only set one background, allowing a div to set multiple background images. background-imageYou can also set linear gradients and other effects.

Regarding the background of css3, it is very powerful and has many attributes, such as background-size, etc. You can write a blog about these attributes. Regarding other properties of css3background, I will blog about them separately later!

CSS3/CSS1 background-image attribute

Syntax:

1

2

background-image:<bg-image> [ , <bg-image> ]

*<bg-image> = none | <url> | <linear-gradient> | <radial-gradient> | <repeating-linear-gradient> | <repeating-radial-gradient>

Copy after login

Default value: none

Value:

none: none Background image.

< url >: Specify the background image using an absolute or relative address.

< linear-gradient>: Create a background image using a linear gradient. (CSS3)

<radial-gradient>: Create a background image using a radial (radial) gradient. (CSS3)

< repeating-linear-gradient>: Create a background image using a repeating linear gradient. (CSS3)

< repeating-radial-gradient>: Create a background image using a repeating radial (radial) gradient. (CSS3)

Description:

Set or retrieve the background image of the object .

If background-image is set, it is also recommended that the author sets background-color to maintain a certain contrast with the text when the background image is invisible.

The corresponding script feature is backgroundImage.

How to stretch the background image to cover the screen in CSS

The CSS code I wrote is

1

2

3

4

5

6

#bg

{

width: 100%;

height: 100%;

background:url(images/beijing.png);

}

Copy after login

In this way, it will repeat the image to cover the screen. I How should I write it if I want him to stretch the picture to fill the screen?

1

background:url(images/beijing.png) repeat;

Copy after login


Add an attribute

1

background-size:100%;background:url(images/beijing.png) no-repeat;

Copy after login

Add an attribute background-size:100%;background:url(images/beijing.png) no-repeat; The picture will be distorted oh!

Either the outer frame is limited, set it to 100%. I tested it here and it is full. You can see if there are any other attributes that affect it.

The above is the detailed content of How to tile css background-image?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does placeholder mean in vue What does placeholder mean in vue May 07, 2024 am 09:57 AM

What does placeholder mean in vue

How to write spaces in vue How to write spaces in vue Apr 30, 2024 am 05:42 AM

How to write spaces in vue

How to get dom in vue How to get dom in vue Apr 30, 2024 am 05:36 AM

How to get dom in vue

What does span mean in js What does span mean in js May 06, 2024 am 11:42 AM

What does span mean in js

What does rem mean in js What does rem mean in js May 06, 2024 am 11:30 AM

What does rem mean in js

How to introduce images into vue How to introduce images into vue May 02, 2024 pm 10:48 PM

How to introduce images into vue

What is the function of span tag What is the function of span tag Apr 30, 2024 pm 01:54 PM

What is the function of span tag

What language is the browser plug-in written in? What language is the browser plug-in written in? May 08, 2024 pm 09:36 PM

What language is the browser plug-in written in?

See all articles