第一天
一、简答题
1.请写出Java领域的相关技术。
答:java主要用于开发两种程序:桌面应用程序和internet应用程序。
2.简述java程序中注释的作用及类型。
答:在java中,常用的注释有两种:单行注释和多行注释。
1.多行注释
多行注释以“/”开头,以“/”结尾,在“/”和“/”之间的内容都被看做注释。
2.单行注释
如果说明性的文字较少,可以放在一行当中,就可以使用单行注释。单行注释使用“//”开头,每行中“//”后面的文字都可以被看做是注释。3
3.请写出在MyEclipse中开发一个java程序的步骤。
答:1.创建一个java项目;
2.创建并编写java源程序
3.编译java源程序
4.运行java程序
5.编写一个Java程序,显示个人档案,分别使用记事本和MyEclipse实现。
第二天
(1)简述Java中变量的命名规则。
变量名必须是以字母、数字、下划线或$组成
变量名不能以数字开头
变量名不能是Java关键字
除了下划线、$之外,不包括任何其他特殊字符
(2)举例说明在什么情况下会发生自动类型转换。
double i=5; int自动转换成double
1
(3)小明左,右手中分别拿两张纸牌:黑桃10和红桃8,现在交换手中的牌。用程序模拟这一过程:两个整数分别保存在两个变量中,将这两个变量的值互换,并输出互换后的结果。
package com.dj;
public class DJ12 {
public static void main(String[] ags){
int left=10; //以前左手中的纸牌数
int right=8; //以前右手中的纸牌数
System.out.println("输出互换前手中的纸牌:");
System.out.println("左手的纸牌"+left);
System.out.println("右手的纸牌"+right);
System.out.println("");
int newright=left; //现在右手中的纸牌数
int newleft=right; //现在左手中的纸牌数
System.out.println("输出互换后手中的纸牌:");
System.out.println("左手的纸牌"+newleft);
System.out.println("右手的纸牌"+newright);
}
}
(4)小明要到美国旅游,可是那里的温度是以华氏温度为单位记录的。他需要一个程序将华氏温度转换成摄氏度,并以华氏度和摄氏度为单位分别显示该温度。编写程序实现该功能。要求:可以从控制台录入温度信息。
package com.dj;
import java.util.Scanner;
public class DJ13 {
public static void main(String[] args){
@SuppressWarnings("resource")
Scanner input = new Scanner(System.in);
System.out.println("请输入华氏温度:");
double fahrenheit=input.nextDouble(); //华氏温度
double centigrade=5/9.0*(fahrenheit-32); //摄氏度
System.out.println("华氏温度:"+fahrenheit);
System.out.println("摄氏温度:"+centigrade);
}
}
(5)银行提供了整存整取定期储蓄业务,其存期分为一年,两年,三年,五年,到期凭存单支取本息。编写一个程序,输入存入的本金数目,计算存期为一年,两年,三年或五年,到期取款时,银行应支付的本息分别是多少。
package com.dj;
import java.util.Scanner;
public class DJ14 {
public static void main(String[]agse){
Scanner input = new Scanner(System.in);
System.out.println("请输入本金:");
double principal=input.nextDouble();
double pai1=principal+(principal*0.0225*1);
double pai2=principal+(principal*0.027*2);
double pai3=principal+(principal*0.0324*3);
double pai5=principal+(principal*0.036*5);
System.out.println("本金为:"+principal);
System.out.println("");
System.out.println("存款一年后的本息为:"+pai1);
System.out.println("");
System.out.println("存款两年后的本息为:"+pai2);
System.out.println("");
System.out.println("存款三年后的本息为:"+pai3);
System.out.println("");
System.out.println("存款五年后的本息为:"+pai5);
}
}
第三天
1、画出流程图并编程实现:如果用户名等于字符’青’,且密码等于数字123,则输出”欢迎你,青”;否则输出”对不起,你不是青”。
package com.dj;
import java.util.Scanner;
public class DJ3word1 {
@SuppressWarnings("resource")
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("用户名:");
String Un=input.next();
if(!Un.equals("青")){
System.out.println("对不起,你不是青");
}else{System.out.print("密码:");
double Password=input.nextDouble();
if(Password==123){
System.out.println("欢迎你,青");
}else{
System.out.println("对不起,你不是青");
}
}
}
}
2、画出流程图并编程实现:如果年龄满7岁,或者年龄满5岁并且性别是”男”,就可以搬动桌子。
package com.dj;
import java.util.Scanner;
public class DJ3word2 {
@SuppressWarnings("resource")
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("请输入年龄:");
int Age=input.nextInt();
if(Age>=7){
System.out.println("你可以搬动桌子。");
}else if(5<=Age){
System.out.print("请输入性别:");
String Sex=input.next();
if(Sex.equals("男")){
System.out.println("你可以搬动桌子。");
}else{
System.out.println("你不可以搬动桌子。");
}
}
}
}
3、画出流程图并编程实现:从键盘上输入三个整数,分别赋给整形变量a、b、c,然后将输入的整数按照从小到大的顺序放在变量a、b、c中,并输出三个变量的值。
package com.dj;
import java.util.Scanner;
public class DJ3word3 {
@SuppressWarnings("resource")
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("请输入一个整数:");
int a=input.nextInt();
System.out.print("请输入一个整数:");
int b=input.nextInt();
System.out.print("请输入一个整数:");
int c=input.nextInt();
int d;
if(a>b){
d=a;
a=b;
b=d;
}
if(a>c){
d=a;
a=c;
c=d;
}
if(b>c){
d=b;
b=c;
c=d;
}
System.out.println(a+" "+b+" "+c);
}
}
4、画出流程图并编程实现:从键盘上输入一个整数,判断是否能被3或5整除。如果能,则输出”该整数是3或者5的倍数。”;否则输出”该数不能被3或5中的任何一个数整除。”。
package com.dj;
import java.util.Scanner;
public class DJ3word4 {
@SuppressWarnings("resource")
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("请输入一个整数:");
int integer=input.nextInt();
if((integer%3==0)||(integer%5==0)){
System.out.print("该整数是3或5的倍数");
}else{
System.out.print("该数不能被3或5中任何一个数整除");
}
}
}
5、画出流程图并编程实现:
刘珊珊同学参加了java课程的学习,他父亲和母亲承诺如下。
→如果考试成绩==100分,父亲给她买一辆车。
→如果考试成绩>=90分,母亲给她买一部笔记本电脑。
→如果考试成绩>=60分,母亲给她买一部手机。
→如果考试成绩<60分,没有礼物。
package com.dj;
import java.util.Scanner;
public class DJ3word5 {
@SuppressWarnings("resource")
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("请输入考试成绩:");
int achievement=input.nextInt();
if(achievement>=100){
System.out.print("父亲给她买一辆车;");
}else if(achievement>=90){
System.out.print("母亲给她买一部笔记本电脑;");
}else if(achievement>=60){
System.out.print("母亲给她买一部手机;");
}else{
System.out.print("没有礼物;");
}
}
}
6、画出流程图并编辑实现:某人准备去海南旅游,现在要订购机票。机票的价格受季节旺季、淡季的影响,头等舱和经济舱价格也不同。假设机票原价为5000元,4~10月为旺季,旺季头等舱打九折,经济舱打八折;淡季头等舱打五折,经济舱打四折。编写程序,使用嵌套if选择结构,根据出行月份和选择的舱位输出实际的机票价格。
package com.dj;
import java.util.Scanner;
public class DJ3word6 {
@SuppressWarnings("resource")
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.println("请输入您出行的月份:");
int Month=input.nextInt();
System.out.println("请问您选择头等舱还是经济舱?头等舱输入1,经济舱输入2");
int cabin=input.nextInt();
int money =5000;
int money1=(int) (money*0.5);
int money2=(int) (money*0.4);
int money3=(int) (money*0.9);
int money4=(int) (money*0.8);
if(cabin==1){
if((Month>=1&&Month<=3)||(Month>=11&&Month<=12)){
System.out.print("您的机票价格为:"+money1);
}else if(Month>=4&&Month<=10){
System.out.print("您的机票价格为:"+money3);
}
}if(cabin==2){
if((Month>=1&&Month<=3)||(Month>=11&&Month<=12)){
System.out.print("您的机票价格为:"+money2);
}else if(Month>=4&&Month<=10){
System.out.print("您的机票价格为:"+money4);
}
}
}
}
第四天
1、说明什么情况下可以使用switch选择结构代购多重if选择结构。
switch的语句都可以用多重if结构替换~~但是多重if结构要替换成switch的话 判断条件必须是字 符型或整形
1
2、使用switch结构实现,为小明制定学习计划,星期一、星期三、星期五学习编程,星期二、星期四、星期六学习英语,星期日休息。
package com.dj;
import java.util.Scanner;
public class DJ4word2 {
@SuppressWarnings("resource")
public static void main(String[] agse){
Scanner input=new Scanner(System.in);
System.out.print("请输入星期几:");
if(input.hasNextInt()==true){
int day=input.nextInt();
switch(day){
case 1:
case 3:
case 5:
System.out.println("学习编程");
break;
case 2:
case 4:
case 6:
System.out.println("学习英语");
break;
case 7:
System.out.println("休息");
break;
}
}else{
System.out.println("请输入正确的数字!");
}
}
}
3、使用switch选择结构完成本书第3章第5题的要求,实现父母对刘珊珊的承诺
package com.dj;
import java.util.Scanner;
public class DJ4word3 {
@SuppressWarnings("resource")
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("请输入考试成绩:");
if(input.hasNextInt()==true){
int achievement=input.nextInt();
int achievement1=achievement/10;
switch(achievement1){
case 10:
System.out.print("父亲给她买一辆车;");
break;
case 9:
System.out.print("母亲给她买一部笔记本电脑;");
break;
case 8:
case 7:
case 6:
System.out.print("母亲给她买一部手机;");
break;
default:
System.out.print("没有礼物;");
break;
}
}else{
System.out.println("请输入正确的数字!");
}
}
}
4、使用switch选择结构完成本书第3章第6题的要求,根据月份和选择的舱位输出实际的机票价格
package com.dj;
import java.util.Scanner;
public class DJ4word4 {
@SuppressWarnings("resource")
public static void main(String[] args){
int money =5000;
int money1=(int) (money*0.5);
int money2=(int) (money*0.4);
int money3=(int) (money*0.9);
int money4=(int) (money*0.8);
Scanner input=new Scanner(System.in);
System.out.println("请输入您出行的月份:");
int Month=input.nextInt();
if(Month>=1&&Month<=12){
switch(Month){
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
System.out.println("请问您选择头等舱还是经济舱?头等舱输入1,经济舱输入2");
int cabin=input.nextInt();
if(cabin==1){
System.out.print("您的机票价格为:"+money3);
}else if(cabin==2){
System.out.print("您的机票价格为:"+money4);
}else{
System.out.print("请输入正确的数字!");
}
break;
default:
System.out.println("请问您选择头等舱还是经济舱?头等舱输入1,经济舱输入2");
int cabin1=input.nextInt();
if(cabin1==1){
System.out.print("您的机票价格为:"+money1);
}else if(cabin1==2){
System.out.print("您的机票价格为:"+money2);
}else{
System.out.print("请输入正确的数字!");
}
}
}
}
}
5、编程实现迷你计算机功能,支持”+” “-” “*” “/”从控制台输入两个操作数,输出运算
package com.dj;
import java.util.Scanner;
public class DJ4word5 {
@SuppressWarnings("resource")
public static void main(String[] agse){
Scanner input=new Scanner(System.in);
System.out.print("请输入第一个操作数:");
if(input.hasNextInt()==true){
double num1=input.nextDouble();
System.out.print("请输入第二个操作数:");
double num2=input.nextDouble();
System.out.print("请输入运算符:");
char word=input.next().charAt(0);
switch(word){
case '+':
System.out.println("计算结果:"+(num1+num2));
break;
case '-':
System.out.println("计算结果:"+(num1-num2));
break;
case '*':
System.out.println("计算结果:"+(num1*num2));
break;
case '/':
System.out.println("计算结果:"+(num1/num2));
break;
default:
System.out.println("输入错误");
break;
}
}else{
System.out.println("请输入正确的数字!");
}
}
}
第五天
1、利用循环结构解决问题的一般步骤是什么?
确定循环条件,确定循环体,然后写代码就行了
1
2、使用while循环结构输出:100、95、90、85…5.先画出流程图,在编程实现。设置断点调试程序,观察循环变量的变化。
package sra;
public class DJ5word2 {
public static void main(String[] args){
int i=100;
while(i>0){
System.out.println(i);
i=i-5;
}
}
}
3、使用do-while循环结构实现:计算1~50中是7的倍数的数值之和并输出。
package sra;
public class DJ5word3 {
public static void main(String[] args){
int i=1;
int sum=0;
do {
if(i%7==0){
sum+=i;
}
i++;
}while(i<=50);
System.out.println(sum);
}
}
4、从键盘上接受一拼整数,比较并输出其中的最大值和最小值,输入数字0时结束循环。
package sra;
import java.util.Scanner;
public class DJ5word4 {
@SuppressWarnings("resource")
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("请输入一个整数(输入0结束):");
int num=input.nextInt();
int max=num;
int min=num;
for(;;){
if(num==0)break;
System.out.print("请输入一个整数(输入0结束):");
int num1=input.nextInt();
if(num1==0)break;
if(num1>max){
max=num1;
}
if(num1<min){
min=num1;
}
}
System.out.println("最大值是:"+max);
System.out.println("最小值是:"+min);
}
}
5、从键盘上输入一位整数,当输入1~7时,显示下面对应的英文星期名称的缩写。
1:MON 2:TUE 3:WED 4:THU 5:FRI 6:SAT 7:SUN
输入其他数字时提示用户重新输入,输入数字0时程序结束。
package sra;
import java.util.Scanner;
public class DJ5word5 {
@SuppressWarnings("resource")
public static void main(String[] args){
String one2="MON";
String two2="TUE";
String three2="WED";
String four2="THU";
String five2="FRI";
String six2="SAT";
String seven2="SUN";
Scanner input=new Scanner(System.in);
System.out.print("请输入数字1-7(输入0结束):");
int num=input.nextInt();
for(;;){
if(num==0)break;
System.out.print("请输入数字1-7(输入0结束):");
int num1=input.nextInt();
if(num1==0)break;
switch(num1){
case 1:
System.out.println("今天是:"+one2);
break;
case 2:
System.out.println("今天是:"+two2);
break;
case 3:
System.out.println("今天是:"+three2);
break;
case 4:
System.out.println("今天是:"+four2);
break;
case 5:
System.out.println("今天是:"+five2);
break;
case 6:
System.out.println("今天是:"+six2);
break;
case 7:
System.out.println("今天是:"+seven2);
break;
default:
System.out.println("请输入正确的数字!");
break;
}
}System.out.println("程序结束!");
}
}
第六天
1、说明在循环结构中break语句和continue语句的区别。
一个是立即跳出循环的语句:break;
一个是立即继续循环的语句:continue;
1
2
2、使用for循环结构实现:从键盘上接受从周一至周五每天的学习时间(一小时为单位),并计算每日平均学习时间。
package sra;
import java.util.Scanner;
public class DJ6word2 {
@SuppressWarnings("resource")
public static void main(String[] args) {
double time;
double sum=0;
double avg=0;
boolean isNegative=false;
for(int o=1;o<6;o++){
Scanner i=new Scanner(System.in);
System.out.print("请输入周"+o+"的学习时间:");
time=i.nextDouble();
if(time<0){
isNegative=true;
break;
}
sum+=time;
}
if(isNegative){
System.out.println("抱歉,分数录入错误!");
}else{
avg=sum/5;
System.out.println("周一至周五每日平均学习时间是:"+avg+"小时");
}
}
}
3、鸡兔同笼是我国古代著名的趣题之一。大约在1500年前,《孙子算经》中记载了这样一道题目;今有鸡兔同笼,上有三十五头,下有九十四足,问鸡兔各几只?
package sra;
public class DJ6word3 {
public static void main(String[] args) {
int chookNum,rabbitNum;
for(chookNum=0;chookNum<=35;chookNum++){
for(rabbitNum=0;rabbitNum<=35;rabbitNum++){
if(chookNum+rabbitNum==35&&(2*chookNum+4*rabbitNum==94)){
System.out.println("鸡的数量是:"+chookNum);
System.out.println("鸡的数量是:"+rabbitNum);
}
}
}
}
}
4、开发一个标题为“FlipFlop”的游戏应用程序。它从1~100遇到3的倍数输出“Flip”,5的倍数输出”Flop“,既是三又是五的倍数输出”Flip Flop“其余情况下输出当前数字。
package sra;
import java.util.Scanner;
public class DJ6word4 {
@SuppressWarnings("resource")
public static void main(String[] args) {
int num;
System.out.println("\t\tFilpFlop");
for(int o=0;o<100;o++){
Scanner i=new Scanner(System.in);
System.out.print("请输入一个整数:");
num=i.nextInt();
if(num%3==0&&num%5==0){
System.out.println("FlipFlop");
}else if(num%5==0){
System.out.println("Flop");
}else if(num%3==0){
System.out.println("Flip");
}else{
System.out.println("你的数字是:"+num);
}
}
}
}
5、在马克思手稿中有一道趣味的数学问题:一共有30个人,可能包括男人,女人和小孩。他们在一家饭馆吃饭共花了50先令,其中每个男人花3先令,每个女人花2先令,每个小孩花1先令,请问男人女人小孩各几人。
package sra;
public class DJ6word5 {
public static void main(String[] args) {
int men,women,kid;
for(men=0;men<=30;men++){
for(women=0;women<=30;women++){
for(kid=0;kid<=30;kid++){
if(men+women+kid==30&&men*3+women*2+kid==50){
System.out.println("男人有几个:"+men);
System.out.println("女人有几个:"+women);
System.out.println("小孩有几个:"+kid);
}
}
}
}
}
}
6、求程序结束后变量sum的值。
package cn.bdqn.test;
public class Demo10 {
public static void main(String[] args) {
int sum=0,i;
for(i=1;i<=4;i++){
switch(i){
case 1:
sum=sum+2;
case 2:
sum=sum+4;
continue;
case 3:
sum=sum+16;
break;
}
}
}
}
sum的值为26
第七天
1.写出八种Java语言的基本数据类型。
(1)byte(2)short(3)int(4)long(5)float(6)double(7)boolean(8)char
1
2.编写Java程序,实现接收用户输入的正整数,输出该数的阶乘。例如,输入数据4,则输出4!=1*2*3*4=24。
要求:限制输入的数据为1~10,否则提示“无效输出”并结束程序。
package sra;
import java.util.Scanner;
public class DJ7word2 {
@SuppressWarnings("resource")
public static void main(String[] args) {
int num;
int sum = 1;
Scanner i=new Scanner(System.in);
System.out.print("请输入一个正整数:");
num=i.nextInt();
if(num>=0&&num<=10){
System.out.print(num+"!=");
for(int o=1;o<=num-1;o++){
sum=sum*o;
System.out.print(o+"*");
}
System.out.print(num+"="+sum*num);
}else{
System.out.println("无效数据");
}
}
}
3.编写Java程序,实现输出1~100中所有不能被7整除的数,并求其和。
要求:每输出四个数据换行显示。
package sra;
public class DJ7word3 {
public static void main(String[] args) {
int a=1;
int sum=0;
System.out.println("1-100之间不能被7整除的数据为:");
for(int i=0;i<=100;i++){
if(i%7!=0){
System.out.print(i+"\t");
if(a++%4==0){
System.out.println();
}
sum+=a;
}
}
System.out.println("\n数据之和为:"+sum);
}
}
第八天
1.阅读一下代码,找出其中的错误。
String[] scores=new String[5]{"Milk","Lily","Summy","Jenny","Anna"};
for(int i=0;i<=scores.length;i++){
System.out.println(scores[i]);
}
将第一句中String[5]的5删除。
2.依次输入五句话,然后将它逆序输出。
package sra;
import java.util.Scanner;
public class DJ8word2 {
@SuppressWarnings("resource")
public static void main(String[] args) {
String[] word=new String[5];
Scanner i=new Scanner(System.in);
for(int a=0;a<word.length;a++){
System.out.print("第"+(a+1)+"句话:");
word[a]=i.next();
}
System.out.println("逆序输出5句话为:");
for(int b=5;b>=1;b--){
System.out.println(word[b-1]);
}
}
}
3.某百货商场当日消费积分最高的八名顾客,他们的积分分别是18,25,7,36,13,2,89,63。编写程序找出最低的积分及它在数组中的原始位置(下标)。
package sra;
public class DJ8word3 {
public static void main(String[] args) {
int[] integral=new int[]{18,25,7,36,13,2,89,63};
int min=integral[0];
int index=0;
for(int a=0;a<integral.length;a++){
if(integral[a]<min){
min=integral[a];
index=a;
}
}
System.out.println("最低积分的下标为:"+index);
System.out.println("最低积分为:"+min);
}
}
4.从键盘上输入10个整数,合法值为1,2和3,不是这三个数则为非法数字。试编程统计每个整数和非法数字的个数。
package sra;
import java.util.Scanner;
public class DJ8word4 {
@SuppressWarnings("resource")
public static void main(String[] args) {
int one=0;
int two=0;
int three=0;
int Other=0;
int[] num=new int[10];
Scanner i=new Scanner(System.in);
System.out.println("请输入10个数:");
for(int a=0;a<num.length;a++){
num[a]=i.nextInt();
}
for(int b=0;b<num.length;b++){
if(num[b]==1){
one++;
}else if(num[b]==2){
two++;
}else if(num[b]==3){
three++;
}else{
Other++;
}
}
System.out.println("数字1的个数为:"+one);
System.out.println("数字2的个数为:"+two);
System.out.println("数字3的个数为:"+three);
System.out.println("非法数字的个数为:"+Other);
}
}
5.假设有一个长度为5的数组,如下所示。
int[] num=new int[]{1,3,-1,5,-2};
现创建一个新数组newArray[],要求新数组中元素的存放顺序与原数组中的元素逆序,并且如果原数组中的元素值小于0,在新数组中按0,在新数组中按0储存。试编程输出新数组中的元素。
package sra;
public class DJ8word5 {
public static void main(String[] args) {
int[] num={1,3,-1,5,-2};
System.out.println("原数组为:");
for(int a=0;a<num.length;a++){
System.out.print(num[a]+" ");
}
for(int b=0;b<num.length;b++){
if(num[b]<0){
num[b]=0;
}
}
System.out.println("\n逆序并处理后的数组为:");
for(int c=num.length-1;c>-1;c--){
System.out.print(num[c]+" ");
}
}
}
6.有一组英文歌曲,按照歌曲名称的字母顺序从“A”和“Z”顺序排列,保持在一个数组中。现在增加一首新歌,将它插入数组,并保持歌曲名称升序排列。
package sra;
import java.util.Scanner;
public class DJ8word6 {
@SuppressWarnings("resource")
public static void main(String[] args) {
String[] music=new String[5];
music[0]="Island";
music[1]="Ocean";
music[2]="Pretty";
music[3]="Sun";
int index=music.length;
System.out.print("插入前的数组为:");
for(int a=0;a<music.length;a++){
System.out.print(music[a]+" ");
}
Scanner i=new Scanner(System.in);
System.out.print("\n请输入歌曲名称:");
String musics=i.next();
for(int a=0;a<music.length;a++){
if(music[a]pareToIgnoreCase(musics)>0){
index=a;
break;
}
}
for(int b=music.length-1;b>index;b--){
music[b]=music[b-1];
}
music[index]=musics;
System.out.print("插入后的数组为:");
for(int a=0;a<music.length;a++){
System.out.print(music[a]+" ");
}
}
}
第九天
1.什么是二重循环?在内层循环中使用continue和break语句,程序如何跳转?
内循环中continue是跳出当前循环,比如说循环10次,当执行到第二次时遇到continue则本次不执行,会跳到第3次继续执行;若这里是break的时候则跳出所有循环,也就是余下的循环都不执行了。
1
2.编写程序,打印如下图案。
package sra;
import java.util.Scanner;
public class DJ9word2 {
@SuppressWarnings("resource")
public static void main(String[] args) {
Scanner i=new Scanner(System.in);
System.out.print("请输入行数:");
int num=i.nextInt();
for(int a=1;a<=num;a++){
for(int b=1;b<=a;b++){
System.out.print(b+" ");
}
System.out.println();
}
}
}
3.我国古代数学家张丘建在《算经》中出了一道“百钱买百鸡”的问题,题意是这样的:5文钱可以买1只公鸡,3文钱可以买1只母鸡,1文钱可以买3只雏鸡。现在用100文钱买100只鸡,那么各有公鸡,母鸡,雏鸡多少只?
package sra;
public class DJ9word3 {
public static void main(String[] args) {
int Cock=0;
int Hen=0;
int chick=0;
for(Cock=0;Cock<=100;Cock++){
for(Hen=0;Hen<=100;Hen++){
for(chick=0;chick<=100;chick++){
if(Cock+Hen+chick==100&&Cock*15+Hen*9+chick==300){
System.out.print("公鸡的数量为:"+Cock);
System.out.print("母鸡的数量为:"+Hen);
System.out.print("雏鸡的数量为:"+chick);
System.out.println();
}
}
}
}
}
}
4.有三个班级各四名学员参赛,从控制台输入每个班级参赛的成绩,要求统计出三个班级所有参赛学员中成绩大于85分的学员的平均分,如何编程实现?
package sra;
import java.util.Scanner;
public class DJ9word4 {
@SuppressWarnings("resource")
public static void main(String[] args) {
int[] amrk=new int[4];
int classnum=3;
int count=0;
double sum=0;
Scanner i=new Scanner(System.in);
for(int a=0;a<classnum;a++){
System.out.println("请输入第"+(a+1)+"个班级的成绩");
for(int b=0;b<amrk.length;b++){
System.out.print("第"+(b+1)+"个学员的成绩:");
amrk[b]=i.nextInt();
if(amrk[b]<85){
continue;
}else{
count++;
sum+=amrk[b];
}
}
System.out.println();
}
System.out.println("成绩85分以上的学员的平均分是:"+sum/count);
}
}
5.假设一个简单的在ATM的取款过程如下:首先提示用户输入密码(password),最多只能输入三次,超过三次则提示用户“密码错误,请取卡”,交易结束。如果用户密码正确,再提示用户输入金额(amount),ATM只能输出100元纸币,一次取钱要求最低0元,最高1000元。如果用户输入的金额符合上述要求,则打印输出用户的钱数,最后提示用户“交易完成,请取卡”,否则提示用户重新输入金额。假设用户密码是111111。
package sra;
import java.util.Scanner;
public class DJ9word5 {
@SuppressWarnings("resource")
public static void main(String[] args) {
int a=0;
Scanner i=new Scanner(System.in);
for(a=0;a<3;a++){
System.out.print("请输入密码:");
int Password=i.nextInt();
if(Password==111111){
System.out.print("请输入取款金额:");
int aom=i.nextInt();
for(int b=0;b<=10;b+=1){
if(aom>=0){
if(aom<=1000&&aom%100==0){
System.out.println("您的取款金额为:"+aom);
System.out.println("交易完成,请取卡。");
break;
}else{
System.out.print("您输入的金额不合法,请重新输入:");
int aom2=i.nextInt();
aom=aom2;
continue;
}
}else{
System.out.print("您输入的金额不合法,请重新输入:");
int aom2=i.nextInt();
aom=aom2;
continue;
}
}
}else{
continue;
}
break;
}if(a==3){
System.out.println("密码错误,请取卡。");
}
}
}
6.输入行数,打印棱形,要求如下:
从控制台输入棱形的高度(行数)。如果用户输入的行数合法(奇数),则打印出棱形;否则提示用户输出奇数。
假设用户输入的行数为rows,则每行字符*的个数为1。3.5.7.···,rows,···,7,5,3,1。
package sra;
import java.util.Scanner;
public class DJ9word6 {
@SuppressWarnings({ "unused", "resource" })
public static void main(String[] args) {
Scanner i=new Scanner(System.in);
System.out.print("请输入棱形行数:");
int num=i.nextInt();
for(int a=0;;a++){
if(num>0){
if(num%2==1){
for(int b=1;b<=num;b++){
for(int c=1;c<=num-b;c++){
System.out.print(" ");
}
for(int d=1;d<=2*b-1;d++){
System.out.print("*");
}
System.out.println();
}
for(int e=num-1;e>=1;e--){
for(int f=1;f<=num-e;f++){
System.out.print(" ");
}
for(int g=1;g<=2*e-1;g++){
System.out.print("*");
}
System.out.println();
}
break;
}else{
System.out.print("请输入奇数:");
int num2=i.nextInt();
num=num2;
continue;
}
}else{
System.out.print("请输入奇数:");
int num2=i.nextInt();
num=num2;
continue;
}
}
}
}
第十天
1.简述什么是类和对象,以及二者之间的关系。
类是一个抽象的概念
而对象是类抽象概念的实物表达
2.老师要求张浩使用面向对象的思想编写一个计算器类(Calculator),可以实现两个整数的加,减,乘,除的运算.。
package sra;
import java.util.Scanner;
public class DJ11word2Calculator {
@SuppressWarnings({ "unused", "resource" })
public static void main(String[] args) {
String answer="";
double num1=0;
double num2=0;
char symbol='+';
double result=0;
Scanner i=new Scanner(System.in);
do{
System.out.print("请输入第一个数:");
num1=i.nextDouble();
System.out.print("请输入运算符:");
symbol=i.next().charAt(0);
System.out.print("请输入第二个数:");
num2=i.nextDouble();
switch(symbol){
case '+':
System.out.println(num1+"+"+num2+"="+(num1+num2));
break;
case '-':
System.out.println(num1+"-"+num2+"="+(num1-num2));
break;
case '*':
System.out.println(num1+"*"+num2+"="+(num1*num2));
break;
case '/':
System.out.println(num1+"/"+num2+"="+(num1/num2));
break;
default:
System.out.println("输入错误");
break;
}
System.out.print("继续吗?(y/n):");
answer=i.next();
System.out.println();
}while("y".equals(answer));
if("n".equals(answer)){
System.out.println("谢谢使用,程序结束。");
}
}
}
3.假设当前时间是2015年5月12日11分00秒,编写一个CurrentTime类,设置属性为该时间,定义show()方法显示该时间。
package sra;
public class DJ11word3CurrentTime {
String curTime = "2015年5月12日10点11分00秒";
public void show(){
System.out.println("当前时间是:" + curTime);
}
}
4.改进第3题,将当前时间改为2015年5月12日11分30秒。编写一个Dome类,改变CurrentTine类中设定的时间,并打印输出。
package sra;
public class DJ11word4Demo {
public static void main(String[] args) {
DJ11word3CurrentTime currentTime = new DJ11word3CurrentTime();
currentTime.curTime = "2015年5月12日10点11分30秒";
currentTime.show();
}
}
5.是用类的方式描述计算机。
package sra;
public class DJ11word5 {
String CPU;
String Amainboard;
String Monitor;
String Harddisk;
String Memory;
public void showInfo(){
System.out.println("计算机配置如下:"+"\nCPU:"+CPU+"\n主板"+Amainboard+"\n显示器"+Monitor+"\n硬盘"+Harddisk+"\n内存"+Memory);
}
}
6.某公司要开发新游戏,请用面向对象的思想设计英雄类,怪物类和武器类。
package sra;
public class DJ11word6information {
public String Heroicname;
public String HeroicHP;
public void Heroic(){
System.out.print("我是英雄,我的基本信息如下:\n");
System.out.print("名字:"+Heroicname+",");
System.out.print("生命值:"+HeroicHP);
}
public String monstername;
public String monsterHP;
public String monstertype;
public void monster(){
System.out.print("\n我是怪物,我的基本信息如下:\n");
System.out.print("名字:"+monstername+",");
System.out.print("生命值:"+monsterHP+",");
System.out.print("类型:"+monstertype);
}
public String armsname;
public String armsAggressivity;
public void arms(){
System.out.print("\n我是武器,我的基本信息如下:\n");
System.out.print("名字:"+armsname+",");
System.out.print("攻击力:"+armsAggressivity);
}
}
package sra;
public class DJ11word6output {
public static void main(String[] args) {
DJ11word6information output = new DJ11word6information();
output.Heroicname="张小侠";
output.HeroicHP="300";
output.monstername="小龟";
output.monsterHP="300";
output.monstertype="潜水类";
output.armsname="死神镰刀";
output.armsAggressivity="12";
output.Heroic();
output.arms();
output.monster();
}
}
第十一天
1.根据目录结构myjava/practice1/Foo.java,写出Foo类的包名。
包名为:myjava.practice1:
2.改写第12章中简答题第3题中的计算机类(Calculator)。要求将加减乘除的方法改写成带参方法,在定义一个运算方法 ope(),接收用户的运算和两个数字,根据用户选择的运算计算结果。
public class DJ14word2Calculator {
public double add(double num1,double num2){
System.out.print(num1+"+"+num2+"=");
return(num1+num2);
}
public double minus(double num1,double num2){
System.out.print(num1+"-"+num2+"=");
return(num1-num2);
}
public double multiple(double num1,double num2){
System.out.print(num1+"*"+num2+"=");
return(num1*num2);
}
public double divide(double num1,double num2){
System.out.print(num1+"/"+num2+"=");
return(num1/num2);
}
public double ope(int op,double num1,double num2){
if(op==1){
return add(num1,num2);
}else if(op==2){
return minus(num1,num2);
}else if(op==3){
return multiple(num1,num2);
}else{
return divide(num1,num2);
}
}
}
import java.util.Scanner;
public class DJ14word2 {
@SuppressWarnings({ "resource" })
public static void main(String[] args) {
DJ14word2Calculator calc=new DJ14word2Calculator();
Scanner i=new Scanner(System.in);
System.out.print("请选择运算:1.加法2.减法3.乘法4.除法:");
int op=i.nextInt();
System.out.print("请输入第一个数:");
double num1=i.nextDouble();
System.out.print("请输入第二个数:");
double num2=i.nextDouble();
System.out.println(calc.ope(op,num1,num2));
}
}
3.模拟一个简单的购房商贷月供计算器,假设按照以下的公式计算出总利息和每月还款金额。
public class DJ14word3Loan {
public double loan(double loan,int yearchoice){
double money=0;
switch(yearchoice){
case 1:
money=loan*1.0603/36;
System.out.println("月供为:"+money);
break;
case 2:
money=loan*1.0612/60;
System.out.println("月供为:"+money);
break;
case 3:
money=loan*1.0639/240;
System.out.println("月供为:"+money);
break;
default:
System.out.println("请输入正确的数字!");
break;
}
return money;
}
}
import java.util.Scanner;
public class DJ14word3 {
@SuppressWarnings({ "unused", "resource" })
public static void main(String[] args) {
DJ14word3Loan l=new DJ14word3Loan();
Scanner i=new Scanner(System.in);
System.out.print("请输入贷款金额:");
double lloan=i.nextDouble();
System.out.print("请输入贷款年限:1.3年(36个月)2.5年(60个月)3.20年(240个月)");
int lyearchoice=i.nextInt();
}
}
4.根据指定不同的行及字符,生成不同的三角形。
public class DJ14word4Triangle {
public void printTriangle(int row,String ch){
for(int a=0;a<row;a++){
for(int b=0;b<=a;b++){
System.out.print(ch);
}
System.out.println();
}
}
}
import java.util.Scanner;
public class DJ14word4 {
@SuppressWarnings("resource")
public static void main(String[] args) {
DJ14word4Triangle l=new DJ14word4Triangle();
Scanner i=new Scanner(System.in);
System.out.print("请输入行数:");
int lrow=i.nextInt();
System.out.print("请输入打印的字符:");
String lch=i.next();
l.printTriangle(lrow,lch);
}
}
5.根据三角形的三条边长,判断其是直角、钝角,还是锐角三角形。
public class DJ14word5Triangle {
public boolean it(int a,int b,int c){
boolean flag=false;
if((a+b)>c&&(a+c)>b&&(c+b)>a){
flag=true;
}
return flag;
}
public String shape(int a,int b,int c){
String shape="";
if(a==b&&b==c){
shape="这是个等边三角形";
}else if(a==b||b==c||c==a){
shape="这是个等腰三角形";
}else if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a){
shape="这是个直角三角形";
}else if(a*a+b*b>c*c||a*a+c*c>b*b||b*b+c*c>a*a){
shape="这是个锐角三角形";
}else if(a*a+b*b<c*c||a*a+c*c<b*b||b*b+c*c<a*a){
shape="这是个钝角三角形";
}
return shape;
}
}
import java.util.Scanner;
public class DJ14word5 {
@SuppressWarnings("resource")
public static void main(String[] args) {
DJ14word5Triangle l=new DJ14word5Triangle();
String answer="";
Scanner i=new Scanner(System.in);
do{
System.out.print("请输入第1条边:");
int a=i.nextInt();
System.out.print("请输入第2条边:");
int b=i.nextInt();
System.out.print("请输入第3条边:");
int c=i.nextInt();
if(l.it(a,b,c)){
System.out.println(l.shape(a,b,c));
}else{
System.out.println("这不能构成三角形");
}
System.out.print("继续吗?(y/n):");
answer=i.next();
}while("y".equals(answer));
System.out.println("谢谢使用!");
}
}
6.编写程序,向整型数组的指定位置插入元素,并输出插入前后数组的值。
public class DJ14word6ia {
public void insertArray(int[] arr,int index,int value){
for(int a=arr.length-1;a>=index;a--){
arr[a]=arr[a-1]; //向后移一位
}
arr[index-1]=value; //赋值
}
}
public class DJ14word6 {
public static void main(String[] args) {
int[] a=new int[20]; //定义一个新数组
a[0]=45;
a[1]=12;
a[2]=0;
a[3]=87;
a[4]=21;
a[5]=1;
a[6]=89;
a[7]=123;
a[8]=21;
System.out.println("插入前:");
for(int i=0;i<a.length-1;i++){
System.out.print(a[i]+" ");
}
DJ14word6ia ia=new DJ14word6ia(); //引用另一页
ia.insertArray(a,3,10); //赋值
System.out.println("\n插入后:");
for(int i=0;i<a.length-1;i++){
System.out.print(a[i]+" ");
}
}
}
7.本学期期末学员共参加了三门课,即Java、C、SQL,编写方法计算每位学员三门课的平均分。
public class DJ14word7student {
public int java;
public int C;
public int SQL;
}
public class DJ14word7studentBiz {
public double getAvg(DJ14word7student stu){
return (stu.java+stu.C+stu.SQL)/3;
}
}
import java.util.Scanner;
public class DJ14word7 {
@SuppressWarnings("resource")
public static void main(String[] args) {
DJ14word7student curriculum=new DJ14word7student();
Scanner i=new Scanner(System.in);
System.out.print("请输入你的java成绩:");
curriculum.java=i.nextInt();
System.out.print("请输入你的C成绩:");
curriculum.C=i.nextInt();
System.out.print("请输入你的SQL成绩:");
curriculum.SQL=i.nextInt();
DJ14word7studentBiz calculation=new DJ14word7studentBiz();
double avg=calculation.getAvg(curriculum);
System.out.println("你的平均分是:"+avg);
}
}
第十二天
1.根据你的理解,简要说明比较运算符(==)和equal()方法判断两个字符串是否相等有什么区别。
答
==用于比较引用和比较基本数据类型时具有不同的功能:
比较基本数据类型,如果两个值相同,则结果为true
而在比较引用时,如果引用指向内存中的同一对象,结果为true
2.
equals 方法(是String类从它的超类Object中继承的)被用来检测两个对象是否相等,即两个对象的内容是否相等,区分大小写。
3.
s1 = new String("sony"); //创建的是字符串对象
s1.equals("sony"); //返回true
s1 == "sony" //返回false
//如果
s1 = "sony";
s1 == "sony" //返回true
//如果
s1 = "sony";
s2 = "sony";
s1.equals(s2); 或者string.equals(s1,s2);//返回true
2.输入五种水果的英文名称(如葡萄grape、橘子orange、香蕉banana、苹果apple、桃peach),编写一个程序,输出这些水果的名称(按照在字典里出现的先后顺序输出)。
import java.util.Arrays;
import java.util.Scanner;
public class DJ15word2 {
@SuppressWarnings({ "resource", "unused" })
public static void main(String[] args) {
String blank="";
String[] fruits=new String[5];
Scanner i=new Scanner(System.in);
for(int a=0;a<fruits.length;a++){
System.out.print("请输入第"+(a+1)+"种水果:");
fruits[a]=i.next();
}
Arrays.sort(fruits);
System.out.println("\n这些水果在字典中出现的顺序是:");
for(int d=0;d<fruits.length;d++){
System.out.println(fruits[d]);
}
}
}
3.假设中国人的姓都是单个字,请随机输入一个人的姓名,然后输入一个人的姓名,然后输出姓和名。
import java.util.Scanner;
public class DJ15word3 {
@SuppressWarnings("resource")
public static void main(String[] args) {
String name="";
Scanner i=new Scanner(System.in);
System.out.print("请输入任意一个姓名:");
name=i.next();
System.out.println("姓氏:"+name.substring(0,1)); //name.charAt(0)和substring(0,1)都可以
System.out.println("名字:"+name.substring(1,name.length()));
}
}
4.录入用户的18位身份证号码,从中提取用户的生日。
import java.util.Scanner;
public class DJ15word4 {
@SuppressWarnings("resource")
public static void main(String[] args) {
Scanner i=new Scanner(System.in);
System.out.print("请输入用户的身份证号码:");
String id=i.next();
if(id.length()==18){
System.out.print("该用户的生日是:");
System.out.print(id.substring(6,10)+"年");
System.out.print(id.substring(10,12)+"月");
System.out.print(id.substring(12,14)+"日");
}else{
System.out.println("请输入正确的身份证号码!");
}
}
}
5.编写一个字符浏览器,输入字符串及需要查找的字符或字符串,浏览器自动定位所有出现该字符或字符串的位置。
import java.util.Scanner;
public class DJ15word5 {
@SuppressWarnings("resource")
public static void main(String[] args) {
Scanner i=new Scanner(System.in);
System.out.print("请输入一段字符:");
String one=i.next();
System.out.print("请输入要查找的字符:");
char two=i.next().charAt(0);
System.out.print(two+"出现的位置是:");
for(int a=0;a<one.length();a++){
if(two==one.charAt(a)){
System.out.print(a+" ");
}
}
}
}
6.对录入的信息进行有效性验证。
录入会员生日时,形式必须是“月/日”,如“09/12”。录入的密码位数必须为6~10位。允许用户重复录入,直到输入正确为止。
public class DJ15word6judge {
public String Birthday(String birthday){
String a="";
String prefix="该会员生日是:";
if(birthday.indexOf('/')!=2){
a="生日形式输入错误!";
}else{
a=prefix.concat(birthday);
}
return a;
}
public String Password(String password){
String b="";
String prefix="该会员密码是:";
if(password.length()<6||password.length()>10){
b="密码形式输入错误!";
}else{
b=prefix.concat(password);
}
return b;
}
}
import java.util.Scanner;
public class DJ15word6 {
@SuppressWarnings("resource")
public static void main(String[] args) {
DJ15word6judge l=new DJ15word6judge();
Scanner i=new Scanner(System.in);
String a="";
String b="";
do{
System.out.print("请输入会员生日<月/日:00/00>:");
String birthday=i.next();
System.out.println(l.Birthday(birthday));
a=l.Birthday(birthday);
}while("生日形式输入错误!".equalsIgnoreCase(a));
do{
System.out.print("请输入会员密码<6~10位>:");
String password=i.next();
System.out.println(l.Password(password));
b=l.Password(password);
}while("密码形式输入错误!".equalsIgnoreCase(b));
}
}
第十三天
1.实现用户登陆功能,在控制台输入用户名和密码,然后判断输入是否正确并输出结果。
import java.util.Scanner;
public class DJ16word1 {
public boolean login(String name,String password){
boolean judge=false;
if("jack".equalsIgnoreCase(name)&&"123456".equals(password)){
judge=true;
}
return judge;
}
@SuppressWarnings("resource")
public static void main(String[] args) {
DJ16word1 l=new DJ16word1();
Scanner i=new Scanner(System.in);
System.out.print("请输入用户名:");
String name=i.next();
System.out.print("请输入密码:");
String password=i.next();
if(l.login(name, password)){
System.out.println("登陆成功!");
}else{
System.out.println("登陆失败!");
}
}
}
2.在控制台输入学生姓名、年龄、性别和学校,然后模拟将该学生信息储存导数据库中。
public class DJ16word2Student {
private String name;
private String age;
private String sex;
private String school;
public String getname(){
return name;
}
public void setname(String name){
this.name=name;
}
public String getage(){
return age;
}
public void setage(String age){
this.age=age;
}
public String getsex(){
return sex;
}
public void setsex(String sex){
this.sex=sex;
}
public String getschool(){
return school;
}
public void setschool(String school){
this.school=school;
}
}
import java.util.Scanner;
public class DJ16word2{
public void insertStudent(DJ16word2Student stu){
String name=stu.getname();
String age=stu.getage();
String sex=stu.getsex();
String school=stu.getschool();
System.out.println("\n将该学生信息成功写入到数据库");
System.out.println(name+"\t"+age+"\t"+ sex +"\t"+school);
}
@SuppressWarnings("resource")
public static void main(String[] args) {
DJ16word2 a= new DJ16word2();
DJ16word2Student b=new DJ16word2Student();
Scanner i=new Scanner(System.in);
System.out.print("请输入学生姓名:");
String name=i.next();
System.out.print("请输入学生年龄:");
String age=i.next();
System.out.print("请输入学生性别:");
String sex=i.next();
System.out.print("请输入学生学校:");
String school=i.next();
b.setname(name);
b.setage(age);
b.setsex(sex);
b.setschool(school);
a.insertStudent(b);
}
}
3.某公司对固定资产进行编号,规则如下:购买年份+产品类型(1为台式机,2为笔记本,3为其他,统一采用两位数字表示,数字前加0)+3为随机数。
import java.util.Scanner;
public class DJ16word3 {
@SuppressWarnings("resource")
public static void main(String[] args) {
int age=0;
int type=0;
int max=999;
int min=100;
Scanner i=new Scanner(System.in);
System.out.print("请输入年份:");
age=i.nextInt();
System.out.print("请选择产品类型(1.台式机2.笔记本3.其他):");
type=i.nextInt();
if(type>0&&type<4){
int random=(int)(Math.random()*(max-min))+min;
System.out.print("该固定资产编号是:"+age+"0"+type+random);
}else{
System.out.println("你的输入有误!");
}
}
}
4.按照月/日/年的方法输入一个日期(如8/8/2008),然后对字符串进行拆分,输出某天是哪年哪月哪日(如2008年8月8日)。
import java.util.Scanner;
public class DJ16word4 {
@SuppressWarnings("resource")
public static void main(String[] args) {
Scanner i=new Scanner(System.in);
String date="";
System.out.print("请输入一个日期(月/日/年):");
date=i.next();
int num1=date.indexOf("/"); //返回第一个的" "的值
int num2=date.lastIndexOf("/");//返回最后面的" "的值
String day=date.substring(num1+1,num2);
String month=date.substring(0,num1);
String year=date.substring(num2+1,date.length());
System.out.println(year+"年"+month+"月"+day+"日");
}
}
第十四天
1.请写出网页的基本标签、作用和语法。
Basic tags 基 本 标 签
<html></html> Creates an HTML document 创 建 一 个HTML 文 档
<head></head> Sets off the title and other
information that isn't displayed
on the Web page itself 设 置 文 档 标 题 以 及 其 他 不 在WEB 网 页 上 显 示 的 信 息
<body></body> Sets off the visible portion of
the document 设 置 文 档 的 可 见 部 分
Header tags
标 题 标 签
<title></title> Puts the name of the document
in the title bar 将 文 档 的 题 目 放 在 标 题 栏 中
Body attributes
文 档 整 体 属 性
<body bgcolor=?> Sets the background color,
using name or hex value 设 置 背 景 颜 色, 使 用 名 字 或 十 六 进 制 值
<body text=?> Sets the text color, using
name or hex value 设 置 文 本 文 字 颜 色, 使 用 名 字 或 十 六 进 制 值
<body link=?> Sets the color of links,
using name or hex value 设 置 链 接 颜 色, 使 用 名 字 或 十 六 进 制 值
<body vlink=?> Sets the color of followed
links, using name or hex value 设 置 已 使 用 的 链 接 的 颜 色, 使 用 名 字 或 十 六 进 制 值
<body alink=?> Sets the color of links on click 设 置 正 在 被 击 中 的 链 接 的 颜 色, 使 用 名 字 或 十 六 进 制 值
Text tags
文 本 标 签
<pre></pre> Creates preformatted text 创 建 预 格 式 化 文 本
<h1></h1> Creates the largest headline 创 建 最 大 的 标 题
<h6></h6> Creates the smallest headline 创 建 最 小 的 标 题
<b></b> Creates bold text 创 建 黑 体 字
<i></i> Creates italic text 创 建 斜 体 字
<tt></tt> Creates teletype, or
typewriter-style text 创 建 打 字 机 风 格 的 字 体
<cite></cite> Creates a citation, usually
italic 创 建 一 个 引 用, 通 常 是 斜 体
<em></em> Emphasizes a word (with italic
or bold) 加 重 一 个 单 词( 通 常 是 斜 体 加 黑 体)
<strong></strong> Emphasizes a word (with italic
or bold) 加 重 一 个 单 词( 通 常 是 斜 体 加 黑 体)
<font size=?></font> Sets size of font, from 1 to 7 设 置 字 体 大 小, 从 1 到 7
<font color=?></font> Sets font color, using name or
hex value 设 置 字 体 的 颜 色, 使 用 名 字 或 十 六 进 制 值
2.超链接有哪些类型?它们的区别是什么?
按照连接一般分为以下3种类型:内部链接,锚点链接和外部链接。
1、超链接对象
超链接是超级链接的简称。如果按照使用对象的不同,网页中的链接又可以分为:文本超链接,图像超链接,E-mail链接,锚点链接,多媒体文件链接,空链接等。
超链接是一种对象,它以特殊编码的文本或图形的形式来实现链接,如果单击该链接,则相当于指示浏览器移至同一网页内的某个位置,或打开一个新的网页,或打开某一个新的WWW网站中的网页。
2、网页超链接
网页上的超链接一般分为三种:一种是绝对URL的超链接。URL(Uniform Resource Locator)就是统一资源定位符,简单地讲就是网络上的一个站点、网页的完整路径。
第二种是相对URL的超链接。如将网页上的某一段文字或某标题链接到同一网站的其他网页上面去;
还有一种称为同一网页的超链接,这种超链接又叫做书签。
3、动态静态
超链接还可以分为动态超链接和静态超链接。动态超链接指的是可以通过改变HTML代码来实现动态变化的超链接,例如可以实现将鼠标移动到某个文字链接上,文字就会象动画一样动起来或改变颜色的效果,也可以实现鼠标移到图片上图片就产生反色或朦胧等等的效果,而静态超链接,顾名思义,就是没有动态效果的超链接。
3.制作聚美优品常见问题页面,页面标题和问题和使用标题标签完成,问题答案使用段落标签签完成,客服温馨提示部分与问题列表之间使用水平线分隔。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>聚美优品常见问题页面</title>
</head>
<body>
<h1>
<img src="faq01.jpg"/><br/>
<hr>
<img src="faq03.jpg"/>客服温馨提示
</h1>
<p>
为了减少您可能的等待时间,您不妨先仔细阅读下面的常见问题。查询物流状态,退货,退余额等操作均可以登录聚<br>
美优品网站后自助进行,无需联系客服。如果仍无法解决。请您在本页页底联系在线客服,或拨打聚美客服电话。小美<br>
谢谢您的理解!
<hr/>
</p>
<h3>
聚美订单什么时候发货?大概多长时间可以收到货?
</h3>
<p>
正常情况下您的订单将在6小时后内发出(最晚不超过一个工作日)。8月1日的订单,将在3日内全部发出。发货之后,您<br/>
可以在我的订单中可以查看发货状态。由于快递公司可能无法实时更新信息,因此您看到的发货情况可能一定会延迟。<br/>
</p>
<h3>
为什么后下的订单,先收到了,之前下的订单还没收到?你们是按什么顺序发货的?
</h3>
<p>
为了单位时间内以最快速度处理尽量多订单,聚美会适当综合按订单里货品配货的情况安排发货,因此可能会出现<br/>
订单发货和下单顺序不完全一致的情况。我们会尽一切努力为你尽快发货。<br/>
</p>
<h3>
订单发货了,但快递信息为什么还没更新?
</h3>
</body>
</html>
4.制作聚美优品帮助中心菜单列表页面,菜单超链接均设置为空链接,菜单中间使用水平线分隔。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>聚美优品菜单列表</title>
</head>
<body>
<h1>
帮助中心
</h1>
<h4>
<a href="#"target=" "> 使用帮助</a>
</h4>
<hr>
<h4>
<a href="#"target=" "> 账户相关</a>
</h4>
<hr>
<h4>
<a href="#"target=" "> 支付相关</a>
</h4>
<hr>
<h4>
<a href="#"target=" "> 配送相关</a>
</h4>
<hr>
<h4><a href="#"target=" "> 售后服务</a>
</h4>
<hr>
<h4><a href="#"target=" "> 聚美手机版</a>
</h4>
<hr>
</body>
</html>
5.制作滚筒洗衣机销售排行榜,左侧为图片,右侧为图片说明和价格,商品之间用水平线分隔。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>滚筒洗衣机销售排行榜</title>
</head>
<body>
<h1>滚筒洗衣机销售排行榜</h1>
<h4>
<img src="wish01.jpg"/>格兰仕XQG660-A708 ¥1099.00
</h4>
<hr>
<h4>
<img src="wish02.jpg"/>LG WD-N12430D ¥2599.00
</h4>
<hr>
<h4>
<img src="wish03.jpg"/>三洋XQG60-F1029 ¥1998.00
</h4>
<hr>
<h4>
<img src="wish04.jpg"/>三星WF1702NCW/XSC ¥2499.00
</h4>
<hr>
<h4>
<img src="wish05.jpg"/>西门子XQG60-WS10K2670W ¥3999.00
</h4>
<hr>
</body>
</html>
第十五天
1.无序列表、有序列表和定义列表适用的场合分别是什么?
有序列表使用编号来记录项目的顺序(那种有1- 2- 3-顺序的列表可以用这个)
无序列表使用项目符号来记录无序的项目(一般表示并列项)
自定义列表它由两个部分组成:定义条件和定义描述。
1
2
3
2.表格的跨行、列表分别使用什么属性?要实现一个3行2列的单元格需要哪些步骤?
跨行用:rowspan="所跨的行数"
跨列用:colspan="所跨的行数"
一般而言,跨行或跨列操作时,需要以下两个步骤。
(1)在需要合并的第一个单元格,设置跨列或跨行属性,列如rowspan=“3”,colspan=“2”
(2)删除被合并的单元格,即把某个单元格看成多个单元格合并后的单元格。
3.HTML5中的媒体元素有哪些?怎么实现不同浏览器都能播放?
HTML5中的媒体元素有:Ogg,MPEG4,WebM,MP3,WAV,audio,embed,iframe
实现不同浏览器都能播放:<source arc="媒体路径">
1
2
4.制作百度页面中的"品牌全知道"版块。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>品牌全知道</title>
</head>
<body>
<img src="iknowshouye.jpg" title="车展全知道"\>
<h3>品牌全知道</h3>
<ul>
<li><img src="icon-1.jpg"\>理肤泉敏感全知道</li>
<li><img src="icon-2.jpg"\>薇姿健康肌肤全知道</li>
<li><img src="icon-3.jpg"\>中信银行全知道</li>
<li><img src="icon-4.jpg"\>Windows7全知道</li>
<li><img src="icon-5.jpg"\>海信电视全知道</li>
<li><img src="icon-6.jpg"\>多美滋全知道</li>
<li><img src="icon-7.jpg"\>三星手机全知道</li>
</ul>
</body>
</html>
5.使用HTML5中的结构元素布局贵美-商城购物车页面。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>贵美商城-商品购买页</title>
</head>
<body>
<style>
header,section,footer{
width: 1000px;
height: 1000px;
border: 1px;
}
</style>
<header>
<p>
<img src="100" width="100" width="100" title="头部">
</p>
</header>
<header>
<p>
<img src="100" width="100" width="100" title="主体">
</p>
</header>
<header>
<p>
<img src="100" width="100" width="100" title="尾部">
</p>
</header>
</body>
</html>
第十六天
1.标签的for属性表示什么?
for 属性规定 label 与哪个表单元素绑定,label的for属性要与绑定表单元素(input)的ID对应。绑定完成后可以通过点击label触发表单元素的默认属性。通俗的讲就是你绑定完了点lebel就相当于点击表单元素(input)。
2.哪些元素自身就有验证功能?
数字类型、邮箱类型等一部分表单有自身验证功能
3.请用HTML5实现所示的申请表表单。相关要求如下。
教育程度:默认选中硕士。
国籍:有美国、澳大利亚、日本、新加坡,默认选中澳大利亚。
单击文字相应的文本框得到焦点。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>申请表</title>
</head>
<body>
<h1>申请表</h1>
<form method="post" action="">
<p>
姓名:
<input type="text" name="name"/>
</p>
<p>
教育程度:
<input type="radio" name="Education" checked>硕士
<input type="radio" name="Education" >博士
</p>
<p>
常用邮箱:
<input type="email" name="email">
</p>
<p>
性别:
<input type="radio" name="Sex" checked>男
<input type="radio" name="Sex">女
</p>
<p>
年龄:
<input type="number" name="age">
</p>
<p>
月薪:
<input type="text" name="income">
</p>
<p>
附注:
<textarea name="" cols="40" rows="6">请在这里键入附注
</textarea>
</p>
<p>
国籍:
<select name="">
<option value="1">美国</option>
<option value="2" selected>澳大利亚</option>
<option value="3">日本</option>
<option value="4">新加坡</option>
</select>
</p>
<input type="submit" name="" value="提交" />
<input type="reset" name="" value="重置" />
</form>
</body>
</html>
4.请用HTML5实现所示的电子产品调查表表单。
请输入您的购买日期:"月份"下拉列表框为1-12月,“日"下拉列表框为1-31日。
您是否查看过我们的在线产品目录:默认选中"是”。
单击文字相应的文本框得到焦点。
所有表单元素不能为空。
使用placeholder属性为表单元素添加提示文字。
重置按钮禁止操作。
不需要用patten写验证条件。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>电子产品调查问卷</title>
</head>
<body>
<h1>American Metric 电子产品调查表</h1>
<form action="" method="post">
<p>
姓名:
<input type="text" placeholder="输入必须是2-6个字符" required/>
</p>
<p>
购买日期:
<input type="number" name="" required/>年
<select name="">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>月
<select name="">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>日
</p>
<p>
电子邮件地址:
<input type="email" name="" placeholder="www.baidu" required/>
</p>
<p>
手机号码:
<input type="number" name="" placeholder="输入必须是以13/15/18开头的11位数字" required/>
</p>
<p>
您是否看过我们的在线产品目录?
<input type="radio" name="judge" checked/>是
<input type="radio" name="judge"/>否
</p>
<p>
如果查看过,您对哪些电子产品有兴趣购买?(选择提供的产品)<br/>
<input type="radio" name=""/>大屏幕电视机
<input type="radio" name=""/>音频设备
<input type="radio" name=""/>视屏设备
<input type="radio" name=""/>相机
</p>
<p>
在填写订单之前,您还有什么问题、意见或建议?<br/>
<textarea name="" cols="40" rows="6">您的输入:
</textarea>
</p>
<input type="submit" value="提交"/>
<input type="reset" value="重置" disabled/>
</form>
</body>
</html>
第十七天
1.使用CSS制作网页有哪些优势?
大大缩减页面代码,提高页面浏览速度,缩减带宽成本;
结构清晰,容易被搜索引擎搜索到
缩短改版时间。只要简单的修改几个CSS文件就可以重新设计一个有成百上千页面的站点。
强大的字体控制和排版能力。CSS控制字体的能力比糟糕的FONT标签好多了,有了CSS,我们不再需要用FONT标签或者透明的1 px GIF图片来控制标题,改变字体颜色,字体样式等等。
CSS非常容易编写。你可以象写html代码一样轻松地编写CSS。
提高易用性。使用CSS可以结构化HTML
可以一次设计,随处发布。
更好的控制页面布局。
表现和内容相分离。将设计部分剥离出来放在一个独立样式文件中,你可以减少未来网页无效的可能。
更方便搜索引擎的搜索。用只包含结构化内容的HTML代替嵌套的标签,搜索引擎将更有效地搜索到你的内容,并可能给你一个较高的评价(ranking)。
Table 布局灵活性不大,你只能遵循 table tr td 的格式。而div 你可以 div ul li 也可以 ol li 还可以 ul li ……但标准语法最好有序的写。
另外如果你不是javascrput的高手,你可以不必去写ID,只用class就可以。当客户端程序员写完程序,需要调整时候,你可以在利用他的ID进行控制。
Table 中布局中,垃圾代码会很多,一些修饰的样式及布局的代码混合一起,很不利于直观。而Div 更能体现样式和结构相分离,结构的重构性强。
在几乎所有的浏览器上都可以使用。
以前一些非得通过图片转换实现的功能,现在只要用CSS就可以轻松实现,从而更快地下载页面。
使页面的字体变得更漂亮,更容易编排,使页面真正赏心悦目。
你可以轻松地控制页面的布局 。
2.使用>style>标签和style属性引入CSS样式有哪些相同点和不同点?
html头部用的style>标签的方式属于内联样式,而用style直接写在标签里面的样式属于行内样式,两者的相同点在于都可以达到修饰的作用,唯一不同点在于当出现相同属性后会以行内样式为准(例:行内样式和内联样式针对同一个标签同时出现背景色、高度、宽度等)这是由于行内样式的权重大于内联样式引起的
3.说明E F:nth-of-child(n)和E F:nth-of-type(n)两种选择器的区别与个自的使用场景。
E:nth-child(n)///选中父元素中第(n)个元素.若第n个元素为E则选中;若第n个不为E则不选中。n可以为2n(偶数)、2n+1(奇数)、等…
E:nth-of-type(n)///选中父元素中第(n)个为E的元素。n的取值同上。
4.制作图4.35所示的北大青鸟总裁致辞页面,页面要求如下。
标题使用标题标签实现,字体大小为18px。
致辞正文字体大小为12px,页面中的数字均为加粗、红色字体。
页面中的年份斜体显示,字体大小为16px.字体颜色为蓝色。
使用外部样式表创建页面样式,页面样式体现高级选择器的应用
/*标签选择器*/
h1{
font-size: 18px;
}
/*标签选择器*/
p{
font-size: 12px;
font-weight: bold;
}
/*后代选择器*/
p strong{
color: red;
}
/*后代选择器*/
p em{
font-size: 16px;
color: blue;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>总裁致辞页面</title>
</head>
<link rel="stylesheet" href="DJ4word4.css" type="text/css"/>
</head>
<body>
<h1>总裁致辞</h1>
<hr/>
<img src="icon.jpg" alt=""/>
<p>目前北大青鸟IT教育行业全体系员工<strong>10000</strong>余名,授权培训中心<strong>180</strong>余家、合作院校<strong>500</strong>余所、覆盖全国<strong>90</strong>余座城市,市场占有率<br/>达到<strong>39.8%</strong>。<br/><br/>作为IT职业教育的先行者,北大青鸟IT教育创新的职业教育理念和业务经营模式得到了社会的广泛认可:国家人力资源和社<br/>会保障部与北大青鸟IT教育实施课程联合认证制度;公司两度入选中华人民共和国商务部评选的“中国连锁经营百强企<br/>业”,是迄今为止教育培训领域唯一上榜品牌。公司连续两年荣获 “中国服务业十大优秀特许品牌”称号,并获得中国特许<br/>经营协会颁发的中国连锁经营百强和中国特许经营年度大奖;获得新浪颁发的“中国教育杰出贡献奖”和“中国十大品牌教<br/>育集团”称号;并赢得 “中国IT公众认知企业金奖”、“本土最具知名度认证奖”、“最佳就业认同奖”、“质量放心用户<br/>满意双优品牌”、“最佳实用课程奖”等数十个奖项。人民日报、光明日报、经济日报、解放日报、中国青年报、中国计算<br/>机报等几十家权威媒体对公司进行了多方面的报道。<br/><br/><em>2000年</em>,北大青鸟IT教育创造性地将特许经营模式引入到IT职业教育领域,在全国建立“北大青鸟APTECH计算机授权培<br/>训中心”。所有中心实行统一经营管理、严格保证教学质量,受到社会和业界的高度认可。发展速度之快、经营规模之大、<br/>学员人数之多,在全国众多IT职业培训机构中一枝独秀。成立至今,北大青鸟IT教育先后培养45万名学员进入IT行业。
</p>
</body>
</html>
2.制作图436所示的员工团队风采页面页面要求如下。
标题使用标题标签实现字体大小为18px第一个标题的字体颜色为红色第二个标题:字体颜色为绿色。
页面字体大小为14px.
第一个标题下面的两张图片宽度为300px高度为200px。
最后一段文字的颜色为蓝色。
"联系我们"等内容字体大小为14px颜色为#640000.
cSS 样式体现标签选择器。类选择器、ID选择器、层次选择器结构伪类选择器属性选择器。
使用外部样式表创是页面样式。完整页面显示效果请参考素材文件里的效果图。
/*标签选择器*/
h1{
font-size: 18px;
color: red;
}
/*ID选择器*/
#1{
font-size: 18px;
color: green;
}
/*类选择器
.picture{
width: 300px;
height: 200px;
}*/
/*属性选择器*/
img[src="100"]{
width: 300px;
height: 200px;
}
/*结构伪类选择器
body p:last-of-type{
color: blue;
}*/
/*后代选择器*/
last p{
color: blue;
}
/*属性选择器*/
a[href]{
font-size: 14px;
color: #640000;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>员工团队风采页面</title>
</head>
<link rel="stylesheet" type="text/css" href="DJ4word5.css"/>
<body>
<p>
<img src="recruit-01.jpg" alt=""/>
<img src="recruit-02.jpg" alt=""/>
</p>
<p>北大青鸟始终以人才作为企业的核心资本。为了吸引、激励和保留优秀人才, 公司为员工提供完善的培训与发展体系,关注员工成<br/>长,同时在兼顾市场竞 争力和内部公平的基础上为员工提供全面、富有竞争力的薪酬福利体系。良好的企业发展前景、广阔的个人<br/>发展平台、快乐向上的工作环境,是青鸟人一直秉承的核心要素</p>
<h1>我们的管理团队</h1>
<p>
<img src="recruit-03.jpg" alt=""/>
<img src="recruit-04.jpg" alt=""/>
</p>
<p>北大青鸟始终以人才作为企业的核心资本。为了吸引、激励和保留优秀人才,公司为员工提供完善的培训与发展体系,关注员工成<br/>长,同时在兼顾市场竞争力和内部公平的基础上为员工提供全面、富有竞争力的薪酬福利体系。良好的企业发展前景、 广阔的个人<br/>发展平台、快乐向上的</p>
<h1 id="#1">我们的部门风采</h1>
<img src="recruit-05.jpg" alt=""/>
<p>北大青鸟始终以人才作为企业的核心资本。为了吸引、激励和保留优秀人才,公司为员工提供完善的培训与发展体系,<br/>关注员工成长,同时在兼顾市场竞争力和内部公平的基础上为员工提供全面、富有竞争力的薪酬福利体系。良好的企业<br/>发展前景、 广阔的个人发展空间。</p>
<ul>
<li><a href="http://www.bdqn/page/contactus.shtml">联系我们</a></li>
<li><a href="">关于我们</a></li>
<li><a href="">版权声明</a></li>
<li><a href="">招商加盟</a></li>
</ul>
</body>
</html>
第十八天
1.使用font-fanmily属性,同时设置英文字体和中文字体时需要注意什么问题?
把英文字体写在前面,中文的写在后面
2.在CSS中,常用的背景属性有哪几个?他们的作用是什么?
background:#fff url(‘sss.jpg’) no-rerepeat;
颜色,背景图片路径,不循环
还有一个background-size:背景图片的大小
3.制作北大青鸟课程介绍页面(页面效果参见提供的上机练习素材中的页面效果图),页面要求如下。
使用《div》,《p》,《span》等标签编辑页面,页面整体背景颜色使用线性渐变(#ECECEC,#FFFFFD)。
课程特色字体颜色为绿色(#5C9815),设计理念字体为橙色(#F26522)。
课程特色和设计理念每行开头带背景颜色的字体为白色,背景颜色从提供作业素材的页面中获取,使用结构伪类选择器元素。
使用外部样式表创建页面样式。
/*整体设定*/
#whole{
width: 600px;
background-color: #eeeeee;
background: linear-gradient(to bottom,#ECECEC,#FFFFED);
}
/*id选择器*/
#whole span{
color: #ffffff;
}
/*改变字体背景*/
.one{
line-height:30px;
color: #5C9815;
}
.one span:nth-of-type(1) {
background-color:#005952;
}
.one span:nth-of-type(2) {
background-color:#007236;
}
.one span:nth-of-type(3) {
background-color:#008bbf;
}
.one span:nth-of-type(4) {
background-color:#0066b3;
}
.one span:nth-of-type(5){
background-color:#002561;
}
/*id选择器*/
.two{
line-height:30px;
color: #F26522;
}
/*改变字体背景*/
.two span:nth-of-type(1) {
background-color:#f36f21;
}
.two span:nth-of-type(2) {
background-color:#bb131a;
}
.two span:nth-of-type(3){
background-color:#d73765;
}
.two span:nth-of-type(4) {
background-color:#a70532;
}
.two span:nth-of-type(5) {
background-color:#553171;
}
.two span:nth-of-type(6){
background-color:#4f1268;
}
<!DOCTYPE html>
<htm1l lang="en">
<head>
<meta charset="UTF-8">
<title>北大青鸟课程介绍页面</title>
<!--引用选择器-->
<link rel="stylesheet" href="DJ5word3.css" type="text/css"/>
</head>
<body>
<!--引用whole样式-->
<div id="whole">
<!--插入图片-->
<h2><img src="title.gif"></h2>
<h3><img src="img_01.png"></h3>
<!--引用one样式-->
<div class="one">
<span>逆向课程设计:</span> 以企业需求决定课程设计内容,确保训练内容及深度和企业需求<br/>一致<br/>
<span>模拟学员学习路线:</span> 强调难点和复杂技能点的反复训练,力求学习效果和学习体<br/>验<br/>
<span>互联网作为教学环境:</span> 学员的日常教学和训练均在互联网线上进行<br/>
<span>学习挡板监控网上学习效果:</span> 每个学习阶段设置线上线下测试,严密监控学习效<br/>果<br/>
<span>真实开发项目经验积累:</span> 采用专业互联网企业提供的真实项目作为模拟开发<br/>
</div>
<!--插入图片-->
<h3><img src="img_02.png"></h3>
<!--引用two样式-->
<div class="two">
<span>【实用性】——</span> 以就业岗位需求为导向,重点讲解企业80%的时间在使用的20%<br/>的技术<br/>
<span>【权威性】——</span> 与来自百度等知名企业的专家联合开发<br/>
<span>【专业性】——</span> 引进业内资深人才和典型行业开发项目<br/>
<span>【真实性】——</span> 在互联网真实环境下进行教学和训练<br/>
<span>【易学性】——</span> 在线培训模式,24小时专家在线解答疑难问题<br/>
<span>【完整性】——</span> 利用SNS虚拟社区:学习、人脉双丰收<br/>
</div>
</div>
</body>
</htm1l>
4.制作席慕容的诗《初相遇》(页面效果参见提供的上机练习素材中的页面效果图),页面要求如下。
页面总宽度为400px,整体背景颜色线性渐变(#CAEFFE,#FFFFED);
使用《h1》标签排版文字标题,字体大小为18px,黑色文字阴影。
使用《p》标签排版文字正文,首行缩进为2em,行高为22px。
首段第一个“美”字,字体大小为18px,加粗显示,黑色和白色文字阴影,具体方向参考素材效果图。第二段中的“胸怀中满溢······在我眼前”字体风格倾斜,颜色为蓝色,字体大小为16px。正文其余文字大小为12px。
最后一段文字带下划线。
使用外部样式表创建页面样式。
页面中的字体颜色从提供作业素材的页面效果图中获取。
/*设定整体*/
body{
font-size: 12px;
font-family:Verdana,Arial,Helvetica,sans-serif, "宋体";
width: 400px;
height: 400px;
}
/*设置主题部分*/
#whole{
background: 400px;
background: linear-gradient(to bottom,#CAEFFE,#FFFFED);
}
/*设置标题*/
h1{
font-size: 18px;
color: #0d7dac;
text-align: center;
text-shadow: black 1px 1px 1px;
}
/*设置特定字体*/
span{
font-size: 12px;
color: #999999;
font-weight: normal;
}
/*设置p标签的样式*/
p{
text-indent: 2em;
line-height: 22px;
}
.one{
font-size: 18px;
color:violet;
font-weight: bold;
text-shadow: white 2px 2px 2px,black 2px 2px 2px,white -2px -2px 2px;
}
.two{
font-size: 18px;
color: #4c67f4;
font-style: oblique;
}
.three{
color: #339900;
text-decoration: underline;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>初相遇--席慕容</title>
<!--引用选择器-->
<link rel="stylesheet" type="text/css" href="DJ5word4.css">
</head>
<body>
<!--引用whole样式-->
<div id="whole">
<h1>初相遇 <!--引用样式--><span>文/席慕容</span></h1>
<p>
<!--引用one样式-->
<span class="one">美</span>
丽的梦和美丽的诗一样,都是可遇而不可求的,常常在最没能料到<br/>的时刻里出现。
</p>
<p>
我喜欢那样的梦,在梦里,一切都可以重新开始,一切都可以慢慢解<br/>释,心里甚至还能感觉到,所有被浪费的时光竟然都能重回时的狂喜与感<br/>激。<!--引用two样式--><span class="two">胸怀中满溢着幸福,只因你就在我眼前</span> ,对我微笑,一如<br/>当年。
</p>
<!--引用three样式-->
<p class="three">
我喜欢那样的梦,明明知道你已为我跋涉千里,却又觉得芳草鲜美,落<br/>落英缤纷,好像你我才初相遇。
</p>
</div>
</body>
</html>
5.制作淘宝女装分类页面(页面效果参见提供的上机练习素材中的页面效果图),页面要求如下。
使用无序列表等HTML标签有语义化的编辑页面。
女装各分类名称前的图片使用背景图片的方式实现,标题字体大小为18px,加粗显示。
分类内容字体大小为12px,超链接文本字体颜色为黑色,无下划线,当鼠标移至超链接文本字体上时字体颜色为橙色(#F60),并且显示下划线。
使用外部样式表创建页面样式。
页面中其他的效果样式见提供的作业素材中的页面效果图。
/*设置标题*/
h2{
font-size: 18px;
font-weight: bold;
}
/*引用图片当背景*/
.one{
background: url(../Semester1book3DJ5/dress01.png) 0px 0px no-repeat;
}
.two{
background: url(../Semester1book3DJ5/dress02.png) 0px 0px no-repeat;
}
.three{
background: url(../Semester1book3DJ5/dress03.png) 0px 0px no-repeat;
}
.four{
background: url(../Semester1book3DJ5/dress04.png) 0px 0px no-repeat;
}
.five{
background: url(../Semester1book3DJ5/dress05.png) 0px 0px no-repeat;
}
/*设置p标签样式*/
p{
font-size: 12px;
}
/*设置悬停时样式*/
a:hover{
text-decoration: underline;
color: #F60;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>淘宝女装分类页面</title>
</head>
<!--引用样式-->
<link rel="stylesheet" href="DJ5word5.css" type="text/css">
<body>
<!--使用无序列表-->
<ul>
<li>
<!--使用one样式-->
<h2 class="one"> 夏季流行</h2>
<hr/>
<p>
<!--引用悬停样式-->
<a href="#">夏季新品</a>
<a href="#">雪纺裙</a>
<a href="#">短袖T</a>
<a href="#">铅笔裤</a>
<a href="#">短裤</a>
<a href="#">短袖衬衫</a>
<a href="#">小脚牛仔裤<br/></a>
<a href="#">开衫</a>
<a href="#">蕾丝/雪纺衫</a>
<a href="#">韩版外套</a>
<a href="#">小西装</a>
<a href="#">中长款裙</a>
</p>
</li>
<li>
<!--使用two样式-->
<h2 class="two"> 上装</h2>
<hr/>
<p>
<!--引用悬停样式-->
<a href="#">T恤</a>
<a href="#">衬衫</a>
<a href="#">针织衫</a>
<a href="#">长袖T</a>
<a href="#">韩版T</a>
<a href="#">情侣衫</a>
<a href="#">雪纺衬衫</a>
<a href="#">韩版衬衫<br/></a>
<a href="#">防晒衣</a>
<a href="#">休闲套装</a>
<a href="#">卫衣</a>
<a href="#">背心/吊带</a>
</p>
</li>
<li>
<!--使用three样式-->
<h2 class="three"> 裙子</h2>
<hr/>
<p>
<!--引用悬停样式-->
<a href="#">连衣裙</a>
<a href="#">半身裙</a>
<a href="#">长裙</a>
<a href="#">短袖裙</a>
<a href="#">蕾丝连衣裙</a>
<a href="#">长袖裙</a>
<a href="#">无袖/背心<br/>裙</a>
<a href="#">A字裙</a>
<a href="#">牛仔裙</a>
<a href="#">半身中长裙</a>
<a href="#">半身短裙</a>
<a href="#">包臀裙</a>
</p>
</li>
<li>
<!--使用four样式-->
<h2 class="four"> 裤子</h2>
<hr/>
<p>
<!--引用悬停样式-->
<a href="#">裤子</a>
<a href="#">休闲裤</a>
<a href="#">牛仔裤</a>
<a href="#">打底裤</a>
<a href="#">长裤</a>
<a href="#">哈伦裤</a>
<a href="#">阔腿裤</a>
<a href="#">短裤/热<br/>裤</a>
<a href="#">连体裤</a>
<a href="#">七/九分裤</a>
<a href="#">牛仔短裤</a>
<a href="#">西装裤</a>
</p>
</li>
<li>
<!--使用five样式-->
<h2 class="five"> 其他女装</h2>
<hr/>
<p>
<!--引用悬停样式-->
<a href="#">胖M装</a>
<a href="#">中老年</a>
<a href="#">婚纱</a>
<a href="#">礼服</a>
<a href="#">旗袍</a>
<a href="#">夜店</a>
<a href="#">舞台装</a>
<a href="#">唐装</a>
<a href="#">职业装<br/></a>
<a href="#">全球购</a>
<a href="#">羊绒衫</a>
<a href="#">毛衣</a>
<a href="#">呢大衣</a>
<a href="#">羽绒服</a>
<a href="#">真皮皮衣</a>
</p>
</li>
</ul>
</body>
</html>
第十九天
1.什么是盒子模型?盒子模型的属性有那几个?它们的作用分别是什么?
(1)CSS将网页中所有元素都看成一个个盒子。
(2)盒子模型属性有边框、内边距和外边距。
(3)边框设置网页元素边框的颜色、粗细和样式;外边距指与其他盒子之间的距离,也就是指网页中元素与元素之间的距离,便于精确控制盒子的位置;内边距用于控制内容与边框之间的距离,以便精确控制内容在盒子中的位置。
2.盒子模型有哪几种解析方式?它们有什么区别?
content-box:默认值,盒子的宽度或高度 = border+padding+(margin)+ width/height。
border-box:盒子的宽度或高度等于元素内容的宽度或高度。从盒子模型的介绍可知,这里内容宽度或高度包含了元素的border、padding、内容的宽度或高度(此处的内容宽度或高度=盒子宽度或高度-border-padding)。
3.制作图北大青鸟网站的中心开班信息模块。要求如下:
<页面宽度250px,整体居中显示,背景使用线性渐变及1px的灰色圆角边框。
<标题左侧的小图标以背景图片的方式实现,标题颜色为白色。
<使用无序实现开班信息列表,列表前的小三角箭头和下方的虚线均使用背景图像的方式实现。
<列表超链接文本颜色为灰色,无下划线,当鼠标悬浮在超链接文本上是,字体颜色改变无下划线。
<页面中涉及的盒子模型解析方式都使用border-box。
/*初始化内外边距*/
body,div,ul,li{
padding: 0px;
margin: 0px;
}
/*设置页面整体*/
.div{
width: 250px;
margin: 0 auto;
border: 1px solid #d8d8d8;
border-radius: 8px;
box-sizing:border-box;
background: linear-gradient(to bottom,#5bc1f9 ,#FFF,#FFF,#FFF,#FFF);/*渐变*/
}
/*设置标题*/
.h2{
background: url("../Semester1book3DJ6/bg.gif") 5px no-repeat;
color: white;
font-size: 14px;
padding-left: 45px;
margin: 10px 0px;
font-weight:bold;
height: 40px;
line-height:40px;
border-bottom: 1px solid #FFFFFF;
}
/*设置列表*/
li{
list-style:none;/*去前面的原点*/
background: url("../Semester1book3DJ6/dotBg.gif") -9px center no-repeat;
width:220px;
height:30px;
padding-left: 10px;
margin: 10px 0px;
}
/*原来*/
a{
color: #626262;
text-decoration: none;
}
/*悬浮时*/
a:hover{
color: #F30;
text-decoration: none;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>中心开班信息</title>
<link rel="stylesheet" href="DJ6word3.css" type="text/css">
</head>
<body>
<div class="div">
<h2 class="h2">中心开班信息</h2>
<ul>
<li><a href="#">8月12日:学历+技能班</a></li>
<li><a href="#">8月16日:高考特招班</a></li>
<li><a href="#">8月23日:Java精英班</a></li>
<li><a href="#">8月31日:学士后强化班</a></li>
<li><a href="#">9月5日:大学生就业班</a></li>
<li><a href="#">9月9日:企业定向委培班</a></li>
<li><a href="#">9月16日:网络营销强化班</a></li>
</ul>
</div>
</body>
</html>
4.制作图商品分类列表页面。
<商品列表放在一个div中,<div的四边框均为2px的橙色实线圆角边框。
<用结构伪类选择器选择每个列表并为其加上背景图每个列表下方1px的灰色虚线边框,但是最后一个列表项没有。
<文本超链接为黑色粗体,当鼠标悬浮在超链接文本上变色,平切无下划线。
/*初始化内外边距*/
body,div,ul,li{
margin: 0px;
padding: 0px;
}
li{
list-style:none;
}
/*设置整体*/
#div{
width: 200px;
border: #fc9829 2px solid;
border-radius:8px;
box-sizing: border-box;
}
/*设置宽度去除前面装饰*/
#div ul{
width: 190px;
margin: 0px auto;
}
/*设置列表*/
#div li{
height:47px;
font-size:12px;
font-weight:bold;
padding-left:50px;
border-bottom:1px #929292 dotted;
line-height:47px;
box-sizing: border-box;
}
/*未悬浮时*/
#div a{
color: black;
font-weight: bold;
text-decoration:none;
}
/*悬浮时*/
#div a:hover{
color: #008bbf;
text-decoration:none;
}
/*设置列表背景*/
#div li:nth-of-type(1){
background: url("../Semester1book3DJ6/icon_01.jpg") 0px 0px no-repeat;
}
#div li:nth-of-type(2){
background: url("../Semester1book3DJ6/icon_02.jpg") 0px 0px no-repeat;
}
#div li:nth-of-type(3){
background: url("../Semester1book3DJ6/icon_03.jpg") 0px 0px no-repeat;
}
#div li:nth-of-type(4){
background: url("../Semester1book3DJ6/icon_04.jpg") 0px 0px no-repeat;
}
#div li:nth-of-type(5){
background: url("../Semester1book3DJ6/icon_05.jpg") 0px 0px no-repeat;
}
#div li:nth-of-type(6){
background: url("../Semester1book3DJ6/icon_06.jpg") 0px 0px no-repeat;
}
#div li:nth-of-type(7){
background: url("../Semester1book3DJ6/icon_07.jpg") 0px 0px no-repeat;
}
#div li:nth-of-type(8){
background: url("../Semester1book3DJ6/icon_08.jpg") 0px 0px no-repeat;
}
#div li:nth-of-type(9){
background: url("../Semester1book3DJ6/icon_09.jpg") 0px 0px no-repeat;
}
#div li:nth-of-type(10){
background: url("../Semester1book3DJ6/icon_10.jpg") 0px 0px no-repeat;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>商品分类列表页</title>
<link rel="stylesheet" href="DJ6word4.css" type="text/css">
</head>
<body>
<div id="div">
<ul>
<li><a href="#">酒水、饮料</a></li>
<li><a href="#">进口食品</a></li>
<li><a href="#">休闲零食</a></li>
<li><a href="#">地方特产</a></li>
<li><a href="#">保健、冲调</a></li>
<li><a href="#">粮油、生鲜</a></li>
<li><a href="#">美容洗护</a></li>
<li><a href="#">清洁洗涤</a></li>
<li><a href="#">母婴、纸品</a></li>
<li><a href="#">家居百货</a></li>
</ul>
</div>
</body>
</html>
5.制作权威课程免费体验登录页面。
<页面文本颜色为白色,*的字体颜色为红色。
<使用无序列表排版单元素。
<无序列表内容在页面中居中显示。
<“免费体验”按钮使用背景图像的方式实现。
<按语义化使用表单元素,且是圆角边框。
body,div,ul,li{
margin: 0px;
padding: 0px;
}
li {
list-style-type:none;
}
.picture{
width: 312px;
height: 353px;
background: url("../Semester1book3DJ6/bg.jpg") 0px 0px no-repeat;
}
.su{
width: 260px;
margin: 0px auto;
padding-top: 80px;
font-size: 14px;
color: white;
box-sizing: border-box;
}
li{
height: 38px;
line-height: 38px;
}
li span{
color: red;
padding-right: 5px;
}
select{
border: 1px #7b7b7b solid;
border-radius: 4px;
}
.button{
background: url("../Semester1book3DJ6/btn.jpg") 0px 0px no-repeat;
width:152px;
height:49px;
border:0px;
cursor:pointer;
}
.male{
text-align:center;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>免费体验登陆页面</title>
<link rel="stylesheet" href="DJ6word5.css" type="text/css">
</head>
<body>
<div class="picture">
<div class="su">
<ul>
<li>
<span>*</span>姓名:
<input type="text" name="name">
</li>
<li>
<span>*</span>邮箱:
<input type="email" name="email">
</li>
<li>
<span>*</span>电话:
<input type="number" name="number">
</li>
<li>性别:
<select name="sex">
<option>请选择</option>
<option>男</option>
<option>女</option>
</select>
</li>
<li>年龄:
<select name="age">
<option>请选择</option>
<option>1</option>
<option>2</option>
</select>
</li>
<li class="male">
<input type="submit" value=" " class="button">
</li>
</ul>
</div>
</div>
</body>
</html>
第二十天
1.清除浮动的方法有哪几种?分别如何实现?
(1)浮动元素后面加空div
(2)设置父元素的高度
(3)父级添加overflow属性
(4)父级添加伪类
2.使用display:inlink-block或float布局页面有什么区别?需要注意什么?
(1)display:inline-block
可以让元素排在一行,并且支持宽度和高度,代码实现起来方便
位置方向不可控制,会解析空格,IE 6、IE 7上不支持
(2)float
可以让元素排在一行并且支持宽度和高度,可以决定排列方向
float 浮动以后元素脱离文档流,会对周围元素产生影响,必须在它的父级上添加清除浮动的样式
3.制作摄影社区热门小镇页面(页面效果及页面中的图片、字体颜色等参见提供的作业素材),要求如下。
使用<div和无序列表相结合的方法布局HTML文档。
使用float属性创建横向多列排版网页元素。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>摄影社区热门小镇</title>
<link rel="stylesheet" href="DJ7word3.css" type="text/css">
</head>
<body>
<div>
<h1>摄影社区热门小镇</h1>
<ul>
<li class="one">
<a href="#"><img src="pic_01.jpg"></a>
<h2>风景狙击手</h2>
<ul>
<li>成员:80</li>
<li>作品:276</li>
</ul>
</li>
<li class="one">
<a href="#"><img src="pic_02.jpg"></a>
<h2>叙事感</h2>
<ul>
<li>成员:235</li>
<li>作品:116</li>
</ul>
</li>
<li class="one">
<a href="#"><img src="pic_03.jpg"></a>
<h2>定焦视界</h2>
<ul>
<li>成员:56</li>
<li>作品:456</li>
</ul>
</li>
<li class="one">
<a href="#"><img src="pic_04.jpg"></a>
<h2>中画幅乐园</h2>
<ul>
<li>成员:130</li>
<li>作品:239</li>
</ul>
</li>
<li class="one">
<a href="#"><img src="pic_05.jpg"></a>
<h2>《卡啪》先锋...</h2>
<ul>
<li>成员:78</li>
<li>作品:125</li>
</ul>
</li>
<li class="one">
<a href="#"><img src="pic_06.jpg"></a>
<h2>植物的无声世界</h2>
<ul>
<li>成员:235</li>
<li>作品:1258</li>
</ul>
</li>
</ul>
</div>
</body>
</html>
body,div,h3,ul,li{
margin: 0px;
padding: 0px;
}
div{
width:660px;
border: 1px solid #d8d8d8;
box-sizing: border-box;
overflow:hidden;
margin: 50px auto;
}
h1{
font-size: 14px;
color: #999999;
line-height: 35px;
padding-left: 10px;
}
h2{
font-size: 14px;
color: #2e75bc;
line-height: 30px;
margin-top: 3px;
}
li{
list-style:none;
color: #999999;
line-height: 20px;
}
.one{
float: left;
width:216px;
height:99px;
overflow: hidden;
}
.one img{
margin:10px 15px 0 10px;
float:left;
padding:3px;
border:1px solid #ccc;
border-radius: 6px;
}
4.制作名人名言页面(完整的页面效果图参见提供的作业素材)。要求如下。
使用headder、article、section、nav、footer等结构元素布局。
使用float属性创建横向多列布局。
使用无序列表制作导航菜单,并使用盒子属性美化菜单,当鼠标移至导航菜单上时显示下划线。
使用标题标签排版网页中的各级标题。
页面的完整效果及页面中字体样式。颜色等参见提供的作业素材。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>名人名言</title>
<link rel="stylesheet" href="DJ7word4.css" type="text/css">
</head>
<body>
<div class="whole">
<!--头部-->
<div class="one">
<h1>名人名言</h1>
<h2>分享名人名言,开始一段触动心灵的智慧之旅跳到内容</h2>
<ul>
<li><a href="#">登录</a></li>
<li><a href="#">关于</a></li>
<li><a href="#">名人名言</a></li>
<li><a href="#">英文名言(English)</a></li>
<li><a href="#">心理杂志</a></li>
<li><a href="#">心理书籍</a></li>
<li><a href="#">专题活动</a></li>
<li><a href="#">发表</a></li>
</ul>
<p><hr/></p>
</div>
<!--主体左-->
<div class="left">
<div class="two">
<h1>心理学经典名言的智慧</h1>
<h2>洞察人性的美与丑,认识自我的强与弱。一句好的格言能够穿越时间,永不失色、历久弥香,它总是能给人们带来心灵的滋养。</h2>
</div>
<div class="three">
<h1>创造力(creativity)有两个词根:Crera拉丁语的意思是“去创造”。Krainir希腊语的意思是“去实现”。所以,创造力不仅仅是一种想象力、一种天赋,创造力更是一种将自己的想法付诸实现的能力。 </h1>
<h2>创造力(creativity)有两个词根:Crera拉丁语的意思是“去创造”。Krainir希腊语的意思是“去实现”。所以,创造力不仅仅是一种想象力、一种天赋,创造力更是一种将自己的想法付诸实现的能力。 </h2>
<h2>发表在 未分类 | 标签: 《换个脑袋去思考》, 创造力 | 留下评论</h2>
</div>
<div class="four">
<h1>作者简介</h1>
</div>
<div class="three">
<h1>如果你还没有注意到你有能力让对方作出你所希望得到的反应,那么你就还没有很好地掌握人生的真谛。这其实简单到不可思议。如果你希望他人对你感兴趣,那么你就要先对他人产生兴趣;如果你想让他人紧张,那么你自己首先要紧张起来。就是这么简单。人们会按照你对待他们的方式对待你。这其中没有什么秘诀。看看周围的人,你可以在与下一个人交流时证实这一点。</h1>
<h2>如果你还没有注意到你有能力让对方作出你所希望得到的反应,那么你就还没有很好地掌握人生的真谛。这其实简单到不可思议。如果你希望他人对你感兴趣,那么你就要先对他人产生兴趣;如果你想让他人紧张,那么你自己首先要紧张起来。就是这么简单。人们会按照你对待他们的方式对待你。这其中没有什么秘诀。看看周围的人,你可以在与下一个人交流时证实这一点。</h2>
<h2>发表在 未分类 | 标签: 《怎样出售设计创意》, 温斯顿·丘吉尔 | 留下评论</h2>
</div>
<div class="five">
<h1>赞助广告</h1>
<img src="ad_2.jpg">
</div>
</div>
<!--主体右-->
<div class="six">
<ul>
<li>赞助广告</li>
<li><img src="ad.jpg"></li>
<li>搜索</li>
<li><input type="search" placeholder="点击搜索" "></li>
<li>标签</li>
<li>60年语录 《犯罪心理》 世间百态 二十四史传统名人 体育人物 卡斯特罗 卡斯特罗名言 卡斯特罗语录 历史 友谊爱情 古代格言 名人名言 名人随语 教子立人 新闻事件 李白 爱情语录 韩寒语录</li>
</ul>
</div>
</div>
</body>
</html>
body,div,ul,li{
margin: 0px;
padding: 0px;
}
/*设置整体*/
.whole{
height: 1000px;
width: 1000px;
border: 1px #999999 solid;
margin: auto;
padding: 10px 50px;
clear: right;
}
.left{
width: 550px;
float: left;
}
/*设置头部*/
.one{
margin-left: 30px;
width: 100%;
margin-bottom: 50px;
height: 100px;
}
.one h1{
font-size: 30px;
color: #000;
}
.one h2{
color: #999999;
font-size: 14px;
}
.one li{
list-style:none;
}
.one a{
font-size: 14px;
padding: 8px;
float: left;
color: #999999;
text-decoration: none;
border: 1px #999999 solid;
}
.one a:hover{
color: #999999;
text-decoration: underline;
}
.one p{
padding-top: 15px;
float: bottom;
}
.two{
border: 1px #999999 solid;
float: left;
width: 520px;
}
.two h1{
font-size: 20px;
color: #000;
}
.two h2{
font-size: 14px;
color: #999999;
}
.three{
margin-top: 10px;
float: left;
width: 520px;
}
.three h1{
font-size: 14px;
color: #000;
}
.three h2{
font-size: 14px;
color: #999999;
}
.four{
border: 1px #999999 solid;
width: 520px;
float: left;
}
.four h1{
font-size: 20px;
color: black;
}
.five{
width: 520px;
float: left;
border: 1px #999999 solid;
}
.five h1{
font-size: 14px;
color: black;
}
.six{
float: right;
border: 1px #999999 solid;
width: 400px;
padding: 5px 10px;
}
.six li{
list-style:none;
color: #999999;
font-size: 14px;
font-style: oblique;
padding-top: 10px;
}
5.制作彩妆热卖产品列表页面(页面效果、背景图片、分割线颜色样式、背景颜色、字体颜色等页面样式参见提供的上机练习素材),要求如下。
页面背景颜色为浅黄色,彩妆热卖产品列表背景颜色为白色。
标题放在段落标签中,标题背景颜色为桃红色,字体颜色为白色。
使用无序列表<ul制作彩妆热卖产品列表,两个产品列表之间使用虚线隔开。
超链接字体颜色为灰色,无下划线,数字颜色为白色,数字背景为灰色背景。
当鼠标移至超链接上时,超链接字体颜色为桃红色,无下划线,数字颜色为白色,数字背景为桃红色圆圈,并且显示产品对应的图片、价格和当前已购买人数。
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>彩妆热卖产品列表</title>
<link href="../Semester1book3DJ7/DJ7word5.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="whole">
<p class="p">大家都喜欢的彩妆</p>
<ul>
<li><a href="#"><span>1</span>Za姬芮新能真皙美白隔离霜 35g
<div><img src="icon-1.jpg" alt="Za姬芮新能真皙美白隔离霜"/>
<p>¥62.00 最近69122人购买</p>
</div>
</a></li>
<li><a href="#"><span>2</span>美宝莲精纯矿物奇妙新颜乳霜BB霜 30ml
<div><img src="icon-1.jpg" alt="美宝莲精纯矿物奇妙新颜乳霜BB霜"/>
<p>¥89.00 最近13610人购买</p>
</div>
</a></li>
<li><a href="#"><span>3</span>菲奥娜水漾CC霜 40g
<div><img src="icon-1.jpg" alt="菲奥娜水漾CC霜"/>
<p>¥59.90 最近13403人购买</p>
</div>
</a></li>
<li><a href="#"><span>4</span>DHC 蝶翠诗橄榄卸妆油 200ml
<div><img src="icon-1.jpg" alt="DHC 蝶翠诗橄榄卸妆油"/>
<p>¥169.00 最近16757人购买</p>
</div>
</a></li>
</ul>
</div>
</body>
</html>
body,div,p,ul,li{
padding: 0px;
margin: 0px;
}
ul,li{
list-style-type: none;
}
body{
background-color: #eee7e1;
font-size: 12px;
}
img{
border: 0px;
}
.whole{
width: 255px;
background-color: #fff;
}
.p{
background-color: #e9185a;
font-size: 14px;
color: #fff;
height: 35px;
line-height: 35px;
padding-left: 10px;
font-weight: bold;
}
.whole li{
border-bottom: 1px #999 dashed;
line-height: 30px;
padding-left: 2px;
}
.whole li div{
display: none;
text-align: center;
}
.whole li a{
text-decoration: none;
color: #999;
}
.whole li a:hover{
color: #e9185a;
}
.whole li a:hover div{
display: block;
}
.whole li a span{
color:#FFF;
font-weight:bold;
margin-right: 10px;
display: inline-block;
width: 20px;
height: 20px;
border-radius: 50%;
background: #373b3c;
line-height: 20px;
text-align: center;
}
.whole li a:hover span{
color: #fff;
background-color: #e9185a;
}
更多推荐
寒假作业
发布评论