zoukankan      html  css  js  c++  java
  • 仿写微博发布

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title></title>
    <style>
    *{margin:0;padding: 0;}
    .warp{
    600px;
    margin:50px auto 0;
    background-color: #ccc;
    }
    #box{
    600px;
    height: 340px;
    /*background-color: #ccc;*/
    position: relative;
    /*overflow: hidden;*/
    /*margin:50px auto 0;*/
    font-family: '微软雅黑';
    }
    #box .span1{
    position: absolute;
    font-size: 16px;
    line-height: 16px;
    top: 10px;
    left: 5px;
    }
    #box .span2{
    position: absolute;
    font-size: 16px;
    line-height: 16px;
    top: 50px;
    left: 5px;
    }
    #title{
    position: absolute;
    460px;
    height: 20px;
    line-height: 20px;
    font-size: 16px;
    text-indent: 5px;
    left: 70px;
    top: 6px;
    }
    #text{
    position: absolute;
    460px;
    height: 250px;
    resize: none;
    top: 50px;
    left: 70px;
    text-indent: 5px;
    font-size: 16px;
    }
    #box #prompt{
    position: absolute;
    top: 312px;
    left: 340px;
    }
    #prompt1{
    position: absolute;
    top: 312px;
    left: 340px;
    display: none;
    }
    #send{
    position: absolute;
    height: 25px;
    60px;
    line-height: 20px;
    font-size: 16px;
    top: 310px;
    right: 68px;
    }
    #news{
    list-style: none;
    490px;
    margin:10px auto 0px;
    padding-bottom: 5px;
    }
    #news li{
    490px;
    font-size: 14px;
    overflow: hidden;
    background-color: #fff;
    margin-bottom: 5px;
    position: relative;
    }
    #news li h1{
    font-size: 16px;
    line-height: 20px;
    }
    #news li p{
    text-indent: 5px;
    clear: left;
    }
    #news li span{
    position: absolute;
    top: 0px;
    right: 0px;
    cursor: pointer;
    }
    #news span:hover{
    color: red;
    }
    </style>
    </head>
    <body>
    <div class="warp">
    <div id="box">
    <span class='span1'>标题:</span>
    <input id="title" type="text">
    <span class="span2">内容:</span>
    <textarea id="text"></textarea>
    <button id="send">发送</button>
    </div>
    <ul id="news">
    <li><h1></h1><span></span>
    <p></p>
    </li>
    </ul>
    </div>
    <script>
    var title=document.getElementById('title');
    var text=document.getElementById('text');
    var send=document.getElementById('send');
    var ul=document.getElementById('news');
    var lis=ul.getElementsByTagName('li');
    var prompt=document.getElementById('prompt');
    var prompt1=document.getElementById('prompt1');
    var textnum=document.getElementById('textnum');
    var textnum1=document.getElementById('textnum1');
    var timer1=null,timer2=null;
    send.onclick=function(){
    if (text.value==''||title.value=='') {
    alert('标题或内容不能为空');return false;
    }
    lis[0].innerHTML='<h1>'+title.value+'</h1><span>删除</span><p>'+text.value+'</p>';
    lis[0].children[1].setAttribute('id','close');
    var newLi=document.createElement('li');
    ul.insertBefore(newLi,lis[0]);
    maxheight=lis[1].clientHeight;
    lis[1].style.height=0+'px';
    var x=0;
    var minstep=0;
    var maxstep=20;
    var change=maxheight/maxstep;
    clearInterval(timer1);
    timer1=setInterval(function(){
    minstep++;
    if (minstep>=maxstep) {
    clearInterval(timer1);
    }
    x+=change;
    lis[1].style.height=x+'px';
    },10)
    title.value='';
    text.value='';
    var close=document.getElementById('close');
    for (var i = 0; i < lis.length; i++) {
    close.onclick=function(){
    var isme=this.parentNode;
    var x=this.parentNode.clientHeight;
    var minstep=0;
    var maxstep=20;
    var change=x/maxstep;
    clearInterval(timer1);
    timer1=setInterval(function(){
    minstep++;
    if (minstep>=maxstep) {
    clearInterval(timer1);
    ul.removeChild(isme);
    }
    x-=change;
    isme.style.height=x+'px';
    },10)

    }
    }
    }
    text.onfocus=function(){

    timer2=setInterval(function(){
    if(text.value.length<190){
    var num=200-text.value.length;
    textnum.style.color='black';

    textnum.innerHTML=num;

    }
    if (text.value.length>=190&&text.value.length<=200){
    var num=200-text.value.length;

    textnum.style.color='red';
    textnum.innerHTML=num;
    }
    if (text.value.length>200){
    var num=text.value.length-200;

    prompt.style.display='none';
    prompt1.style.display='block';
    textnum1.style.color='red';
    textnum1.innerHTML=num;

    }

    },50)

    }
    text.onblur=function(){
    clearInterval(timer2);
    }
    </script>
    </body>
    </html>

  • 相关阅读:
    C++数组释放问题
    C# 线程与进程
    Inspector面板Debug模式
    Unity实现汉诺塔游戏
    Unity中的销毁方法
    如何修改Unity中脚本模板
    序列帧动画
    Unity中的射线和射线图层过滤使用方法
    简单第一人称射击游戏
    C# 集合和泛型
  • 原文地址:https://www.cnblogs.com/hjl553155280/p/6007488.html
Copyright © 2011-2022 走看看