初学自建的超简单网站

实现功能

  • 文字显示
  • 修改文字格式
  • 添加索引
  • 动态网页交互
  • 计时器

 

网页代码

<html>
<head>
<meta charset="utf-8">
<title>动态网页</title>
<script>
function openNav() {
    document.getElementById("mySidenav").style.width = "250px";
    document.getElementById("main").style.marginLeft = "250px";
}

function closeNav() {
    document.getElementById("mySidenav").style.width = "0";
    document.getElementById("main").style.marginLeft= "0";
}

// Set the date we're counting down to
var countDownDate = new Date("Jul 2, 2018 10:30:00").getTime();

// Update the count down every 1 second
var x = setInterval(function() {

    // Get todays date and time
    var now = new Date().getTime();
    
    // Find the distance between now an the count down date
    var distance = countDownDate - now;
    
    // Time calculations for days, hours, minutes and seconds
    var days = Math.floor(distance / (1000 * 60 * 60 * 24));
    var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
    var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
    var seconds = Math.floor((distance % (1000 * 60)) / 1000);
    
    // Output the result in an element with id="demo"
    document.getElementById("demo").innerHTML = days + "天" + hours + "小时"
    + minutes + "分钟" + seconds + "秒";
    
    // If the count down is over, write some text 
    if (distance < 0) {
        clearInterval(x);
        document.getElementById("demo").innerHTML = "EXPIRED";
    }
}, 1000);
</script>
<style>
body {
    font-family: "Lato", sans-serif;
}

.sidenav {
    height: 100%;
    width: 0;
    position: fixed;//绝对定位元素,相对浏览器窗口定位
    z-index: 1;//堆叠顺序
    top: 0;
    left: 0;
    background-color: #111;
    overflow-x: hidden;
    transition: 0.5s;//改变时间
    padding-top: 60px;
}

.sidenav a {
    padding: 8px 8px 8px 32px;
    text-decoration: none;
    font-size: 25px;
    color: #818181;
    display: block;
    transition: 0.3s;
}

.sidenav a:hover, .offcanvas a:focus{
    color: #f1f1f1;
}

.sidenav .closebtn {
    position: absolute;
    top: 0;
    right: 25px;
    font-size: 36px;
    margin-left: 50px;
}

#main {
    transition: margin-left .5s;
    padding: 16px;
}

@media screen and (max-height: 450px) {
  .sidenav {padding-top: 15px;}
  .sidenav a {font-size: 18px;}
}

.time {
  text-align: center;
  font-size: 60px;
  color:#81818181;
  transition:0.3s;
}
.time:hover{
color:#ff0000ff;
}
.title{
text-align:center;
}
</style>
</head>
<body>
<div id="mySidenav" class="sidenav">
  <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
  <a href=http://www.baidu.com>百度</a>
  <a href=https://www.taobao.com>淘宝</a>
  <a href=http://4m3.tongji.edu.cn>4m3</a>
  <a href=http://xuanke.tongji.edu.cn>选课网</a>
</div>
<div id="main">
  <h3 class="title">“一个很low的网站”
</br>
你可以从中:
</br>
1.进入常用网址
</br>
2.提醒考试时间
</br>
3.sorry 没了
</h3>
  <h1>同济大学学生专用</h1>
  <h2>!点击下方按钮快速进入网站链接!</h2>
  <span style="font-size:30px;cursor:pointer" onclick="openNav()">&#9776; 打开</span>
<br>
<br>
<div class="time">
  <p>距离期末考试第一科还有:</p>
  <p id="demo"></p>
</div>
</div>
</body>
</html>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值