如何从codepen中获取代码,并在我的文本编辑器中编辑保存?
How do I take the code from codepen, and use it locally in my text-editor?
http://codepen.io/mfields/pen/BhILt
我想【xiǎng】在【zài】本地创建一个播放【fàng】,但是当我用chrome打开它时,我【wǒ】得到一个空白的白页【yè】,没【méi】有任何【hé】东西【xī】。
I am trying to have a play with this creation locally, but when I open it in chrome, I get a blank white page with nothing going on.
<!DOCTYPE HTML>
<html>
<head>
<script> src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="celtic.js"></script>
<link rel="stylesheet" type="text/css" src="celtic.css"></link>
</head>
<body>
<canvas id="animation" width="400" height="400"></canvas>
</body>
</html>
我有复制,粘【zhān】贴【tiē】和保存css和js到不【bú】同的【de】文件并保存,然后尝【cháng】试将它们链接【jiē】到html文件,如上所示。
I have copy, pasted and saved the css and js into different files and saved them, then tried to link them into the html file as I have shown above.
我【wǒ】还包括jquery库,因【yīn】为【wéi】我理【lǐ】解很多codepen创作使用【yòng】它。
I have also included the jquery library as I understand a lot of the codepen creations use it.
我得到的唯一的控制台错误是
The only console error I'm getting is
Uncaught TypeError: Cannot read property 'getContext' of null
链接到我的js文件第4行
which is linking to my js file, line 4
(function(){
var canvas = document.getElementById( 'animation' ),
c = canvas.getContext( '2d' ),
对【duì】不起【qǐ】,如果这是【shì】愚蠢的【de】, 。我相信这是【shì】基本的,任何帮助将是真棒!
Sorry if this is dumb, but I'm new to all this. I'm sure this is basic as hell. Any help would be awesome!
Joe Fitter是正确的,但【dàn】我【wǒ】认为最【zuì】好导出您【nín】的笔(使用导出导出.zip选项在本地使用笔【bǐ】)。这将给你一个工作版本的笔,而不必复制【zhì】和【hé】粘贴CSS,JavaScript和HTML代码【mǎ】,而不【bú】必对其【qí】进行更【gèng】改【gǎi】,使其【qí】工作。
Joe Fitter is right, but I think is better to export your pen (use the export to export.zip option for using your pen locally). This will give you a working version of your pen without having to copy and paste the CSS, JavaScript and HTML code and without having to make changes on it for making it work.
版权所有:深圳市网商在线科技有限公司
友情链接: