实验一 基于CSS+HTML+JS开发简单个人网站

目录

一、实验目的

二、实验要求

1、个人网站分为四个部分:注册页面,登录界面,主界面,以及分界面。

2、个人简历界面:主要是css3实体样式;同样采用了四个盒子分别介绍四个内容。如图1-2,具体内容自定。

3、我的理想界面:列举我的理想,可以使用无序列表或者表格排列。

4、我的生活界面:主要内容采用展示照片墙或者视频来体现。

5、学习内容界面:采用list-style:none的有序列表。

6、具体操作步骤:

三、实验代码

四、实验结果

五、实验体会


一、实验目的

目的:熟悉在静态网页制作基本流程,熟练应用CSS+HTML+JS。

任务:使用CSS+HTML+JS,开发简易个人网站。

二、实验要求

1、个人网站分为四个部分:注册页面,登录界面,主界面,以及分界面。

1)注册页面需要使用到用户名及密码等信息,用到的标签有表格、文本框、单选按钮、复选按钮、下拉列表框等基本的标签;登录界面需要输入用户名和密码;

2)登陆成功后,可利用javascript判断输入用户名和密码的正确性,输入正确,则利用form标签中action转向主界面,如果输入不正确,可用警告框提醒用户:“输入不正确,再次输入”;

3)主界面类似图1-1,采用四个盒子分别代表个人简历,我的理想,我的生活,学习内容。每个盒子都采用float浮动。

图1-1 主界面

2、个人简历界面:主要是css3实体样式;同样采用了四个盒子分别介绍四个内容。如图1-2,具体内容自定。

图1-2个人简历界面

3、我的理想界面:列举我的理想,可以使用无序列表或者表格排列。

4、我的生活界面:主要内容采用展示照片墙或者视频来体现。

5、学习内容界面:采用list-style:none的有序列表。

6、具体操作步骤:

1)准备网站需要的素材:图片和视频;

2)可利用记事本或者Jbuilder编写各个页面。

3)注意各页面之间的转向或者链接关系

4)打开浏览器,观察各个页面运行结果。

2、实验安排方式:上机编码。

3、实验结果展示,包括代码(可分栏展示)和效果图。

三、实验代码

1、登录页面:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>登录</title>
  <style>
    .bjimg {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -10;
      object-fit: cover;
      }
 
    #login_box {
      width: 30%;
      height: 300px;
      background-color: #00000060;
      margin: auto;
      margin-top: 10%;
      text-align: center;
      border-radius: 10px;
      padding: 50px 50px;
    }
 
     body {
                 background:url(".jpg")
	no-repeat;
	background-size: 1300px 750px;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -10;
      object-fit: cover;
}
    h2 {
      color: #ffffff90;
      margin-top: 5%;
    }
 
    #input-box {
      margin-top: 5%;
    }
 
    span {
      color: #fff;
    }
 
    input {
      border: 0;
      width: 60%;
      font-size: 15px;
      color: #fff;
      background: transparent;
      border-bottom: 2px solid #fff;
      padding: 5px 10px;
      outline: none;
      margin-top: 10px;
    }
 
    button {
      margin-top: 30px;
      width: 60%;
      height: 30px;
      border-radius: 10px;
      border: 0;
      color: #fff;
      text-align: center;
      line-height: 30px;
      font-size: 15px;
      background-image: linear-gradient(to right, #101008, #3f3a3e);
    }
   
    #sign_up {
      margin-top: 45%;
      margin-left: 60%;
    }
 
    a {
      color: #b94648;
    }
  </style>

</head>
<body>
  <div id="login_box">
    <h2>登录</h2>
    <div class="input_box">
      <input type="text" id="username"placeholder="请输入用户名">
    </div>
    <div class="input_box">
      <input type="text"id="password" placeholder="请输入密码">
    </div>
    <div>
      <button type="button" id="Button"value="立即登录" onclick="login()">立即登录</button>
      <br><br>
      <h>没有账号?<a href="注册.html">请注册</a></h>
 
  </div>
 
 
  <from action>
<script type="text/javascript">
    
    //判断登录是否成功
    function login(){
      //获取注册时存储在localStorage中的值
             var username1=localStorage.getItem("username1").value;
             var password1=localStorage.getItem("password1").value;
             var username=document.getElementById("username").value;
             var password=document.getElementById("password").value;
            
        //判断输入的信息和注册的信息是否一致
        if(username!='' && password!=''){
          if (username==''&& password==''){
               window.location.href="我的理想.html";
            }
            if (username=="" && password=="1234"){
               window.location.href="我的主页.html";
            }
            else{
                alert("用户名或密码错误,请重新输入!");
            }
           }
        else{
            alert("用户名或密码不能为空!");
        }
    }
</script>
</div>
</body>
</html>

2、注册页面

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>注册</title>
  <style>
    .bjimg {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -10;
      object-fit: cover;
      }
 
    #login_box {
      width: 30%;
      height: 300px;
      background-color: #00000080;
      margin: auto;
      margin-top: 10%;
      text-align: center;
      border-radius: 10px;
      padding: 50px 50px;
    }
    tr{ 
         border: 1px solid beige;
      }
     td{ 
        border: 1px solid aliceblue;
      }
     body{
                 background:url("moon.jpg")
	no-repeat;
	background-size: 1300px 750px;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -10;
      object-fit: cover;
}
    h2 {
      color: #ffff;
      margin-top: 5%;
    }
 
    #input-box {
      margin-top: 5%;
    }
 
    span {
      border: 0;
      width: 60%;
      font-size: 15px;
      color:rgb(203, 197, 197);
      background: transparent;
      padding: 10px 3px;
      outline: none;  
      margin-top: 10px;
    }
 
    input {
      border: 0;
      width: 60%;
      font-size: 15px;
      color: #fff;
      background: transparent;
      border-bottom: 2px solid #fff;
      padding: 5px 10px;
      outline: none;
      margin-top: 10px;
    }
 
    button {
      margin-top: 10px;
      width: 60%;
      height: 30px;
      border-radius: 10px;
      border: 0;
      color: #fff;
      text-align: center;
      line-height: 30px;
      font-size: 15px;
      background-image: linear-gradient(to right, #4b1919, #3f3a3e);
    }
   
    #sign_up {
      margin-top: 45%;
      margin-left: 60%;
    }
    
    a {
      color: #fff;
    }
  </style>
</head>
<video src=".mp4" class="bjimg" autoplay loop muted></video>
<body>
  <div id="login_box">
   
  <h2>注册</h2>
    <div class="input_box"> 
      <input type="text" id="username1" placeholder="请输入用户名">
     <br>
    <input type="password"id="password1" placeholder="请输入密码"> <br><br>
    </div>
        <span>年级班级:</span>
        <span colspan="7">
            <select>
                <option>19级</option>
                <option>20级</option>
                <option>21级</option>
            </select>
            <select>
                <option>一班</option>
                <option>二班</option>
                <option>三班</option>
                <option>四班</option>
                <option>五班</option>
                <option>六班</option>
            </select>
      <br>
      <span> 性别:&nbsp&nbsp</span>
      <span>男</span>
      <span><input style="width: auto;" type="radio" name="sex" value="男" id="sex_man"></span>
      <span>女</span>
      <span><input style="width: auto;" type="radio" name="sex" value="女" id="sex_woman"></span><br>
    <button type="button" id="Button"value="注册" onclick="register()">注册</button>
    <br><br>
    <span>
        已有账号?
<a href="登录.html">请登录</a>
    </span>  
</div>
<form  action>
    <script type="text/javascript">
 
        function register(){  
                var username1=document.getElementById("username1").value;
                var password1=document.getElementById("password1").value;
                //localStorage存储注册信息
                localStorage.setItem("username1",username1);
                localStorage.setItem("password1",password1);
        if(username1=='' || password1==''){
             alert("用户名或密码不能为空!"); 
            }
            else{
                 window.location.href="登录.html";
            }
        }      
    </script>
    </div>
</html>

3、我的主页页面

<html>
	<head>
		<title>主页</title>
		<meta charset="UTF-8"/>
		<style type="text/css">/*设置图片样式*/
        #div_box {
      width: 1100px;
      height: 500px;
	  font-family: "宋体";
      background-color: #ffffff90;
      margin: auto;
      margin-top: 3%;
      text-align: center;
      border-radius: 10px;
      padding: 20px 50px;
    }
       
       body{
	background:url(".jpg")
	no-repeat;
	background-size: 1300px 650px;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -10;
      object-fit: cover;
      }
		  h{
            text-align: center;
              margin-top:0px;
              font-size: 20px;
			  color:rgb(9, 8, 8);
              font-family: "宋体"; 
          }
		  h1{
            text-align: center;
              margin-top:30px;
              font-size: 30px;
			  color:rgb(13, 11, 11);
              font-family: "宋体"; 
          }
		/*设置div的基础样式*/
			div{ 
            width: 250px;
            height: 250px;
            border-radius: 50%;
        }
 
		/*设置header和footer的样式*/
			#header,#footer{
				width: 1190px;
				margin: auto;
				margin-top: 100px;
			}
		/*设置子div的样式*/
			#div01{
				border: solid 0px #ffffff90 ;
				float: left; 
               
				margin-right: 20px;
 
            }
 
 
			#div02{
				border: solid 0px #ffffff90;
				float: left;
                
				margin-right: 20px;
 
		}
			#div03{
				border: solid 0px #ffffff90 ;
				float: left; 
				margin-right: 20px;
			}
			#div04{
				border: solid 0px  #ffffff90;
				float: left;
 
			} 
            #log
            {
                color:rgb(100, 50, 355);
				font-size: 55px;
            } 
			img {
            width: 200px;
            height: 200px;
            border-radius: 50%;
        }
		
	</style>
	<style>
	a:visited {color:rgb(2, 1, 1);}
	a:hover {color:rgb(24, 21, 198);}</style>
	</head>   
	<body>
        <div id="div_box">
        <h1>欢迎来到我的主页</h1>
		<div id="header">
				<div id="div01"> 
                <img src=".jpg" alt="" class="img"><br>
			<h><a href="个人简介.html">个人简介</a></h>	
				</div>
				<div id="div02">
                    <img src=".jpg" alt="" class="img"><br>
					<h><a href=".html">我的理想</a></h>
				</div>
	     	
			<div id="div03">
                <img src=".jpg" alt=""class="img"><br>
				<h><a href="我的生活.html">我的生活</a></h>
			</div>
			<div id="div04">
                <img src=".jpg" alt=""class="img"><br>
				<h><a href="学习内容.html">学习内容</a></h>
               
			</div>
		</div>
           
        </p>  
	</body>
</html>

4、个人简介

<html>
	<head>
		<title>个人简介</title>
		<meta charset="UTF-8"/>
		<style type="text/css">/*设置图片样式*/
        #div_box {
			width: 1050px;
		  height: 500px;
		  margin: 10px 50px;
		  background-color: #ffffff90;
		  border: 1px solid #FFFFFF90;
		  
      color: rgb(7, 7, 7);
	  font-family: "宋体";
      text-align: center;
      border-radius: 10px;
      padding: 20px 50px;
    }
	
	h2{text-align: right; 
            font-family: "宋体";
             color:#100f0f;
            font-size: 18px;
			margin-right:15px;
        }
       body {
            background:url("wonderland.jpg")
            no-repeat;
            background-size:120% 100%;
          }
        
			
		/*设置div的基础样式*/
			div{width: 240px;
			       height: 360px;
				
			}
		/*设置header和footer的样式*/
			#header,#footer{width: 1050px;
				margin: auto;
				margin-top: 30px;
				
			}
		/*设置子div的样式*/
			#div01{
				border: solid #ffffff90;
				float: left; 
                background-color: #ffffff90 ;
				margin-right: 20px;
            }
			#div02{
				border: solid  #ffffff90 ;
				float: left;
                background-color:  #ffffff90;
				margin-right: 20px;
 
		}
			#div03{
				border: solid   #ffffff90;
				float: left; 
                background-color:  #ffffff90;
				margin-right: 20px;
			}
			#div04{
				border: solid  #ffffff90 ;
				float: left;
                background-color:  #ffffff90;
 
			} 
            
		div p{
			text-align: right;
			display: block;
			font-size: 25px;
			text-align: center;
			color: rgb(6, 6, 6);
			font-weight: bold;
 
		}
		div span{
			display: block;
			font-size: 18px;
			text-align: left;
			color: rgb(5, 5, 5);
			font-weight: bold;
		}
 
</style>
</head>
<h2><body>点此返回我的主界面?<a href="我的主页.html">返回</a></h2>
<style>
    a:visited {color:#db1b1e;}
	a:hover {color:#480738;}
	</style>
	<div id="div_box">
	<h1>个人简介<h1/>
	<div id="header">
			<div id="div01"> 
			
			<ul>个人信息<br>
                                                                   <span><br></br><li>&nbsp姓名:</li>
				<br></br><li>&nbsp性别: </li>
				<br></br><li>&nbsp家乡:</li>
			                 <br></br><li>&nbsp民族:</li>
			</span>
                                                   </ul>
			</div>
			<div id="div02">
			<ul>联系方式<br>
				<span><br></br><li>&nbsp电话号码:</li>
				<br></br><li>&nbspQQ:</li>
				<br></br><li>&nbsp微信:</li>
				<br></br><li>&nbsp地址:***</li>
			</span>
                                                   </ul>
			</div>
		 
		<div id="div03">
			<ul>兴趣爱好<br>
                                                                   <span><br></br><li>&nbsp吉他</li>
				<br></br><li>&nbsp旅行</li>
				<br></br><li>&nbsp拍照</li>
				<br></br><li>&nbsp吃美食</li>
			</span>
                                                  </ul>
 
		</div>
		<div id="div04">	
			<ul>特长技能<br>
                                                                   <span><br></br><li>&nbsp吉他</li>
				<br></br><li>&nbsp腿毛特长</li>
				<br></br><li>&nbsp头发特短</li>
			</span>
                                                  </ul>
		</div>
	</div>
	</p>  
</body>
</html>

5、我的理想页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的理想</title>
    <style>
        /* 重置默认样式 */
 
        #div_box {
			width: 800px;
		  height: 400px;
		  
	  background-color: #ffffff90;
	  border: 1px solid #FFFFFF90;  
      color: rgb(7, 7, 7);
	  font-family: "宋体";
      text-align: center;
      padding: 50px 50px;
      margin: 30px 200px;/*上,左距离*/
      border-radius: 10px;/*改变形状*/
    }
 
 
        h1{
            text-align: center;
              margin-top:20px;
              font-size: 24px;
              font-family: "宋体"; 
          }
        
         h2{text-align: right; 
            font-family: "宋体";
            margin-right:15px;
            margin-top:0; color:#3e3b3b;
            font-size: 15px;
           }
        body{
	background:url("wonderland.jpg")
	no-repeat;
	background-size: 1300px 650px;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -10;
      object-fit: cover;
      }
        .list{
           width: 1100px;
            height:450px;
           display: flex;
           margin:20px auto;
           flex-wrap: wrap;
            }
        .list li{
            width:400px;
            height:350px;
            border-radius: 10px;/*矩形角圆弧度*/
            margin-top:5px;
            list-style: none;
                }
        .list img{
            margin-left: 30px;
            margin-top:10px;
                 }
        .title{
            font-size:20px;
            text-align: left;
            color:#333333;
             text-decoration:
             underline rgb(4, 0, 0); /*色下划线*/
              }
        .smalltitle{
			display: block;
			font-size: 17px;
            color: #060101 ;
			text-align: left;
                        
        }
    </style>
</head>
<body>
     <h2>点此返回我的主界面?<a href="我的主页.html">返回</a></h2>
    <div id="div_box">
    <h1>我的理想</h1>
    <ul class="list">
        <li>
            <img src="合照1.jpg" alt="图片加载失败"width="320" height="250">
        </li>
        <li>
            <p class="title"><b>理想生活</b></p>
            <p class="smalltitle">***</p>
            <p class="smalltitle">***</p>
            <p class="title"><b>短期目标</b></p>
            <p class="smalltitle">***</p>
            <p class="title"><b>现在的愿望</b></p>
            <p class="smalltitle">***</p>
        </li>
    </ul>
</body>
</html>

6、我的生活页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的理想</title>
    <style>
        /* 重置默认样式 */
 
        #div_box {
			width: 800px;
		  height: 400px;
		  
	  background-color: #ffffff90;
	  border: 1px solid #FFFFFF90;  
      color: rgb(7, 7, 7);
	  font-family: "宋体";
      text-align: center;
      padding: 50px 50px;
      margin: 30px 200px;/*上,左距离*/
      border-radius: 10px;/*改变形状*/
    }
 
 
        h1{
            text-align: center;
              margin-top:20px;
              font-size: 24px;
              font-family: "宋体"; 
          }
        
         h2{text-align: right; 
            font-family: "宋体";
            margin-right:15px;
            margin-top:0; color:#3e3b3b;
            font-size: 15px;
           }
        body{
	background:url("wonderland.jpg")
	no-repeat;
	background-size: 1300px 650px;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -10;
      object-fit: cover;
      }
        .list{
           width: 1100px;
            height:450px;
           display: flex;
           margin:20px auto;
           flex-wrap: wrap;
            }
        .list li{
            width:400px;
            height:350px;
            border-radius: 10px;/*矩形角圆弧度*/
            margin-top:5px;
            list-style: none;
                }
        .list img{
            margin-left: 30px;
            margin-top:10px;
                 }
        .title{
            font-size:20px;
            text-align: left;
            color:#333333;
             text-decoration:
             underline rgb(4, 0, 0); /*色下划线*/
              }
        .smalltitle{
			display: block;
			font-size: 17px;
            color: #060101 ;
			text-align: left;
                        
        }
    </style>
</head>
<body>
     <h2>点此返回我的主界面?<a href="我的主页.html">返回</a></h2>
    <div id="div_box">
    <h1>我的理想</h1>
    <ul class="list">
        <li>
            <img src="合照1.jpg" alt="图片加载失败"width="320" height="250">
        </li>
        <li>
            <p class="title"><b>理想生活</b></p>
            <p class="smalltitle">***</p>
            <p class="smalltitle">***</p>
            <p class="title"><b>短期目标</b></p>
            <p class="smalltitle">***</p>
            <p class="title"><b>现在的愿望</b></p>
            <p class="smalltitle">***</p>
        </li>
    </ul>
</body>
</html>

7、学习内容页面

<!DOCTYPE html>
<html>
    <head>
    <title>学习内容</title>
<meta charset="UTF-8"/>
<style type="text/css">  
body{
	background:url("wonderland2.jpg")
	no-repeat;
	background-size: 1300px 650px;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -10;
      object-fit: cover;
      }
    div.transbox
		{
		  width: 800px;
		  height: 500px;
		  margin: 40px 230px;
		  background-color: #ffffff90;
		  border: 1px solid #FFFFFF90;
		  opacity:0.8;
		} 
       
		h1{text-align: center; 
            font-family: "宋体";
             color:#060000;
			  margin-top:20px;
            font-size: 24px;
			
        }
		h2{text-align: left; 
            font-family: "宋体";
             color:#100f0f;
            font-size: 20px;
			margin-left:3cm;
        }
		h3{text-align: right; 
            font-family: "宋体";
             color:#100f0f;
            font-size: 18px;
			 margin-top:2px;
			margin-right:15px;
        }
		p{text-align: right; 
            font-family: "宋体";
             color:#020001;
            font-size: 18px;
			margin-right:15px;
        }	
</style>
<body>
<head>
	<h3>点此返回我的主界面?<a href="我的主页.html">返回</a></h3>
    <div class="transbox">
	<h1>#每日学习内容#</h1>
		<h2>
			<li>巩固当日学习的专业知识</li>
			<li>保持锻炼</li>
			<li>早睡</li>
			<li>学习日语</li>
            <li>学习英语</li>
    </div> 
</head>
</body>
</html>

四、实验结果

1、注册

2、登录

3、我的主页(略)

4、个人简介

5、我的生活(略)

6、我的理想(略)

7、学习内容

五、实验体会

       学习Vue+Sprig前后端开发,html、css和javascript是基础,在这次实验中,我学习到了页面的跳转方法和超链接的使用,以及各种标签的使用,如何让页面看起来更加的美观,使用什么样的标签比较方便,这些基础知识对后续的开发有着举足轻重的作用。

        另外,图片和HTML文件要在同一个目录下,不然打开HTML看不到图片。

  • 23
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值