在这个简短的教程中,我们将创建一个有趣的滑盖页脚的CSS。 下面可以看到页面的html。这基本上是一个常规的HTML5,在
引用谷歌Webfonts字体。 Tutorial: A CSS3 slide-out footer
A CSS3 slide-out footer.
#main元素包装的内容页面。在下一节中,您将看到我们将分配一个积极的z - index值,以便它呈现在页脚。这是页脚本身的标记:在页脚标签,我们有一个无序列表包含四组的链接(使用元素定义)。每组有一个段落,变成了五颜六色的走向,和另一个< ul >持有链接。最外层的< ul >将被设置为位置:固定,使其静态浏览器窗口的底部。 CSS 你可能已经猜到了,这是事情变得有趣的地方。在开始的教程中,我提到我们要处理负面z-index 使页脚固定在屏幕的底部。 我们要做的第一件事,是创建一个叠加上下文对身体的元素assets/css/styles.cssbody{ font:15px/1.3 'PT Sans', sans-serif; color: #5e5b64; /* Create a page-wide stacking context (so that negative margins work as you expect) */ position:relative; z-index:0;}现在所有页面上的其他元素z - index值将根据body堆叠。接下来我们应该分配一个z - index #主要元素,因此,它涵盖了页脚(否则它总是可见,固定窗口的底部)。#main{ position:relative; z-index:1; background-color: #fff; background-image:-webkit-radial-gradient(center, circle farthest-corner, #fff, #e2e2e2); background-image:-moz-radial-gradient(center, circle farthest-corner, #fff, #e2e2e2); background-image:radial-gradient(center, circle farthest-corner, #fff, #e2e2e2); padding: 120px 0 600px; box-shadow: 0 3px 3px rgba(0,0,0,0.2);} z - index值足以让页面上的元素高于所有其他元素没有明确z-indexes集。在大多数浏览器这足以实现我们的行为之后,但不幸的是移动Safari重绘问题,需要设置负面z-indexes页脚。另一件事,我们要做的就是设置背景#main元素。 这是页脚:footer{ height: 245px; color:#ccc; font-size:12px; position:relative; z-index:-2; background-color:#31353a; background-image:-webkit-linear-gradient(top, #31353a, #2f3337); background-image:-moz-linear-gradient(top, #31353a, #2f3337); background-image:linear-gradient(top, #31353a, #2f3337);} 我有设置一个z - index 2的值。把它背后的#主要div。请注意,我们必须给这个元素高度,因为里面有一个固定的UL元素定位及其大小不会扩大其父母。 接下来是UL元素在里面,这是固定在浏览器窗口:footer > ul{ width:960px; position:fixed; left:50%; bottom:0; margin-left:-480px; padding-bottom: 60px; z-index:-1;}设置为1的z - index,导致它显示以下#主要元素,但在页脚,这正是我们想要的。还有几个值得一提的样式:footer > ul > li{ width:25%; float:left;}footer ul{ list-style: none;}/* The links */footer > ul > li ul li{ margin-left:43px; text-transform: uppercase; font-weight:bold; line-height:1.8;}footer > ul > li ul li a{ text-decoration: none !important; color:#7d8691 !important;}footer > ul > li ul li a:hover{ color:#ddd !important;} 我们要额外小心当设置这些风格,因为页脚包含嵌套的极限状态,可能会搞混了。限制的影响风格,我使用CSS选择器>孩子。 接下来是公司标志。从sprite作为图像显示:在元素之前。footer a.logo{ color: #e4e4e4 !important; text-decoration: none !important; font-size: 14px; font-weight: bold; position: relative; text-transform: uppercase; margin-left: 16px; display: inline-block; margin-top: 7px;}footer a.logo i{ font-style: normal; position: absolute; width: 60px; display: block; left: 48px; top: 18px; font-size: 12px; color: #999;}footer a.logo:before{ content: ''; display: inline-block; background: url('../img/sprite.png') no-repeat -19px -70px; width: 48px; height: 37px; vertical-align: text-top;}在这之后,我们可以风格段落元素,它必须转化成色彩鲜艳的标题为每个四个部分。footer p{ width: 90%; margin-right: 10%; padding: 9px 0; line-height: 18px; background-color: #058cc7; font-weight: bold; font-size: 14px; color:#fff; text-transform: uppercase; text-shadow: 0 1px rgba(0,0,0,0.1); box-shadow: 0 0 3px rgba(0,0,0,0.3); margin-bottom: 20px; opacity:0.9; cursor:default; -webkit-transition: opacity 0.4s; -moz-transition: opacity 0.4s; transition: opacity 0.4s;}footer > ul > li:hover p{ opacity:1;}footer p:before{ content: ''; display: inline-block; background: url('../img/sprite.png') no-repeat; width: 16px; height: 18px; margin: 0 12px 0 15px; vertical-align: text-bottom;} 我这里使用的另一个把戏,是我设置不透明度定义的元素是0.9,我将顺利过渡动画的透明度的变化。不透明度设置为1时,触发动画。 最后,这里有不同的颜色主题,创建一些CSS的帮助下梯度:footer p.home{ background-color: #0096d6; background-image:-webkit-linear-gradient(top, #0096d6, #008ac6); background-image:-moz-linear-gradient(top, #0096d6, #008ac6); background-image:linear-gradient(top, #0096d6, #008ac6);}footer p.home:before{ background-position: 0 -110px;}footer p.services{ background-color: #00b274; background-image:-webkit-linear-gradient(top, #00b274, #00a46b); background-image:-moz-linear-gradient(top, #00b274, #00a46b); background-image:linear-gradient(top, #00b274, #00a46b);}footer p.services:before{ background-position: 0 -129px;}footer p.reachus{ background-color: #d75ba2; background-image:-webkit-linear-gradient(top, #d75ba2, #c75496); background-image:-moz-linear-gradient(top, #d75ba2, #c75496); background-image:linear-gradient(top, #d75ba2, #c75496);}footer p.reachus:before{ background-position: 0 -89px;}footer p.clients{ background-color: #e9ac40; background-image:-webkit-linear-gradient(top, #e9ac40, #d89f3b); background-image:-moz-linear-gradient(top, #e9ac40, #d89f3b); background-image:linear-gradient(top, #e9ac40, #d89f3b);}footer p.clients:before{ background-position: 0 -69px;}这使得标题瑰丽多彩,没有任何图像。 ![创建一个整洁的页脚滑盖特效 z-index技巧]()
在线演示
积分下载
6毛下载
砍两刀下载
文件目录······