【问题标题】:Page is loaded without the css applied,and after a secnd it applies the CSS and renders it properly页面在没有应用 css 的情况下加载,一秒钟后它应用 css 并正确呈现它
【发布时间】:2016-12-21 13:47:59
【问题描述】:

我在 IE8 和 IE10 的 localhost 上运行我的项目,页面在没有应用 CSS 的情况下首次加载,一秒钟后它应用 CSS 并正确呈现它。但是,当我在 IE9 中运行它时,一切似乎都工作正常.

我想知道为什么会这样。有人可以告诉我出了什么问题,我将如何解决这个问题?谢谢!

编辑

html代码

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=8"/>
<?php
error_reporting(E_ALL ^ E_NOTICE);
$urls= explode("/",$_SERVER['PHP_SELF']); 
$location=$urls[2];
?>
<title>GASS Security || <?php echo $header_title;?></title>
<link href="css/gass_style.css" rel="stylesheet" type="text/css" /> 
<link rel="stylesheet" href="css/flexslider.css" type="text/css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/elastislide.css" />
<script src="js/html5.js"></script>
<script src="js/jquery-1.10.1.js"></script>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<!-- Place in the <head>, after the three links -->
<script>
$(document).ready(function() {
 /
 $('#menu img').hover(function() {
 var src = $(this).attr('src').substr(0, ($(this).attr('src').length - 4)) + 'Over.jpg';
$(this).attr('src', src)
    }, function() {
var src = $(this).attr("src").replace('Over', '');
 $(this).attr('src', src);
 })
  /
  $('.sumTitle').click(function() {
$(this).next().slideToggle('slow')
$(this).toggleClass('show')
 })

  });
</script>
<script src="js/jquery.flexslider.js"></script>
<!-- Place in the <head>, after the three links -->
<script type="text/javascript" charset="utf-8">
$(window).load(function() {
 $('.flexslider').flexslider({
animation: "slide",
  /*
 slideshowSpeed: 100,           //Integer: Set the speed of the slideshow cycling, in milliseconds
animationSpeed: 100,
  controlNav: true,
directionNav: true,
  pausePlay: true,
pauseText: 'Pause The Slide Show',
  playText: 'Playing The Slide Show'
  */
  });
});
</script>
<!--<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>-->
<script type="text/javascript" src="js/jquery.tmpl.min.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="js/jquery.elastislide.js"></script>
<script type="text/javascript" src="js/gallery.js"></script>
<noscript>
  <style>
  .es-carousel ul{
 display:block;
 }
 </style>
</noscript>
<script id="img-wrapper-tmpl" type="text/x-jquery-tmpl">   
 <div class="rg-image-wrapper">
   {{if itemsCount > 1}}
<div class="rg-image-nav">
 <a href="#" class="rg-image-nav-prev">Previous Image</a>
  <a href="#" class="rg-image-nav-next">Next Image</a>
  </div>
{{/if}}
 <div class="rg-image"></div>
 <div class="rg-loading"></div>
 <div class="rg-caption-wrapper">
 <div class="rg-caption" style="display:none;">
<p></p>
 </div>
</div>
</div>
</script>
<script type="text/javascript" src="Chat.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

 ga('create', 'UA-43258818-1', 'gasssecurity.com');
 ga('send', 'pageview');
</script>
</head>

【问题讨论】:

  • 这与浏览器本身有关。所以,我不知道如何解决它。我只能给你一点信息(你可能已经知道了。不确定。)
  • @XeroElixir 是否与 CSS 缓存有关?
  • 欢迎来到stackoverflow! :-) 请张贴网站的 HTML;至少 ....
  • @JackWilliams,用我的 html 编辑我的问题。至于您的信息,我是这个编程世界的新手,希望您能帮助我。谢谢!
  • 好的,CSS 的链接似乎没问题。您可以尝试在

标签: jquery css internet-explorer


【解决方案1】:

这是一个蓝色到浅蓝色渐变的示例以及在所有浏览器中工作所需的代码:

background: rgb(184, 225, 252);

/* Old browsers */

background: -moz-linear-gradient(left, rgba(184, 225, 252, 1) 0%, rgba(169, 210, 243, 1) 10%, rgba(144, 186, 228, 1) 25%, rgba(144, 188, 234, 1) 37%, rgba(144, 191, 240, 1) 50%, rgba(107, 168, 229, 1) 51%, rgba(162, 218, 245, 1) 83%, rgba(189, 243, 253, 1) 100%);

/* FF3.6+ */

background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(184, 225, 252, 1)), color-stop(10%, rgba(169, 210, 243, 1)), color-stop(25%, rgba(144, 186, 228, 1)), color-stop(37%, rgba(144, 188, 234, 1)), color-stop(50%, rgba(144, 191, 240, 1)), color-stop(51%, rgba(107, 168, 229, 1)), color-stop(83%, rgba(162, 218, 245, 1)), color-stop(100%, rgba(189, 243, 253, 1)));

/* Chrome,Safari4+ */

background: -webkit-linear-gradient(left, rgba(184, 225, 252, 1) 0%, rgba(169, 210, 243, 1) 10%, rgba(144, 186, 228, 1) 25%, rgba(144, 188, 234, 1) 37%, rgba(144, 191, 240, 1) 50%, rgba(107, 168, 229, 1) 51%, rgba(162, 218, 245, 1) 83%, rgba(189, 243, 253, 1) 100%);

/* Chrome10+,Safari5.1+ */

background: -o-linear-gradient(left, rgba(184, 225, 252, 1) 0%, rgba(169, 210, 243, 1) 10%, rgba(144, 186, 228, 1) 25%, rgba(144, 188, 234, 1) 37%, rgba(144, 191, 240, 1) 50%, rgba(107, 168, 229, 1) 51%, rgba(162, 218, 245, 1) 83%, rgba(189, 243, 253, 1) 100%);

/* Opera 11.10+ */

background: -ms-linear-gradient(left, rgba(184, 225, 252, 1) 0%, rgba(169, 210, 243, 1) 10%, rgba(144, 186, 228, 1) 25%, rgba(144, 188, 234, 1) 37%, rgba(144, 191, 240, 1) 50%, rgba(107, 168, 229, 1) 51%, rgba(162, 218, 245, 1) 83%, rgba(189, 243, 253, 1) 100%);

/* IE10+ */

background: linear-gradient(to right, rgba(184, 225, 252, 1) 0%, rgba(169, 210, 243, 1) 10%, rgba(144, 186, 228, 1) 25%, rgba(144, 188, 234, 1) 37%, rgba(144, 191, 240, 1) 50%, rgba(107, 168, 229, 1) 51%, rgba(162, 218, 245, 1) 83%, rgba(189, 243, 253, 1) 100%);

/* W3C */

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b8e1fc', endColorstr='#bdf3fd', GradientType=1);

/* IE6-9 */

【讨论】:

    【解决方案2】:

    确保您的样式位于页面顶部,以便它们在其余资源之前加载。

    <html>
    <title></title>
    <styles here..../>
    <body>
    content ...
    ...
    ...
    ...
    ...
    ...
    <script's here>
    </body>
    </html>
    

    【讨论】:

    • 我用我的部分 html 编辑我的问题,我做得对吗?
    • 是的,您的代码是可以接受的,但最好将所有脚本放在页面末尾的结束正文标记之前,因为它们不需要立即加载。想想浏览器自上而下加载。您可能希望先加载样式,然后加载内容,然后加载脚本,因为在加载页面之前人们不会与您的脚本进行交互。它在某些浏览器中无法正确显示的原因是大多数浏览器的样式不同,有些东西在旧浏览器中受支持,但不是新的,有些旧代码在新浏览器中被弃用。
    猜你喜欢
    • 2021-01-10
    • 1970-01-01
    • 1970-01-01
    • 2023-01-24
    • 2017-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-21
    相关资源
    最近更新 更多