1、html和cssposition:absolute.position:relative 相对定位.1. 从原来的位置开始偏移.2. 相对定位的内容也会漂浮起来。但是还会占着原来的位置。如下无标题文档 div width:100px; height:100px; .d1 background-color:#FF0000; .d2 background-color:#00FF00; position:relative; top:20px; left:20px; .d3 background-color:#FFFF00; 1 2 3 position:fixed , 将内容固定住,同时也会漂浮起来。
2、无标题文档 div width:100px; height:100px; .d1 background-color:#FF0000; .d2 background-color:#00FF00; position:fixed; top:20px; left:20px; .d3 background-color:#FFFF00; 1 关闭 3 margin属性,控制容器的外边据. 被加上margin属性的容器不会漂浮,所以移动后,会将其它内容排开。无标题文档 div width:100px; height:100px; float:left; .d1 background-color:#FF000
3、0; .d2 background-color:#00FF00; margin-left:10px; .d3 background-color:#FFFF00; 1 2 3 Margin是margin-left、margin-right、margin-top、margin-bottom的综合。Margin的取值顺序为 :上 右 下 左。并且当这四个值一样时,可以简写为一个:无标题文档 div width:100px; height:100px; float:left; .d1 background-color:#FF0000; .d2 background-color:#00FF00; mar
4、gin:20px; .d3 background-color:#FFFF00; 1 2 3 当margin取值为auto时,容器会水平居中:无标题文档 div width:100px; height:100px; .d1 background-color:#FF0000; .d2 background-color:#00FF00; margin:auto; .d3 background-color:#FFFF00; 1 2 3 Padding控制内遍距。无标题文档 div width:100px; height:100px; .d1 background-color:#FF0000; .d2
5、background-color:#00FF00; padding:15px; .d3 background-color:#FFFF00; 1 2 3 在网页上,尽量不要使用alert. 因为alert需要让用户点击一下,对用户体验不好。 我们自己给自己制作一个工具,以后凡是要用到alert的地方,就用这个工具。(这叫做封装。)方法一:无标题文档加入购物车 function showMsg(msg,w,h) var elt = document.createElement(div); elt.id=msg; elt.style.border=solid black 5px; elt.style
6、.backgroundColor=yellow; elt.style.width=w+px; elt.style.height=h+px; elt.innerHTML=msg; elt.style.textAlign=center; elt.style.lineHeight=h+px; elt.style.fontSize=30px; elt.style.fontWeight=bold; elt.style.position=absolute; elt.style.top=200+px; elt.style.left=(document.body.offsetWidth - w)/2+px;
7、document.body.appendChild(elt); function shutdown() var msg = document.getElementById(msg); document.body.removeChild(msg); setTimeout(shutdown, 1000); 方法二,让提示框是 震动地。步骤一无标题文档加入购物车 function showMsg(msg,w,h) var elt = document.createElement(div); elt.style.border=solid black 5px; elt.style.backgroundC
8、olor=yellow; elt.style.width=w+px; elt.style.height=h+px; elt.innerHTML=msg; elt.style.textAlign=center; elt.style.lineHeight=h+px; elt.style.fontSize=30px; elt.style.fontWeight=bold; elt.style.position=absolute; elt.style.top=200+px; elt.style.left=(document.body.offsetWidth - w)/2+px; document.bod
9、y.appendChild(elt); var start = new Date(); var A; function animate() var now = new Date(); var last = now - start; elt.style.left = last + px; if(last = 2000) document.body.removeChild(elt); clearInterval(A); A=setInterval(animate, 1); 插播知识点: Math.sin(); 度数有360种,所以sin(度数)的返回值也有360种,以下就是将这360种度数对应的s
10、in返回值输出。观察输出的结果,会发现:范围-1 1之间。不是匀速渐变。方法2:先把上面的sin看懂无标题文档加入购物车 function showMsg(msg,w,h,t) var elt = document.createElement(div); elt.style.border=solid black 5px; elt.style.backgroundColor=yellow; elt.style.width=w+px; elt.style.height=h+px; elt.innerHTML=msg; elt.style.textAlign=center; elt.style.li
11、neHeight=h+px; elt.style.fontSize=30px; elt.style.fontWeight=bold; elt.style.position=absolute; elt.style.top=200+px; elt.style.left=(document.body.offsetWidth - w)/2+px; document.body.appendChild(elt); var start = new Date(); var A; function animate() var now = new Date(); var last = now - start; v
12、ar d = Math.PI/180*50; var jl = Math.sin(last*d) * 10 + (document.body.offsetWidth - w)/2 ; elt.style.left = jl + px; if(last = t) document.body.removeChild(elt); clearInterval(A); A=setInterval(animate, 1); 复习java.1. 7过表驱动式,猜拳游戏。import java.util.Scanner;public class Foo public static void main(Stri
13、ng args) String quan = 剪刀,石头, 布; String jieguo = /刀 石 布 平局,胜利, 失败, / 第一行代表剪刀 失败,平局, 胜利, / 第一行代表石头 胜利,失败, 平局 / 第一行代表布 ; int a,b; /a是电脑(行) b是用户(列)。 a=(int)Math.random()*1000)%3; System.out.println(请出拳: 0 剪刀t1 石头t2 布); Scanner sc = new Scanner(System.in); b=sc.nextInt(); System.out.println(电脑出: + quana
14、); System.out.println(你出: + quanb); System.out.println(结果: + jieguoab); 杨辉三角import java.util.Scanner;public class Foo public static void main(String args) int a = new int1010; for(int i = 0; i a.length; i+) ai0 = 1; aii = 1; for(int i = 2; i a.length; i+) for(int j = 1; j i; j+) aij = ai - 1j + ai - 1j - 1; for(int i = 0; i a.length; i+) for(int j = 0; j = i; j+) System.out.print(aij+t); System.out.println();
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1