萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> 安卓開發 >> html5背景彈性滾動的代碼

html5背景彈性滾動的代碼

下面我們給大家介紹一下html5背景彈性滾動吧!希望大家可以在這裡學習!

<!DOCTYPE html PUBLIC "<fp class='fp-upbz8'></fp>//W<fp class='fp-d41gt'></fp>C//DTD XHTML <fp class='fp-ruy1v'></fp><fp class='fp-bldj4'></fp><fp class='fp-oultd'></fp> Transitional//EN" "

<html xmlns="

<head>

<title>背景彈性滾動的導航效果</title>

<FCK:meta http<fp class='fp-upbz8'></fp>equiv="content<fp class='fp-1v1b9'></fp>type" content="text/html;charset=gb<fp class='fp-x771l'></fp><fp class='fp-2eh49'></fp><fp class='fp-ruy1v'></fp><fp class='fp-n64r7'></fp>" />

<!--把下面代碼加到<head>與</head>之間-->

<style type="text/css">

<fp class='fp-9l8gb'></fp>nav<fp class='fp-1v1b9'></fp>wrap {

margin: <fp class='fp-xpp6p'></fp> auto;

background<fp class='fp-1v1b9'></fp>color: #<fp class='fp-h4nt0'></fp><fp class='fp-bx5ln'></fp><fp class='fp-mioo1'></fp><fp class='fp-n64r7'></fp><fp class='fp-mioo1'></fp><fp class='fp-n64r7'></fp>;

border<fp class='fp-upbz8'></fp>top: <fp class='fp-6926a'></fp>px solid #FFF;

border<fp class='fp-upbz8'></fp>bottom: <fp class='fp-ruy1v'></fp>px solid #FFF;

}

<fp class='fp-5qnea'></fp>group:after {

visibility: hidden;

display: block;

font<fp class='fp-1v1b9'></fp>size: <fp class='fp-jbjo6'></fp>;

content: " ";

clear: both;

height: <fp class='fp-oultd'></fp>;

}

*:first<fp class='fp-upbz8'></fp>child+html <fp class='fp-5qnea'></fp>group { /* IE<fp class='fp-07l83'></fp> */

zoom: <fp class='fp-h4nt0'></fp>;

}

#example {

width: <fp class='fp-32y6f'></fp><fp class='fp-6lu8t'></fp><fp class='fp-lngti'></fp>px;

margin: <fp class='fp-oultd'></fp> auto;

list<fp class='fp-1v1b9'></fp>style: none;

position: relative;

}

#example li {

display: inline;

}

#example li a {

position: relative;

z<fp class='fp-upbz8'></fp>index: <fp class='fp-bx5ln'></fp><fp class='fp-jbjo6'></fp><fp class='fp-jbjo6'></fp>;

color: #AAA;

font<fp class='fp-upbz8'></fp>size: <fp class='fp-h4nt0'></fp><fp class='fp-426b4'></fp>px;

display: block;

float: left;

padding: <fp class='fp-6926a'></fp><fp class='fp-bx5ln'></fp>px <fp class='fp-h4nt0'></fp><fp class='fp-jbjo6'></fp>px <fp class='fp-6926a'></fp><fp class='fp-xpp6p'></fp>px <fp class='fp-6926a'></fp><fp class='fp-xpp6p'></fp>px;

text<fp class='fp-cllot'></fp>decoration: none;

text<fp class='fp-cllot'></fp>transform: uppercase;

}

#example li a:hover {

color: #FFF;

}

#example #magic<fp class='fp-upbz8'></fp>line<fp class='fp-8lzbm'></fp>two {

width: <fp class='fp-ruy1v'></fp><fp class='fp-jbjo6'></fp><fp class='fp-jbjo6'></fp>px;

position: absolute;

top: <fp class='fp-lngti'></fp>;

left: <fp class='fp-xpp6p'></fp>;

background: #<fp class='fp-kbrtv'></fp><fp class='fp-kbrtv'></fp><fp class='fp-kbrtv'></fp>;

z<fp class='fp-upbz8'></fp>index: <fp class='fp-mioo1'></fp><fp class='fp-xpp6p'></fp><fp class='fp-lngti'></fp>;

<fp class='fp-upbz8'></fp>moz<fp class='fp-upbz8'></fp>border<fp class='fp-upbz8'></fp>radius: <fp class='fp-4qe9l'></fp>px;

<fp class='fp-8lzbm'></fp>webkit<fp class='fp-upbz8'></fp>border<fp class='fp-1v1b9'></fp>radius: <fp class='fp-hbeld'></fp>px;

}

<fp class='fp-bldj4'></fp>current a {

color: #FFF !important;

}

</style>

<script type="text/javascript" src="http://www.zzsky.cn/effect/images/jquery.min.js"></script>

<script type="text/javascript">

$(function(){

var $el<fp class='fp-z7d4e'></fp> leftPos<fp class='fp-q6iyp'></fp> newWidth<fp class='fp-2jief'></fp>

$mainNav = $(<fp class='fp-gg6qu'></fp>#example<fp class='fp-w8zww'></fp>);

/*

EXAMPLE

*/

$mainNav<fp class='fp-9l8gb'></fp>append(<fp class='fp-jnbqp'></fp><li id='magic-line-two'></li><fp class='fp-yvo3r'></fp>);

var $magicLineTwo = $(<fp class='fp-yvo3r'></fp>#magic<fp class='fp-cllot'></fp>line<fp class='fp-1v1b9'></fp>two<fp class='fp-yvo3r'></fp>);

$magicLineTwo

<fp class='fp-r5q3d'></fp>width($(<fp class='fp-gg6qu'></fp><fp class='fp-bldj4'></fp>current<fp class='fp-gg6qu'></fp>)<fp class='fp-9l8gb'></fp>width())

<fp class='fp-9l8gb'></fp>height($mainNav<fp class='fp-r5q3d'></fp>height())

<fp class='fp-5qnea'></fp>css(<fp class='fp-w8zww'></fp>left<fp class='fp-jnbqp'></fp><fp class='fp-q6iyp'></fp> $(<fp class='fp-gg6qu'></fp><fp class='fp-5qnea'></fp>current a<fp class='fp-yvo3r'></fp>)<fp class='fp-bldj4'></fp>position()<fp class='fp-r5q3d'></fp>left)

<fp class='fp-9l8gb'></fp>data(<fp class='fp-gg6qu'></fp>origLeft<fp class='fp-jnbqp'></fp><fp class='fp-q6iyp'></fp> $(<fp class='fp-yvo3r'></fp><fp class='fp-5qnea'></fp>current a<fp class='fp-w8zww'></fp>)<fp class='fp-5qnea'></fp>position()<fp class='fp-r5q3d'></fp>left)

<fp class='fp-9l8gb'></fp>data(<fp class='fp-jnbqp'></fp>origWidth<fp class='fp-yvo3r'></fp><fp class='fp-a9ojh'></fp> $magicLineTwo<fp class='fp-9l8gb'></fp>width())

<fp class='fp-9l8gb'></fp>data(<fp class='fp-jnbqp'></fp>origColor<fp class='fp-gg6qu'></fp><fp class='fp-a9ojh'></fp> $(<fp class='fp-yvo3r'></fp><fp class='fp-5qnea'></fp>current a<fp class='fp-w8zww'></fp>)<fp class='fp-bldj4'></fp>attr(<fp class='fp-jnbqp'></fp>rel<fp class='fp-gg6qu'></fp>));

$(<fp class='fp-gg6qu'></fp>#example li<fp class='fp-yvo3r'></fp>)<fp class='fp-bldj4'></fp>find(<fp class='fp-yvo3r'></fp>a<fp class='fp-jnbqp'></fp>)<fp class='fp-bldj4'></fp>hover(function() {

$el = $(this);

leftPos = $el<fp class='fp-5qnea'></fp>position()<fp class='fp-r5q3d'></fp>left;

newWidth = $el<fp class='fp-5qnea'></fp>parent()<fp class='fp-bldj4'></fp>width();

$magicLineTwo<fp class='fp-9l8gb'></fp>stop()<fp class='fp-9l8gb'></fp>animate

copyright © 萬盛學電腦網 all rights reserved