1

我对网页设计的想法完全为零。

如果你去http://caroufredsel.frebsite.nl/examples/carousel-lightbox-tooltip.php你会发现CSS、JavaScript和HTML代码已经分开提到了。我如何整合它们?CSS 和 JavaScript 应该放在 head 标签内吗?

4

3 回答 3

3

你需要有类似的东西

<link rel="stylesheet" href="css/style.css">
<script src="js/script.js"></script>

在 .html 文件的头部内。

如果您可以将 JavaScript 不是放在头部,而是放在 body 标记的末尾,那就更好了。

这意味着你有

  • .html 文件
  • 一个名为 css 的文件夹,其中包含一个 style.css 文件,您在其中拥有...当然是所有 CSS
  • 一个名为 js 的文件夹,其中包含一个 script.js 文件,其中有您的 JavaScript 代码
于 2012-05-28T08:45:51.760 回答
3

是的,您是正确的,它们可以集成到Head Section中。

例如:

<style type="text/css">

    /* Place the contents of the file.css here */

</style>


<script type="text/javascript">

    // Place the contents of the file.js here.

</script>
于 2012-05-28T08:49:06.837 回答
1

如果有必要,您可以将所有代码放在一个文件中。

以非常简化的方式:

<html>
    <head>
        <script>/*javascript goes here*/</script>
        <style>/*css goes here*/</style>
    </head>
    <body>/*content goes here*/</body>
</html>
于 2012-05-28T08:51:50.627 回答