如何将代码从网页传输到CSS [英] How do transfer code from Web page to CSS

查看:91
本文介绍了如何将代码从网页传输到CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是滚动程序的代码.由于存在多个页面,因此我需要将代码移至CSS文件,以便在更改右侧显示的数字时,更改会反映在所有页面上.

"260","700","7000"

Below is code for a scrolling program. As there are multiple pages I require to move code to the CSS file so that when I change the numbers shown on the right, the change is reflected on all the pages.

"260", "700", "7000"

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>
Daniel
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
@import "css/rich-scroller.css";
</style>
<script src="js/dw_scroller.js" type="text/javascript">
</script>
<script type="text/javascript">

function initScroller() { // arguments:
id of layer that scrolls, width and height of scroller (of wn), // number of items (including
repeated 1st item), axis ("v" or "h") // set up pause/resume onmouseover/out?
(true or false) var scr1 = new dw_scroller('cnt', 400, 260,200, "v", true); scr1.setTiming(700, 7000); }
</script>

推荐答案

那不是CSS文件的用途.

您需要做的就是将initScroller()函数移至.js文件,例如您已经拥有的 dw_scroller.js 文件,然后在页面中引用.js文件,然后进行任何更改您对.js文件所做的操作将被所有引用该文件的页面使用.
That''s not what a CSS file is for.

All you need to do is to move your initScroller() function to a .js file, like the dw_scroller.js file that you already have then you reference the .js file in your pages, then any changes you make to the .js file are used by all pages that reference it.


这篇关于如何将代码从网页传输到CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆