简体   繁体   English

为什么我使用 css 时我的页面没有加载?

[英]Why isn't my page loading when I use css?

I have my page at this site: www.rootscope.in我在这个站点有我的页面: www.rootscope.in

When I use css, particularly this one below:当我使用 css 时,尤其是下面这个:

.loader {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: url(assets/img/icons/loader.svg) no-repeat center center #fe9d68;
    background-size: 60px;
}

HTML: HTML:

<div>
    <div id="content" class="container">
        <!--main content-->
        <div id="wrap">
            <div ui-view="content" id="content"></div>
        </div>
    </div>
</div>

Angular routing:角度路由:

angular.module('myApp').config(['$stateProvider', '$locationProvider', '$urlRouterProvider', function ($stateProvider, $locationProvider, $urlRouterProvider) {

// For any unmatched url, redirect to /login
$urlRouterProvider.otherwise("home");

$stateProvider
.state('home', {
    url: "/home",
    views: {
        content: {
            templateUrl: 'views/home.html',
            controller: function ($scope) {
            }
        },
    }
});

Some of the script used in this template:此模板中使用的一些脚本:

<script src="assets/js/jquery.countdown.min.js"></script>
<script src="assets/js/jquery.easydropdown.min.js"></script>
<script src="assets/js/jquery.flexslider-min.js"></script>
<script src="assets/js/jquery.isotope.min.js"></script>
<script src="assets/js/jquery.themepunch.tools.min.js"></script>
<script src="assets/js/jquery.themepunch.revolution.min.js"></script>
<script src="assets/js/jquery.viewportchecker.min.js"></script>
<script src="assets/js/jquery.waypoints.min.js"></script>

I have this line in the script tag:我在脚本标签中有这一行:

$('.loader').fadeOut('slow'); // End Loader

The page keep showing the loading svg icon animation.页面一直显示加载 svg 图标动画。 When I inspect the page in chrome and remove the .loader class, the page loads but with some styles missing.当我在 chrome 中检查页面并删除.loader类时,页面加载但缺少一些样式。 I could have checked for errors but I purchased this html/css template from a site and I applied angular to it.我本可以检查错误,但我从一个站点购买了这个 html/css 模板,并对其应用了 angular。 I don't understand what is problem with .loader class我不明白.loader class什么问题

A common issue is to load scripts after DOM is loaded, but before AngularJS runs script to load the template page.一个常见的问题是在加载 DOM 之后加载脚本,但在 AngularJS 运行脚本加载模板页面之前。

You should only hide ".loader" after Angular.你应该只在 Angular 之后隐藏“.loader”。 Simplest solution (but not scalable) is just to put it in the angular controller:最简单的解决方案(但不可扩展)只是将它放在角度控制器中:

function controller($scope){
   $('.loader').fadeOut('slow');
}

Actually the loader element is not found on the document load because content is not yet loaded.实际上,在文档加载中找不到加载器元素,因为内容尚未加载。 So use setTimeout here for few seconds then it works prefectly.所以在这里使用 setTimeout 几秒钟,然后它就可以完美地工作了。

$(document).ready(function(){
  setTimeout(function () {
    $('.loader').fadeOut('slow');
  }, 1000);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的打印iframe中的CSS加载不一致? - Why isn't CSS loading consistently in my printing iframe? 为什么CURL JS没有加载我的CSS文件? - Why isn't CURL JS loading my CSS file? 为什么从其他子域调用时我的离线缓存子域页面没有加载? - Why isn't my offline cached subdomain page not loading when called from other subdomain? 为什么使用iPhone加载页面时未选择我的默认选项? - Why isn't my default option selected when loading page using iphone? 为什么我的页面没有在 Github 上加载? - Why isn't my page loading up on Github? 当我将其导入Wordpress网站时,为什么我的JQuery / CSS代码不起作用? - Why isn't my JQuery/CSS code working when I import it into my Wordpress website? 为什么当我尝试在滚动时更改它时我的旋转 css 不起作用? - why my rotate css isn't working when I try to change it while scroll? 当我单击表单提交按钮时,为什么不进入下一页? - Why isn't my form submit button not going to a next page when I click on it? 当我刷新页面时,绝对定位元素未隐藏在我的布局中。 为什么? - When I refresh a page the absolte positioned element isn't hidden in my layout. Why? 当我重新访问页面时,我的cookie无法正常工作 - My cookie isn't working when I revisit the page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM