2015-02-23 46 views
0

我對使用skel框架的響應式網站使用模板(html5up.net/prologue)。使用skel框架構建的響應式網站僅在使用漂亮的URL時才應用CSS

除了當我通過一個漂亮的URL訪問網站時,該網站完全正常。例如:example.com/fake-dir/。 dir虛假目錄不存在,漂亮的URL使webserver在根目錄中查找。出於某種原因,使用漂亮的URL時,css風格不適用。它適用的prety網址我的.htaccess如下:

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ./[L] 

我已經找到了到init.js並有一種感覺,它跟JS是如何嘗試應用CSS文件的問題。我認爲它正在根目錄/ css中查找位於漂亮url目錄/ css中的css文件。我已經嘗試在init.js的開頭添加一個絕對路徑,如這裏所示的不同樣式,但沒有奏效。 'global':{range:'*',href:'example.com/css/style.css',containers:1400,grid:{gutters:40},viewport:{scalable:false}},

這是整個init.js文件。任何幫助appriciated。

/* 
Prologue by HTML5 UP 
html5up.net | @n33co 
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 
*/ 

(function($) { 

    skel.init({ 
     reset: 'full', 
     breakpoints: { 
      'global': { range: '*', href: 'css/style.css', containers: 1400, grid: { gutters: 40 }, viewport: { scalable: false } }, 
      'wide': { range: '961-1880', href: 'css/style-wide.css', containers: 1200, grid: { gutters: 40 } }, 
      'normal': { range: '961-1620', href: 'css/style-normal.css', containers: 960, grid: { gutters: 40 } }, 
      'narrow': { range: '961-1320', href: 'css/style-narrow.css', containers: '100%', grid: { gutters: 20 } }, 
      'narrower': { range: '-960', href: 'css/style-narrower.css', containers: '100%', grid: { gutters: 20 } }, 
      'mobile': { range: '-736', href: 'css/style-mobile.css', containers: '100%!', grid: { collapse: true } } 
     }, 
     plugins: { 
      layers: { 
       config: { 
        mode: 'transform' 
       }, 
       sidePanel: { 
        hidden: true, 
        breakpoints: 'narrower', 
        position: 'top-left', 
        side: 'left', 
        animation: 'pushX', 
        width: 240, 
        height: '100%', 
        clickToHide: true, 
        html: '<div data-action="moveElement" data-args="header"></div>', 
        orientation: 'vertical' 
       }, 
       sidePanelToggle: { 
        breakpoints: 'narrower', 
        position: 'top-left', 
        side: 'top', 
        height: '4em', 
        width: '5em', 
        html: '<div data-action="toggleLayer" data-args="sidePanel" class="toggle"></div>' 
       } 
      } 
     } 
    }); 

    $(function() { 

     var $window = $(window), 
      $body = $('body'); 

     // Disable animations/transitions until the page has loaded. 
      $body.addClass('is-loading'); 

      $window.on('load', function() { 
       $body.removeClass('is-loading'); 
      }); 

     // CSS polyfills (IE<9). 
      if (skel.vars.IEVersion < 9) 
       $(':last-child').addClass('last-child'); 

     // Forms (IE<10). 
      var $form = $('form'); 
      if ($form.length > 0) { 

       $form.find('.form-button-submit') 
        .on('click', function() { 
         $(this).parents('form').submit(); 
         return false; 
        }); 

       if (skel.vars.IEVersion < 10) { 
        $.fn.n33_formerize=function(){var _fakes=new Array(),_form = $(this);_form.find('input[type=text],textarea').each(function() { var e = $(this); if (e.val() == '' || e.val() == e.attr('placeholder')) { e.addClass('formerize-placeholder'); e.val(e.attr('placeholder')); } }).blur(function() { var e = $(this); if (e.attr('name').match(/_fakeformerizefield$/)) return; if (e.val() == '') { e.addClass('formerize-placeholder'); e.val(e.attr('placeholder')); } }).focus(function() { var e = $(this); if (e.attr('name').match(/_fakeformerizefield$/)) return; if (e.val() == e.attr('placeholder')) { e.removeClass('formerize-placeholder'); e.val(''); } }); _form.find('input[type=password]').each(function() { var e = $(this); var x = $($('<div>').append(e.clone()).remove().html().replace(/type="password"/i, 'type="text"').replace(/type=password/i, 'type=text')); if (e.attr('id') != '') x.attr('id', e.attr('id') + '_fakeformerizefield'); if (e.attr('name') != '') x.attr('name', e.attr('name') + '_fakeformerizefield'); x.addClass('formerize-placeholder').val(x.attr('placeholder')).insertAfter(e); if (e.val() == '') e.hide(); else x.hide(); e.blur(function(event) { event.preventDefault(); var e = $(this); var x = e.parent().find('input[name=' + e.attr('name') + '_fakeformerizefield]'); if (e.val() == '') { e.hide(); x.show(); } }); x.focus(function(event) { event.preventDefault(); var x = $(this); var e = x.parent().find('input[name=' + x.attr('name').replace('_fakeformerizefield', '') + ']'); x.hide(); e.show().focus(); }); x.keypress(function(event) { event.preventDefault(); x.val(''); }); }); _form.submit(function() { $(this).find('input[type=text],input[type=password],textarea').each(function(event) { var e = $(this); if (e.attr('name').match(/_fakeformerizefield$/)) e.attr('name', ''); if (e.val() == e.attr('placeholder')) { e.removeClass('formerize-placeholder'); e.val(''); } }); }).bind("reset", function(event) { event.preventDefault(); $(this).find('select').val($('option:first').val()); $(this).find('input,textarea').each(function() { var e = $(this); var x; e.removeClass('formerize-placeholder'); switch (this.type) { case 'submit': case 'reset': break; case 'password': e.val(e.attr('defaultValue')); x = e.parent().find('input[name=' + e.attr('name') + '_fakeformerizefield]'); if (e.val() == '') { e.hide(); x.show(); } else { e.show(); x.hide(); } break; case 'checkbox': case 'radio': e.attr('checked', e.attr('defaultValue')); break; case 'text': case 'textarea': e.val(e.attr('defaultValue')); if (e.val() == '') { e.addClass('formerize-placeholder'); e.val(e.attr('placeholder')); } break; default: e.val(e.attr('defaultValue')); break; } }); window.setTimeout(function() { for (x in _fakes) _fakes[x].trigger('formerize_sync'); }, 10); }); return _form; }; 
        $form.n33_formerize(); 
       } 

      } 

     // Scrolly links. 
      $('.scrolly').scrolly(); 

     // Nav. 
      var $nav_a = $('#nav a'); 

      // Scrolly-fy links. 
       $nav_a 
        .scrolly() 
        .on('click', function(e) { 

         var t = $(this), 
          href = t.attr('href'); 

         if (href[0] != '#') 
          return; 

         e.preventDefault(); 

         // Clear active and lock scrollzer until scrolling has stopped 
          $nav_a 
           .removeClass('active') 
           .addClass('scrollzer-locked'); 

         // Set this link to active 
          t.addClass('active'); 

        }); 

      // Initialize scrollzer. 
       var ids = []; 

       $nav_a.each(function() { 

        var href = $(this).attr('href'); 
        if (href[0] != '#') 
         return; 

        ids.push(href.substring(1)); 

       }); 

       $.scrollzer(ids, { pad: 200, lastHack: true }); 

    }); 

})(jQuery); 

回答

0

這不是模板或js的問題。這是我第一次打電話給js文件的方式。我沒有使用絕對路徑