如何将html、css和javascript编码结合起来使我的旋转木马工作

How do i combine html, css and javascript coding to make my carousel work?

本文关键字:起来 结合 我的 工作 旋转木马 编码 javascript html css      更新时间:2023-09-26

我将以下代码拆分为html、css和javascript,但我不知道如何将它们组合在记事本中,以便将其嵌入到我的网站上。(图片来源和文本只是示例。(

HTML

<div id="wrapper">
<div id="text">
    <h3>Geneva International Motor Show</h3>
    <p>The Geneva International Motor Show will open to the public from 03 to       13 March, presenting more than 260 exhibitors and more than 175 world and European premieres. 02 March 2011.<br />
        <small>Source: <a href="http://gigapica.geenstijl.nl/2011/03/geneva_international_motor_sho.html" target="_blank">gigapica.geenstijl.nl</a></small></p>
</div>
<div id="images">
    <div id="a">
        <img src="img/car1.jpg" alt="car1" width="275" height="200" />
        <span>The new Swiss Sbarro TwoFort100 Concept car is shown during the press day at the 81st Geneva International Motor Show in Geneva, Switzerland, on 01 March 2011. </span>
    </div>
    <div>
        <img src="img/car2.jpg" alt="car2" width="275" height="200" />
        <span>The new Toyota FT-86 II Concept car on display during the press day at the 81st Geneva International Motor Show in Geneva, Switzerland, 02 March 2011. </span>
    </div>
    <div>
        <img src="img/car3.jpg" alt="car5" width="275" height="200" />
        <span>The new Renault Dezir Concept car is on display during the press day at the 81st Geneva International Motor Show in Geneva, Switzerland, 02 March 2011. </span>
    </div>
    <div>
        <img src="img/car4.jpg" alt="car6" width="275" height="200" />
        <span>The new Dodge Challenger SRT8 392 is on display during the press day at the 81st Geneva International Motor Show in Geneva, Switzerland, 02 March 2011.</span>
    </div>
    <div>
        <img src="img/car5.jpg" alt="car8" width="275" height="200" />
        <span>The new Nissan Esflow Concept car is on display during the press day at the 81st Geneva International Motor Show in Geneva, Switzerland, 02 March 2011. </span>
    </div>
    <div>
        <img src="img/car6.jpg" alt="car9" width="275" height="200" />
        <span>A study of Volkswagen named Bulli is on display at International Geneva Motor Show at the Palexpo fairground in Geneva, Switzerland, 03 March 2011</span>
    </div>
</div>
</div>

CSS

 html, body {
    height: 100%;
    padding: 0;
    margin: 0;
    }
    body {
    min-height: 650px;
}
    body * {
    font-family: Arial, Geneva, SunSans-Regular, sans-serif;
    font-size: 14px;
    color: #333;
    line-height: 22px;
}
    #wrapper {
    width: 825px;
    margin: 0 0 0 -412px;
    position: absolute;
    left: 50%;
    top: 30px;
}
    #text h3 {
    font-size: 26px;
}
    #text small, #text small * {
    font-size: 12px;
    color: #666;
}
    #images {
    width: 900px;
    overflow: hidden;
}
    #images div, #images img {
    display: block;
    float: left;
    width: 275px;
    height: 200px;
}
    #images span {
    background-color: black;
    color: #ccc;
    display: block;
    float: left;
    width: 215px;
    height: 160px;
    padding: 40px 30px 0 30px;
    }

Javascript

$(function() {
    $('#images > div').each(function() {
        var $cfs = $(this);
        $cfs.carouFredSel({
            direction: 'up',
            circular: false,
            infinite: false,
            auto: false,
            scroll: {
                queue: 'last'
            },
            items: {
                visible: 1,
                width: 275,
                height: 200
            }
        });
        $cfs.hover(
            function() {
                $cfs.trigger('next');
            },
            function() {
                $cfs.trigger('prev');
            }
        );
    });
    });

如果能在这方面提供任何帮助,我们将不胜感激!!!

<!DOCTYPE html>
<html lang"en">
  <head>
    <meta charset="utf-8">
    <title>...</title>
    <link rel="stylesheet" type="text/css" href="path/to/your.css" />
    <script src="path/to/your.js"></script>
  </head>
  <body>
   ...your html
  </body>
</html>

我添加了一些通常出现在html文档头部的内容,比如charset和lang属性。此外,此doctype适用于html5。

您可以内联引用代码,也可以链接到文件。

要内联引用所有内容,请将CSS放在HTML上方:

<style>
</style>

然后将您的javascript放在:之间

<script>
</script>

将CSS保存到文档中,比如slider.CSS

将您的javascript保存到一个名为slider.js 的文件中

然后用链接到它们

<link href="slider.css" type="text/css" rel="stylesheet" />

<script src="slider.js" type="text/javascript></script>

请注意,以上两个代码片段必须放置在<head></head>标签

将其添加到html文件的<head>部分:

<link rel="stylesheet" href="yourcssfilename.css"/>
<script type="text/javascript" src="yourjsfilename.js"/>
<head>
<script type="text/javascript" src="<Location and filename of Javascript file including file extension>"></script>
<link rel="stylesheet" type="text/css" href="<Location and filename of CSS file including file extension>">
</head>

将这些内容替换为服务器/机器上的实际文件位置。