CSS导航栏 点击后跳动

html-css08

CSS导航栏 点击后跳动,第1张

请问楼主是用的cms还是直接调用的呢?

请楼主贴出代码,楼主您要的子菜单效果是哪种类型的呢?

楼主要的这种菜单应该是用js实现的吧!

你可以在百度pm我,愿意帮你看下!

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>HTML5爱心跳动动画DEMO演示</title>

<style>

@import url(http://fonts.googleapis.com/css?family=Inconsolata:400,700)

@import url(http://fonts.googleapis.com/css?family=Hammersmith+One)

body {

background-color: #ccc

}

.container {

width: 512px

height: 380px

margin: auto

margin-top: 0

}

.heart {

z-index: 1

width: 150px

height: 150px

position: absolute

top: 50%

margin-top: -75px

left: 50%

margin-left: -75px

background-size: 100%

background-repeat: no-repeat

background-image:url("data:image/svg+xmlbase64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgd2lkdGg9IjE3M3B4IiBoZWlnaHQ9IjE1OHB4IiB2aWV3Qm94PSIwIDAgMTczIDE1OCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMTczIDE1OCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8cGF0aCBmaWxsPSIjRUY0NjU3IiBkPSJNMTU3LjMzMSwxNS41MDRjLTE5LjU1OS0xOS41NTktNTEuMjcxLTE5LjU1OS03MC44MzEsMGMtMTkuNTU5LTE5LjU1OS01MS4yNzEtMTkuNTU5LTcwLjgzMSwwDQoJYy0xOS41NTksMTkuNTU5LTE5LjU1OSw1MS4yNzEsMCw3MC44MzFsNzAuODMxLDcwLjgzbDcwLjgzMS03MC44M0MxNzYuODksNjYuNzc1LDE3Ni44OSwzNS4wNjQsMTU3LjMzMSwxNS41MDR6Ii8+DQo8L3N2Zz4=")

}

.hometown {

font-family:'Inconsolata', sans-serif

font-weight: bold

font-size: 2.0em

text-transform: uppercase

position: relative

z-index: 1

width: 512px

height: 512px

color: #FFF

}

#top {

width: 200px

margin: auto

position: relative

}

#top span {

height: 350px

position: absolute

width: 20px

left: 50%

margin-left: -10px

top: 110px

}

.char1 {

transform: rotate(-36deg)

}

.char2 {

transform: rotate(-24deg)

}

.char3 {

transform: rotate(-12deg)

}

.char4 {

transform: rotate(0deg)

}

.char5 {

transform: rotate(12deg)

}

.char6 {

transform: rotate(24deg)

}

.char7 {

transform: rotate(36deg)

}

#bottom span {

height: 350px

line-height: 700px

position: absolute

width: 20px

left: 50%

margin-left: -10px

top: 10px

}

#bottom .char1 {

transform: rotate(36deg)

}

#bottom .char2 {

transform: rotate(27deg)

}

#bottom .char3 {

transform: rotate(18deg)

}

#bottom .char4 {

transform: rotate(9deg)

}

#bottom .char5 {

transform: rotate(0deg)

}

#bottom .char6 {

transform: rotate(-9deg)

}

#bottom .char7 {

transform: rotate(-18deg)

}

#bottom .char8 {

transform: rotate(-27deg)

}

#bottom .char9 {

transform: rotate(-36deg)

}

.city {

font-family:"Hammersmith One"

display: inline-block

width: 100%

height: 300px

padding-top: 45px

text-align: center

font-size: 3.0em

z-index: 100

position: absolute

top: 50%

margin-top: -110px

}

.heart {

animation: HEARTBEAT 2.5s infinite

}

#top span {

animation: BOUNCE 2.5s infinite

}

@keyframes HEARTBEAT {

0% {

transform: scale(1)

}

5% {

transform: scale(1.3)

}

10% {

transform: scale(1.1)

}

15% {

transform: scale(1.5)

}

50% {

transform: scale(1)

}

100% {

transform: scale(1)

}

}

@keyframes BOUNCE {

0% {

top: 110px

}

10% {

top: 80px

}

15% {

top: 85px

}

20% {

top: 70px

}

75% {

top: 110px

}

100% {

top: 110px

}

}

</style>

<script src="js/prefixfree.min.js"></script>

</head>

<body>

<div class="container bg">

<div class="hometown">

<div class="heart">

</div>

<div id="top">Made in</div>

<div class="city">Boise</div>

<div id="bottom">With love</div>

</div>

</div>

<div style="text-align:centerclear:both">

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

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

</div>

<script src='js/jquery.js'></script>

<script src='js/jquery.lettering.js'></script>

<script src="js/index.js"></script>

</body>

</html>

js部分

animation实现动画由俩个部分组成,通过类似flash动画的关键帧来申明一个动画,在animation属性中调用关键帧声明的动画实现一个更为复杂的动画效果

关键帧 例如:

调用关键帧:

语法 animation:animation-name animation-duration animation-timing-function  animation-delay animation-iteration-count animation-direction

animation-name 由 @keyframes 创建的动画名称

animation-duration过渡时间

animation-timing-function过渡方式

animation-delay延迟时间

animation-iteration-count 动画的播放次数 通常值为1次 特殊值infinite为无限播放

animation-direction动画的播放方向,alternate为偶数次向前播放,normal动画每次都是循环向前播放

练习如下:

该图形的变化从左上角到右上角来回跳动的一个过程

linear  规定以相同速度开始至结束的过渡效果

ease  规定慢速开始,然后变快,然后慢速结束的过渡效果(默认值)

ease-in 规定以慢速开始的过渡效果

ease-out  规定以慢速结束的过渡效果

ease-in-out 规定以慢速开始和结束的过渡效果

 perspective:500px透视 也可以理解为视距,可以理解为 你的眼睛距离物体的距离  距离物体越近 物体就越大,距离物体越远 物体就越小

transform: rotateZ(30deg) rotateZ是绕着z轴旋转 正值是顺时针旋转 负值是逆时针旋转

transform: rotateY(30deg) rotateY是绕着y轴旋转 正值是向里面旋转 负值是向外面旋转

transform: rotateX(30deg)rotateX是绕着x轴旋转 正值是向里面旋转 负值是向外面旋转

transform: rotate(30deg)参数a取正值时元素相对原来中心顺时针旋转

 transform: translate3d(0, 0, 200px)效果如下:

 translate3d(0,0,200px) 表示z轴向前移动二楼200px(近大远小的原理)

 translate3d 里面分别表示x轴距离 y轴距离 和z轴距离

 要想实现3d效果必须要在父元素上加上一个属性perspective

如果想让子元素有3d的效果 必须要给父元素设置transform-style,默认值是flat, 想变成3d效果要把值设置成preserve-3d

也可以 设置旋转后的div的上下位置,在.b:hover里面加上transform-origin:top/bottom/left/right