Home >Web Front-end >Front-end Q&A >Why doesn't css background appear?

Why doesn't css background appear?

青灯夜游
青灯夜游Original
2021-04-29 15:48:586532browse

The reasons why css background is not displayed: 1. CSS is not called; 2. The background attribute name is written incorrectly or the background image path is incorrect; 3. The background element has no content filling, and width and height are not set; 4. The element does not have the block attribute; 5. It is overwritten by the style of the CSS class with the same name.

Why doesn't css background appear?

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

The reason why css background is not displayed

1. The css is not called; please check whether the css call is successful.

2. The css background attribute name Writing error or background image path error

css sets the background for background. The writing method is backgroud:url('picture path');. Please check whether your css is written correctly. , the picture is not displayed, or it may be because the picture path is wrong. If you don't know which folder the picture is placed in, you can put the html file together with the picture and directly write backgroud:url('1.jpg');

3. The background element has no width and height. When the element has no content and no width and height are set, the background cannot be displayed. The background does not expand the element.

4. The element does not have block attributes. The height and width set when the element does not have the block attribute are invalid. So the picture will not be displayed.

5. Overwritten by the style of the CSS class with the same name. Assume that the background display image is set with the name .bg in the front, and the background display color is set with the name .bg later.

(Learning video sharing: css video tutorial)

The above is the detailed content of Why doesn't css background appear?. 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