博主信息
博文 41
粉丝 2
评论 1
访问量 32460
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
0330作业
郭恒的博客
原创
710人浏览过

IMG_20180402_183249.jpgIMG_20180402_183259.jpgIMG_20180402_183305.jpg

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>实战1:选项卡</title>
    <style type="text/css">
        h2 {
            text-align: center;
        }
        .box {
            width: 538px;
            height: 200px;
            background-color: white;
            border: 1px solid #ccc;
            margin: 20px auto;
            color: #363636;
        }
        .box > ul {
            margin: 0;
            padding: 0;
            background-color: #f8f8f8;
            overflow: hidden;
        }
        .box > ul li {
            list-style-type: none;
            width: 90px;
            height:36px;
            float:left;
            border-right: 1px solid #ccc;
            border-bottom: 1px solid #ccc;
            text-align: center;
            line-height: 36px;
        }
        .box ul + span {
            float:right;
            width:110px;
            height: 36px;
            line-height: 36px;
            margin-top: -36px;
        }
        .box ul + span >a {
            color: #696969;
            text-decoration: none;
        }
        .box li.active {
            background-color: #fff;
            font-weight: bolder;
            border-bottom: none;
            border-top: 3px solid orangered;
        }
        .box div {
            display: none;
        }
        .box div ul {
            margin: 0;
            padding: 10px;
            list-style-type: none;
        }
        .box div ul li {
            line-height: 1.5em;
        }
        .box div ul li a {
            color: #636363;
            text-decoration: none;
        }
        .box div ul li a:hover {
            color: #000;
        }
        .box div ul li  span {
            float: right;
            color: red;
        }
    </style>
</head>
<body>
<h2>仿PHP中文网选项卡实战</h2>
<div class="box">
    <ul>
        <li class="active">范冰冰</li>
        <li>杨幂</li>
        <li>迪丽热巴</li>
        <li>赵丽颖</li>
    </ul>
    <span><a href="">更多下载>></a></span>
        <div style="display: block;">
        <ul>
            <li><a href="">范冰冰 | 1</a><span>03-30</span></li>
            <li><a href="">范冰冰 | 2</a><span>03-30</span></li>
            <li><a href="">范冰冰 | 3</a><span>03-30</span></li>
            <li><a href="">范冰冰 | 4</a><span>03-30</span></li>
        </ul>
    </div>
    <div>
        <ul>
            <li><a href="">杨幂 | 1</a><span>03-30</span></li>
            <li><a href="">杨幂 | 2</a><span>03-30</span></li>
            <li><a href="">杨幂 | 3</a><span>03-30</span></li>
            <li><a href="">杨幂 | 4</a><span>03-30</span></li>
        </ul>
    </div>
    <div>
        <ul>
            <li><a href="">迪丽热巴 | 1</a><span>03-30</span></li>
            <li><a href="">迪丽热巴 | 2</a><span>03-30</span></li>
            <li><a href="">迪丽热巴 | 3</a><span>03-30</span></li>
            <li><a href="">迪丽热巴 | 4</a><span>03-30</span></li>
        </ul>
    </div>
    <div>
        <ul>
            <li><a href="">赵丽颖 | 1</a><span>03-30</span></li>
            <li><a href="">赵丽颖 | 2</a><span>03-30</span></li>
            <li><a href="">赵丽颖 | 3</a><span>03-30</span></li>
            <li><a href="">赵丽颖 | 4</a><span>03-30</span></li>
        </ul>
    </div>
</div>
<script type="text/javascript">
    var box = document.getElementsByClassName('box')[0]
    var ul = box.getElementsByTagName('ul')[0]
    var tab = ul.getElementsByTagName('li')
    var list = box.getElementsByTagName('div')
    for (var i=0; i<tab.length; i++) {
       tab[i].index = i
       tab[i].onmouseover = function (){
            for (var i=0; i<tab.length; i++) {
                tab[i].className = ''
                list[i].style.display = 'none'
            }
            this.className = 'active'
            list[this.index].style.display = 'block'
        }
    }
</script>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>2.仿机器人聊天窗口</title>
    <style type="text/css">
        div:nth-child(1) {
            width: 450px;
            height: 500px;
            background-color: lightskyblue;
            margin: 30px auto;
            color: #333;
            box-shadow: 2px 2px 2px #808080;
        }
        h2 {
            text-align: center;
            margin-bottom: -10px;
        }
        div:nth-child(2) {
            width: 400px;
            height: 350px;
            border: 4px double green;
            background-color: #efefef;
            margin: 20px auto 10px;
        }
        ul {
            list-style: none;
            line-height: 2em;
            overflow: hidden;
            padding: 15px;
        }
        table {
            width: 90%;
            height:80px;
            margin: auto;
        }
        textarea{
            border: none;
            resize: none;
            background-color: lightyellow;
        }
        button {
            width: 60px;
            height: 40px;
            background-color: seagreen;
            color: white;
            border: none;
        }
        button:hover {
            cursor: pointer;
            background-color: orange;
        }
    </style>
</head>
<body>
<div>
    <h2>在线客服</h2>
    <div contenteditable="true">
        <ul>
            <li></li>
        </ul>
    </div>
    <table>
        <tr>
            <td align="right"><textarea cols="50" rows="4" name="text"></textarea></td>
            <td align="left"><button type=button>发送</button></td>
        </tr>
    </table>
</div>
<script type="text/javascript">
    var btn = document.getElementsByTagName('button')[0]
    var text = document.getElementsByName('text')[0]
    var list = document.getElementsByTagName('ul')[0]
    var sum = 0
    btn.onclick = function () {
        if (text.value.length == 0) {
            alert('忘记输入内容了吧')
            return false
        }
        var userComment = text.value
        text.value = ''
        var li = document.createElement('li')
        li.innerHTML = userComment
        var userPic = '<img src="../images/ym.jpg" width="30" style="border-radius:50%">'
        li.innerHTML = userPic+userComment
        list.appendChild(li)
        sum += 1
        setTimeout(function(){
            var info = ['你好烦人','除了退货,退款,维修,什么问题都可以问','啥事呀,说,快点','哈哈哈哈']
            var temp = info[Math.floor(Math.random()*3)]
            var reply = document.createElement('li')
            var kefuPic = '<img src="../images/fbb.jpg" width="30" style="border-radius:50%;">'
            reply.innerHTML = kefuPic + '<span style="color:red">'+temp+'</span>'
            list.appendChild(reply)
            sum += 1
        },2000)
        if (sum > 10) {
            list.innerHTML = ''
            sum = 0
        }
    }
</script>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


批改状态:合格

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
  • 2018-03-16 15:12:44
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学