框架集
- 框架集和内联框架的作用类似,都是用于在一个页面中引入其他的外部的页面框架集可以同时引入多个页面,而内联框架只能引入一个在h5标准中,推荐使用框架集,而不使用内联框架.
- 使用frameset来创建一个框架集,注意frameset不能和body出现在同一个页面中所以要使用框架集,页面中就不可以使用body标签.
属性:
- rows,指定框架集中的所有的框架,一行一行的排列
- cols, 指定框架集中的所有的页面,一列一列的排列
<frameset cols="30%, *, 30%">
<!--
在frameset中使用frame子标签来指定要引入的页面
引入几个页面就写几个frame
-->
<frame src="demo069_表格.html" />
<frame src="demo070_给表格添加样式.html" />
<!-- 嵌套一个frameset -->
<frameset rows="30%, 50%, *">
<frame src="demo072_表格的布局.html" />
<frame src="demo073_完善clearfix.html" />
<frame src="demo074_表单.html" />
</frameset>
</frameset>
在web开发中,需要代码能在不同的浏览器中完美显示,但是浏览器中有个流氓是IE,就不和正常浏览器一样,这个时候需要我们在写代码时就把这个问题解决掉.
- 以下是修复图片的一个方法.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ie6png的修复</title>
<style type="text/css">
.box1{
width: 200px;
height: 200px;
background-image: url(img/3_1.png);
background-repeat: no-repeat;
}
.box2{
width: 200px;
height: 200px;
background-image: url(img/3.png);
background-repeat: no-repeat;
}
</style>
</head>
<body style="background-color: #bfa;">
<!--
在IE6中对图片格式png24支持度不高,如果使用的图片格式是png24,则会导致透明效果无法正常显示
解决方法:
1.可以使用png8来代替png24,即可解决问题,但是使用png8代替png24以后,图片的清晰图会有所下降
2.使用JavaScript来解决该问题,需要向页面中引入一个外部的JavaScript文件,然后在写一下简单的JS代码,来处理该问题
-->
<div class="box1"></div>
<div class="box2"></div>
<img src="img/3.png" alt="大脸猫">
<!-- 在body标签的最后引入外部的JS文件 -->
<!--再创建一个新的script标签,并且编写一些js代码 -->
<!-- 以下代码只会在IE6中执行,其他浏览器中无效 -->
<!--[if IE 6]>
<script type="text/javascript" src="js/DD_belatedPNG_0.0.8a-min.js"></script>
<script type="text/javascript">
DD_belatedPNG.fix("div,img");
</script>
<![endif]-->
</body>
</html>
在上面代码中用到了hack,可以用一个判断来解决雨打的一些问题.
- 有一些情况,有一些特殊的代码我们只需要在某些特殊的浏览器中执行,而在其他的浏览器中不需要执行,这时就可以使用CSS Hack来解决该问题
- CSS Hack实际上指的是一种特殊的代码,这段代码只在某些浏览器中可以识别,而其他浏览器不能识别,通过这种方式,来为一些浏览器设置特殊的代码
- 条件Hack
它只对IE浏览器有效,其它的浏览器都会将它识别为注释IE10及以上的浏览器已经不支持这种方式
<!-- 以下内容只会出现在IE6中 -->
<!--[if IE 6]>
<p>为了您和家人的健康,请远离IE6!!</p>
<![endif]-->
<!--[if IE 8]>
<p>当前浏览器是IE8!!</p>
<![endif]-->
<!--[if lt IE 9]>
<p>该标签会在IE9以下的浏览器中显示</p>
<![endif]-->
<!--[if gte IE 9]>
<p>该标签会在IE9及以上的浏览器中显示</p>
<![endif]-->
<!--[if lte IE 9]>
<p>该标签会在IE9及以下的浏览器中显示</p>
<![endif]-->
<!--[if ! IE 6]>
<p>你的浏览器不是IE6</p>
<![endif]-->
当然,也可以为hack设置属性:
<style type="text/css">
body{
background-color: #bfa;
/*
假设在IE6中需要将背景颜色设置为黄色才能达到和其它浏览器相同的效果
*/
/*
希望黄色背景只在IE6中生效
在样式前添加一个下划线,则该样式只有IE6及以下的浏览器才可以识别
*/
/*_background-color: yellow;*/
/*添加了*的样式只有IE7及以下的浏览器认识*/
/**background-color: yellow;*/
/*在样式最后添加一个\0,则只有IE8及以上的浏览器才能识别*/
/*background-color: yellow\0;*/
/*
CSS Hack不到万不得已的情况尽量不要使用
*/
}
</style>
hack选择符的运用
<style type="text/css">
/*
在选择器前添加* html 则该选择器只有IE6可以识别
*/
* html body{
background-color: #bfa;
}
</style>
css的过渡动画
/*在哪产生动画、动画的时间、运动曲线、延迟*/
/*transition: border-radius 500ms ease,width 500ms ease 500ms,height 500ms ease 1s,background-color 500ms ease 1.5s;*/
transition: all 500ms ease;
css3圆角 阴影 透明度
border-top-left-radius: 100px 50px;/*左上角为椭圆圆角*/
border-top-left-radius: 100px;
border-top-right-radius: 100px;/*左、右上角为正圆圆角*/
border-radius: 40px;曲率半径为40的圆角矩形
border-radius: 20%;/*最大200px,20%即40px*/
/*水平偏移 垂直偏移 羽化大小 扩展大小 颜色*/
box-shadow: 10px 10px 10px 0px #bfa;
/*水平偏移 垂直偏移 羽化大小 扩展大小 颜色 是否内阴影*/
box-shadow: 0px 0px 20px 2px red inset;
/*透明度30%,文字也透明了*/
opacity: 0.3;
/*背景色变透明,但文字不会透明*/
background-color: rgba(255,215,0,0.3);
/*边框透明*/
border: 2px solid rgba(0,0,0,0.3);
运动曲线
/*匀速*/
transition: all 1s linear;
/*开始和结束慢速,中间加速*/
transition: all 1s ease;
/*开始慢速,结尾突然停止*/
transition: all 1s ease-in;
/*突然开始,结束时慢速*/
transition: all 1s ease-out;
/*开始和结束时慢速*/
transition: all 1s ease-in-out;
/*贝塞尔(贝兹)曲线*/
transition: all 1s cubic-bezier(0.250,0.250,0.750,0.750);/*匀速*/
/*超出再缩回的弹性效果*/
transition: all 1s cubic-bezier(0.470, -0.485, 0.460, 1.435);
图片文字遮罩
/*默认文字不可见*/
overflow: hidden;
/*定位使色块在图片正下方*/
position: absolute;
left: 0;
top: 300px;
transition: all 500ms cubic-bezier(0.470, -0.485, 0.460, 1.435);
.box:hover .pic_info{
/*色块上移*/
top:150px;
}
/*间距用p标签的margin,而不直接给.pic_info用padding,因为padding会改变盒子大小*/
.box .pic_info p{
margin: 20px;
line-height: 30px;
}
变形
transition: all 1s ease;/*过渡动画*/
.box:hover{
/*box的动画不会影响到box2*/
/*位移*/
transform: translate(50px,50px);
}
.box2:hover{
/*沿Z轴旋转360度*/
transform: rotate(360deg);
}
.box3:hover{
/*缩放*/
transform: scale(0.5,0.2);
}
.box4:hover{
/*斜切*/
/*transform: skew(45deg,0);*/
transform: skew(0,45deg);
}
元素旋转
旋转方向判断
1、X轴向右、Y轴向下、Z轴向屏幕外
2、让轴向对着自己,顺时针方向就是该轴向的旋转方向
.box{
width: 300px;
height: 300px;
background-color: gold;
margin: 50px auto 0;
transition: all 500ms ease;
/*设置盒子按3D空间显示*/
transform-style: preserve-3d;
transform: perspective(800px) rotateY(0deg);
}
.box:hover{
/*默认沿Z轴旋转*/
/*transform: rotate(45deg);*/
/*perspective设置透视距离,经验数值800比较符合人眼的透视效果*/
/*transform: perspective(800px) rotateX(45deg);*/
transform: perspective(800px) rotateY(-45deg);
}
/*设置变形的中心点*/
transform-origin: left center;
背面可见
transition: all 500ms ease;
/*设置盒子按3d空间显示*/
transform-style: preserve-3d;
/*设置透视距离、三维旋转的初始角度*/
transform: perspective(800px) rotateY(0deg);
/*设置盒子背面是否可见*/
backface-visibility: hidden;
图片翻面
/*以下两句是为了演示图片和文字层重叠的效果*/
transform-style: preserve-3d;
transform: perspective(800px) rotateY(45deg);/*初始旋转45度*/
/*图片和文字背面不可见,文字初始已翻转,所以隐藏露出底层图片*/
backface-visibility: hidden;
transform-style: preserve-3d;
transform: perspective(800px) rotateY(0deg);
transition: all 500ms ease;
/*初始文字浮起10像素方便查看图片与文字分层的效果*/
transform: translateZ(10px);
/*初始文字翻转,鼠标移入时才翻正显示*/
transform: translateZ(2px) rotateY(180deg);
/*鼠标移入时图片翻为背面隐藏*/
.con:hover .pic{
transform: perspective(800px) rotateY(180deg);
}
/*鼠标移入时文字翻为正面显示*/
.con:hover .info{
transform: perspective(800px) rotateY(0deg);
}
animation动画
动画名称、时间、曲线、延迟、播放次数、结束后是否返回、动画前后的状态
infinite不限制次数
alternate动画结束后返回,返回也算次数
animation-fill-mode 动画前后的状态
forwards动画完成保持在最后一帧
backwards在延迟时间内,在动画显示之前,应用from开始属性值(例如box宽100,from宽200,在延迟1s内显示200)
both向前和向后填充模式都被应用(例如起始按200,结束停在最后一帧)
animation: moving 1s ease 1s 5 alternate both;
/*动画暂停*/
/*animation-play-state: paused;*/
.box:hover{
/*动画运行*/
/*animation-play-state: running;*/
}
/*定义一个动画,名称为moving*/
@keyframes moving{
/*初始状态*/
from{
width: 200px;
}
/*结束状态*/
to{
width: 500px;
}
}
人物走路动画
话不多说直接上代码.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>人物走路动画</title>
<style type="text/css">
.box{
width: 120px;
height: 182px;
/*border: 1px solid black;*/
margin: 50px auto 0;
overflow: hidden;
position: relative;
animation: moving 2s linear infinite;
}
.box img{
position: absolute;
left: 0;
top: 0;
/*steps动画步数,图片有8帧,所以设置为8步*/
animation: walking 2s steps(16) infinite;
}
@keyframes moving{
0%{
transform: translate(0px,0px);/*位移*/
}
50%{
transform: translate(200px,0px);
}
100%{
transform: translate(0px,0px);
}
}
@keyframes walking{
from{
left: 0px;
}
to{
left: -1920px;
}
}
</style>
</head>
<body>
<div class="box">
<img src="img/walking1.png" alt="人物走路">
</div>
</body>
</html>
关于浏览器的前缀
.box{
width: 200px;
height: 200px;
/*缩放*/
-webkit-transform: scale(0.5,0.5);
-ms-transform: scale(0.5,0.5);
transform: scale(0.5,0.5);
}
最后一个有趣的小东西,一个等待的小界面
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户等待图画</title>
<style type="text/css">
.box{
width: 300px;
height: 172px;
border: 2px solid black;
margin: 50px auto;
}
.box1{
width: 10px;
height: 20px;
background-color: #00FFFF;
margin: 10px 10px;
animation: moving 1s ease 0.1s infinite;
}
.box2{
width: 10px;
height: 20px;
background-color: #FFFF00;
margin: 10px 10px;
animation: moving 1s ease 0.2s infinite;
}
.box3{
width: 10px;
height: 20px;
background-color: blueviolet;
margin: 10px 10px;
animation: moving 1s ease 0.3s infinite;
}
.box4{
width: 10px;
height: 20px;
background-color: coral;
margin: 10px 10px;
animation: moving 1s ease 0.4s infinite;
}
.box5{
width: 10px;
height: 20px;
background-color: chartreuse;
margin: 10px 10px;
animation: moving 1s ease 0.5s infinite;
}
.p1{
text-align: center;
margin:0 auto;
position: relative;
top: -73px;
}
@keyframes moving{
from{
width: 10px;
}
50%{width: 200px;}
100%{width: 10px;}
}
</style>
</head>
<body>
<div class="box">
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
<div class="box5"></div>
</div>
<p class="p1">loading...</p>
</body>
</html>
网友评论