I'm trying to use loading animation using jQuery. I've tried different paths for css file like
<link href="css/animation.css" type="text/css" rel="stylesheet">
<link href="../css/animation.css" type="text/css" rel="stylesheet">
but still CSS file is not getting loaded in the html file. When I kept the CSS file in the same folder as the html file then it worked correctly.
My folder structure ...
index.html
<html>
<head>
<title>Loading Animation using jQuery</title>
<script src="js/jquery.js"></script>
<script src="js/jquery.backstretch.js"></script>
<link href="css/animation.css" type="text/css" rel="stylesheet">
</head>
<body>
<div id="loader">
</div>
<h2>Hi There</h2>
<script>
$(window).load(function(){
$("#loader").delay(10000).hide(0).fadeOut("slow");
});
</script>
</body>
</html>
animation.css
#loader{
z-index:999999;
display:block;
position:fixed;
top:0;
left:0;
width:100%;
height:100%;
background:url(images/loader.gif) 50% 50% no-repeat rgb(249,249,249);
}
The js files are being loaded correctly but the css file is not..Can't understand where I'm going wrong..
There should not be any problem with loading your CSS file,
since the folder CSS is in the same directory level as your HTML file.
But the image thats being used in the CSS file is one level up from your CSS file.
Try changing
background:url(images/loader.gif) 50% 50% no-repeat rgb(249,249,249);
to
background:url(../images/loader.gif) 50% 50% no-repeat rgb(249,249,249);
Open your project in editor, go to the folder where your css file is there. Drag and drop your css file on to the code. It will automatically generate the path for you. Hope this will help.
i saw ur folder structure as per your structure following is right link of your external css link.
and also check animation.css is available in css folder
if you are running this application in chrome browser. Just press clt+shift+j OR F12 to see the error. Like the attached image you can see the error on console tab, just fix that
You can give reference to your CSS file using below code
<link href="css/animation.css" type="text/css" rel="stylesheet">
But you have to modify your CSS file
background:url(../images/loader.gif) 50% 50% no-repeat rgb(249,249,249);
You need to determine first whether the CSS file is actually not loaded by checking the network tab as Yasser stated .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.