Url images bg-support.png top center no-repeat năm 2024

You can use the `<head></head>`6 value by itself, but if you try to use just `404 not found`1 by itself, the CSS rule will be invalid and none of the background properties will work at all.

📣 Freelancers, Developers, and Part-Time Agency Owners: Kickstart Your Own Digital Agency with UACADEMY Launch by UGURUS 📣

The background-image property in CSS applies a graphic (e.g. PNG, SVG, JPG, GIF, WEBP) or gradient to the background of an element.

There are two different types of images you can include with CSS: regular images and gradients.

Images

Using an image on a background is pretty simple:

body {
  background: url(sweettexture.jpg);
}

The url() value allows you to provide a file path to any image, and it will show up as the background for that element.

You can also set a data URI for the url(). That looks like this:

body {
  /* Base64 encoded transparent gif */
  background: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7);
}

This technique removes one HTTP request, which is a good thing. But, there are a number of downsides, so before you start replacing all of your images make sure you consider all the pros and cons of Data URIs.

You can also use background-image to sprite images, which is another useful method for reducing HTTP requests.

Gradients

Another option when using backgrounds is to tell the browser to create a gradient. Here’s a super-duper simple example of a linear gradient:

body {
  background: linear-gradient(black, white);
}

You can also use radial gradients:

body {
  background: radial-gradient(circle, black, white);
}

Technically speaking, gradients are just another form of background image. The difference is that the browser makes the image for you. Here’s an entire guide on how to make and use them.

The example above uses only one gradient, but you can also layer multiple gradients on top of each other. There are some pretty amazing patterns you can create using this technique.

Setting a fallback color

If a background image fails to load, or your gradient background is viewed on a browser that doesn’t support gradients, the browser will look for a background color as a fallback. You can specify your fallback color like this:

body {
  background: url(sweettexture.jpg) blue;
}

Multiple background images

You can use multiple images, or a mixture of images and gradients, for your background. Multiple background images are well-supported now (all modern browsers and IE9+ for graphic images, IE10+ for gradients).

When you’re using multiple background images, be aware that there’s a somewhat counter-intuitive stacking order. List the image that should be at the front first, and the image that should be at the back last, like this:

body {
  background: url(logo.png), url(background-pattern.png);
}

When you’re using multiple background images, you’ll often need to set more values for the background to get everything in the right place. If you want to use the

body {
  /* Base64 encoded transparent gif */
  background: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7);
}

1 shorthand, you can set the values for each image individually. Your shorthand will look something like this (notice the comma separating the first image and its values from the second image and its values):

body {
  background:
    url(logo.png) bottom center no-repeat,
    url(background-pattern.png) repeat;
}

There’s no limit to how many background images you can set, and you can do cool things like animate your background images. There’s a good example of multiple background images with animation on David Walsh’s blog.

Some images should be repeated only horizontally or vertically, or they will look strange, like this:

If the image above is repeated only horizontally (background-repeat: repeat-x;), the background will look better:

Example

body { background-image: url("gradient_bg.png"); background-repeat: repeat-x; }

Try it Yourself »

Tip: To repeat an image vertically, set background-repeat: repeat-y;


CSS background-repeat: no-repeat

Showing the background image only once is also specified by the background-repeat property:

Example

Show the background image only once:

body { background-image: url("img_tree.png"); background-repeat: no-repeat; }

Try it Yourself »

In the example above, the background image is placed in the same place as the text. We want to change the position of the image, so that it does not disturb the text too much.

How do I stop my BG image from repeating?

To make a background image stop tiling in HTML, you can use the background-repeat property in CSS and set it to "no-repeat". Here's an example: body { background-image: url('your-image-url.

How do I make a picture not repeat?

To avoid the background image from repeating itself, set the background-repeat property to no-repeat .

Which property is used to avoid repeating the background image?

You can use no-repeat value for the background-repeat property if you do not want to repeat an image, in this case, the image will display only once.

How do I make the background image not repeat in CSS header?

The CSS background-repeat is what you're looking for. If you want the background image not to repeat at all, use background-repeat: no-repeat; . Good luck!