zoukankan      html  css  js  c++  java
  • day 16 JS DOM 继续

    为什么有jquey了还学DOM  ?
    因为JQuey 是大而全,可能有10k 但是我们用到的只有1k  网站小没事,网站大流量就是问题
    所以大网站都是自己用DOM 实现一个类似于JQuey 的适合自己公司的模块
    所以需要学习DOM 。
     
     
    回顾下上次内容:

    min-width 设置最小宽度,在页面缩放的时候,当宽度小于指定宽度时,使用最小宽度

    左边菜单不动  

    学一个新技能,只要改一个属性就能实现 菜单 左边固定不动 和 菜单随右边内容滚动

     

    实践:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            body{
                margin: 0;
            }
            .left{
                float: left;
            }
            .right{
                float: right;
            }
            .pg-header{
                height: 48px;
                background-color: #2459a2;
                color: white;
            }
            .pg-content .menu{
                position: absolute;
                top:48px;
                left: 0;
                bottom: 0;
                 200px;
                background-color: #dddddd;
            }
            .pg-content .content{
                position: absolute;
                top: 48px;
                right: 0;
                bottom: 0;
                left: 200px;
                min- 980px;
                overflow: auto;
            }
        </style>
    </head>
    <body>
        <div class="pg-header"></div>
        <div class="pg-content">
            <div class="menu left">a</div>
            <div class="content left">
                <!--<div style="position: fixed;bottom:0;right:0; 50px;height: 50px;">返回顶部</div>-->
                <!--<div style="position: absolute;bottom:0;right:0; 50px;height: 50px;">返回顶部</div>-->
                <div style="background-color: purple">
                <p style="margin: 0;">asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p style="margin: 0;">asdf</p>
                    </div>
            </div>
        </div>
        <div class="pg-footer"></div>
    </body>
    </html>
    

     

    调整为圆形的 就调整这个参数为50%

     

    实践:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            .item{
                background: #dddddd;
            }
            .item:hover{
                color: red;
            }
            .item:hover .b{
                background-color: #396bb3;
            }
        </style>
    </head>
    <body>
        <div class="item">
            <div class="a">aa</div>
            <div class="b">bb</div>
        </div>
    </body>
    </html>
    

    效果:

     我们如何使用第三方的图标呢?

    下载css库,然后引用,直接使用就可以了:

    效果:

     

    调整padding参数,变圆:

     

     

     9 序列化

     

    时间,就是一个类,有很多方法:

     

     作用域:

     就近原则,找变量,和python  一样

     

     声明变量 没有赋值 就是 undefined

     

    解决每个对象需要用共同的东西,但是又不想占用更多内存的方法:

    未解决前:

     

     使用原形解决:

     

     原形创建于类里面 这样就不存在于对象中了

    对html的操作:

    操作:

    1 使用text

    2 使用html

    操作文本框:

    select 框:

    查找分为两种形式:

    select 特有的 可以通过 index 设置

    大文本框的获取及更改:

    实现一个搜索框的默认有文字,鼠标点击后文字消失的功能:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <div style=" 600px; margin: 0 auto">
            <input type="text" id="i1" onfocus="Focus();"  onblur="Blur();" value="请输入关键字"/>
        </div>
        <script>
            function Focus() {
                var tag = document.getElementById("i1");
                var val = tag.value;
                if(val == "请输入关键字"){
                    tag.value="";
                }
            }
            function Blur() {
                var tag = document.getElementById("i1");
                var val = tag.value;
                if(val.length == 0){
                    tag.value="请输入关键字";
                }
            }
        </script>
    </body>
    </html>
    

    效果:

     

     JavaScripts  函数 一般用驼峰样式写

     

     

    操作html 标签:

     

     第二种方法:

     

     写一个个人菜单的样式效果:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            body{
                margin: 0;
            }
            .left{
                float: left;
            }
            .right{
                float: right;
            }
            .pg-header{
                height: 48px;
                background-color: #2459a2;
                color: white;
                line-height: 48px;
            }
            .pg-header .logo{
                 200px;
                background-color: cadetblue;
                text-align: center;
            }
            .pg-header .user{
                    margin-right: 60px;
                padding: 0 20px;
                color: white;
                height: 48px;
            }
            .pg-header .user:hover{
                background-color: #204982;
            }
            .pg-header .user .a img{
                height: 40px; 40px;margin-top: 4px;border-radius: 50%;
            }
            .pg-header .user .b{
                    z-index: 20;
                    position: absolute;
                    top: 48px;
                    right: 44px;
                    background-color: white;
                color: black;
                 160px;
                display: none;
            }
            .pg-header .user:hover .b{
                display: block;
            }
            .pg-header .user .b a{
                display: block;
            }
            .pg-content .menu{
                position: absolute;
                top:48px;
                left: 0;
                bottom: 0;
                 200px;
                background-color: #dddddd;
            }
    
            .pg-content .content{
                position: absolute;
                top: 48px;
                right: 0;
                bottom: 0;
                left: 200px;
                overflow: auto;
                z-index: 9;
    
            }
        </style>
    </head>
    <body>
    
        <div class="pg-header">
            <div class="logo left">
                老男孩
            </div>
            <div class="user right" style="position: relative">
                <a class="a" href="#">
                    <img src="22.jpg">
                </a>
                <div class="b">
                    <a>我的资料</a>
                    <a>注销</a>
                </div>
            </div>
    
    
        </div>
        <div class="pg-content">
            <div class="menu left">a</div>
            <div class="content left">
                <!--<div style="position: fixed;bottom:0;right:0; 50px;height: 50px;">返回顶部</div>-->
                <!--<div style="position: absolute;bottom:0;right:0; 50px;height: 50px;">返回顶部</div>-->
                <div style="background-color: purple">
                <p style="margin: 0;">asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                <p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p><p>asdf</p>
                    </div>
            </div>
        </div>
        <div class="pg-footer"></div>
    </body>
    </html>
    

      

     效果:

  • 相关阅读:
    UVA1292-----Strategic game-----树形DP解决树上的最小点覆盖问题
    【OpenGL游戏开发之三】OpenGl核心函数库汇总
    【Lucene】挖掘相关搜索词
    OpenMP入门教程(三)
    OpenMP入门教程(二)
    OpenMP入门教程(一)
    结构体的排序
    结构体
    循环群、对称群、陪集和拉格朗日定理、正规子群和商群
    概率论与数理统计(一)—— 随机事件与概率
  • 原文地址:https://www.cnblogs.com/yangever/p/6094001.html
Copyright © 2011-2022 走看看