HTML仿命令行界面具體實(shí)現(xiàn)

字號:


    本文為大家介紹下HTML仿命令行界面的具體實(shí)現(xiàn),感興趣的朋友不要錯(cuò)過
    HTML部分
    代碼如下:
    <!DOCTYPE html>
    <head>
    <meta charset="utf-8" />
    <title>WeChat Manager</title>
    <link href="css/index.css" rel="stylesheet" type="text/css">
    <script src="http://code.jquery.com/jquery-1.10.2.min.js">
    </script>
    <script>
    $(document).ready(function(){
    $(document).keyup(function(event){
    if(event.keyCode ==13){
    $.ajax({
    type: "POST",
    url: "ok.php",
    data: "code="+$("#in").val(),
    success: function(msg){
    $("ul").append("<li>"+$("#in").val()+"</li>"); //將輸入的輸出到界面
    $("ul").append("<li>"+msg+"</li>"); //獲取返回值并輸出
    $("#in").val(""); //清空輸入框
    $("#text").scrollTop($("#text").scrollTop()+32);//滾動(dòng)條拉到最下面,顯示出輸入框
    }
    });
    }
    });
    $("#in")[0].focus();
    });
    </script>
    </head>
    <body>
    <div>
    <div>
    <img src="css/1.jpg">
    <span>Wechat Dos</span>
    </div>
    <div id="text">
    <ul>
    <li>Welcome...</li>
    <li>login:</li>
    </ul>
    <input type="text" name="" id='in'>
    </div>
    </div>
    </body>
    </html>
    CSS部分
    代碼如下:
    @charset "utf-8";
    body {
    background-color:#396DA5;
    margin:0px;
    padding:0px;
    color:#fff;
    font:"微軟雅黑";
    font-size:14px;}
    .window {
    border:6px #ccc outset;
    width:680px;
    height:442px;
    background-color:#000;
    position:absolute;
    top:40px;
    left:68px;
    overflow:hidden}
    .title {
    background-color:#08246B;
    padding:2px;}
    #text {
    background-color:#000;
    border-top:#ccc outset 2px;
    height:420px;
    overflow-y:scroll;}
    ul {
    margin:0px;
    padding:0px;
    list-style:none;}
    input {
    background-color:#000;
    border:0;
    color:#fff;
    outline:none;
    /*font-size:12px;*/
    width:100%}
    效果圖:
    名單