【问题标题】:"Fake hacker code" in html with css and js [closed]带有css和js的html中的“假黑客代码”[关闭]
【发布时间】:2016-09-30 22:29:04
【问题描述】:

我找到了一些我想测试的代码。我在这里想念什么? 我没有很多使用 JS 的经验,我不确定我是否遗漏了什么。如果有人能够提供帮助,我会非常高兴! 这是我的html:

<html>
    <head>
<meta charset="utf-8">
<title>Test</title>
<link rel="stylesheet" type="text/css" href="spaced.css">
<link rel="shortcut icon" type="image/png" href="http://test.noa16.png"/>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:300' rel='stylesheet' type='text/css'>
</head>
<body>
<p class="text" data-text="test text 010101101010101 lolol whatever"</p>
<script>
   var printText = $('.text').data('text');

var contentArray = printText.split('/n');
$.each(contentArray, function(index, newLine) {
  $('.text').append('<span style="display:block;" id="'+index+'"></span>');

  var lineID = index;
  var self = $(this);
    setTimeout(function () {
      $.each(self, function(index, chunk){
          setTimeout(function () {
            $('#'+lineID).append("<span>"+chunk+"</span>");
            $('body, html').scrollTop($(document).height());
          }, index*5);
      });

    }, index*100);
}); 
</script>
</body>

</html>

这是我的 CSS:

span {
  min-width: 5px;
  display: inline-block;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 0.85em;
  letter-spacing: 1.5px;
  color: #FFF;
}

body {
  background: #111;
  position: relative;
}

body, html {
   height: 100%;
}

.text {
  overflow: hidden;
  height: auto;
}

有人知道为什么这对我不起作用吗?

【问题讨论】:

  • 您的p 标签格式不正确。除此之外:您还没有告诉我们您希望这段代码做什么,或者您不希望它目前正在做什么?
  • 嘿!我希望它像这里显示的那样工作:codepen.io/hparton/pen/idDGK?editors=1011
  • 好的,损坏的p 标签似乎就是它的全部。你还没有关闭它。 "&lt;/p&gt; 应该是 "&gt;&lt;/p&gt;
  • 我只是在这里弄乱了 p 标签,正如您在链接中看到的那样,我删除了很多随机文本。但是现在在现场直播中,p 标签已关闭。但是当我加载页面时,它只显示黑屏。没有文字显示!
  • 你是否包含了 jQuery 库?在上面的代码中看起来不像。 &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"&gt;&lt;/script&gt;

标签: javascript html css


【解决方案1】:
  1. 关闭你的&lt;p&gt;标签
  2. 脚本使用 jQuery,注意 $ 符号,下载或使用 CDN 并将其放在脚本上方
  3. 在执行代码之前确保页面已完全加载

    $(document).ready(function(){
        // your script here
    });
    

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-02
    • 2015-05-17
    • 2011-01-13
    • 2010-10-16
    • 2016-07-08
    • 1970-01-01
    • 2012-11-30
    • 2012-07-12
    相关资源
    最近更新 更多