The use of background images in CSS web design should pay attention to the path problem

Source: Internet
Author: User
css| background picture | design | Web Page Design | problem

Web Design tips article, CSS web design using background images should pay attention to the path problem.

In the traditional table layout, the background image is directly applied to the table, in general, the Background-image attribute of CSS is used very little, or simply do not use. The application CSS page layout, realizes the content and the performance, the behavior separation, as the page frame, the decoration and so on the picture we directly peel to the CSS file, through the CSS to define.

We usually use link to refer directly to a CSS file in HTML (or other active document) files. We'll find that sometimes our pictures don't show. At this point, please check your CSS code, is not the duplicate settings have problems, is not the location of the picture has a problem. If these are all fine, remove the background duplicate and position properties and revert to default. If the picture is still not there, it can only be the path problem we are talking about today! In general, we are accustomed to setting picture paths like this:

Background-image:url (logo.jpg);
Background-image:url (.. /logo.jpg);
Background-image:url (.. /images/logo.jpg);

For the first case "url (logo.jpg)". We want to see if this picture is in the same directory as the CSS file. For the second and third cases, we are strongly not recommended, because our web page files may exist in a multilevel directory, the file location of the same directory is doomed to our relative path is not the same. And this complicates the problem, it is likely that the picture in this file to display normal, the first target, the picture can not find the shadow.

There is a way to easily solve this problem, we may create a common file directory, used to store some common picture files, JS scripts, CSS files, such as "common", we will be directly placed in the CSS file in the directory, you can also file pictures directly in the directory, If the picture file is more in its interior set up a directory to store the picture file "Common/images". We write directly in the CSS file: url (logo.jpg) or URL (images/logo.jpg) can handle the above problem.

Of course, this is only my suggestion, on the site file classification and storage, in addition to personal habits, but also to consider scientific. My method is not necessarily correct. If it is a large project, you should follow the team's agreement, otherwise these problems are enough headaches!



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.