首页 > 其他分享 >html css js复习

html css js复习

时间:2022-12-30 15:57:09浏览次数:33  
标签:居中 function center 100px js html click css

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            /*元素水平居中*/
            margin:0 auto;
            /*元素水平垂直居中*/
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);
            /*文本水平&垂直居中*/
            text-align: center;
            line-height: 50px;/*50px是父级行高*/
            /*盒子模型*/
            margin: 10px;
            padding: 10px;
            box-sizing: border-box;
            /*浮动布局*/
            float: left;
            /*清除浮动
            1.clear: both;
            2.overflow: hidden;
            3.设置父级高度
            */
            /*flex布局:适合具体板块布局*/
            display: flex;
            /*主轴方向*/
            flex-direction: row;
            /*主轴居中*/
            justify-content: center;
            /*交叉轴居中*/
            align-items: center;
            /*项目居中*/
            /*flex没有justify-items和justify-self等*/
            align-self: center;
            /*grid布局:适合页面整体布局*/
            /*设置行列*/
            grid-template-columns: 100px 100px 100px;/*列,3列都是100px,同时也是单元格宽的尺寸*/
            grid-template-rows: 100px 100px 100px;/*行,3行都是100px,同时也是单元格高的尺寸*/
            /*主轴方向*/
            grid-auto-flow:row;
            /*主轴居中(整个grid容器)*/
            justify-content: center;
            /*交叉轴居中*/
            align-content: center;
            /*单元格主轴居中(所有单元格)*/
            justify-items: center;
            /*单元格交叉轴居中*/
            align-items: center;
            /*项目主轴居中(单个单元格)*/
            justify-self: center;
            /*项目交叉轴居中*/
            align-self: center;

            /*JavaScript*/
            /*ES5 ES6对比*/
            /*变量声明 var → let*/
        }
        
    </style>
</head>
<body>
    <script>
        /*获取节点*/
        //ES5
        var g = document.getElementById("id")
        var g = document.getElementsByClassName("classname")
        //ES6
        let g = document.querySelector("选择器")
        let g = document.querySelectorAll("选择器")
        /*事件
        1.鼠标事件:click、mouseenter、mouseleave
        2.键盘事件:keydown
        3.触屏事件:touchstart、touchend、touchmove
         以click为例*/
        //ES5
        g.onclick=function(){
            console.log("hello")
        }
        //ES6
        g.addEventListener("click",function(){
            console.log("hello")
        })
        //jQuery
        $("选择器").click(function(){
            console.log("hello")
        })

        /*事件设置样式*/
        //js
        g.onclick = function(){
            this.style.backgroundColor = "blue";
        }
        //jQuery
        $("button").click(function(){
            let height = $(this).css("height");
            console.log(height);
            $(this).css({
                height:"60px",
                width:"60px"
            })
        })

        /*事件设置属性*/
        //js
        g.onclick = function(){
            g.id="btn1";//点击后设置id属性,有就覆盖,没有就添加
            g.className="active";
        }
        //jQuery
        $("button").click(function(){
            $(this).attr("id","btt1");//有就覆盖,没有就添加
            $(this).attr("class","btn1");
        })

        /*节点操作*/
        //创建元素节点
        let li1 = document.createElement("li")//js
        let li = $(`<li>${value}</li>`)//jQuery
        //添加节点
        ul1.appendChild(li1)//js
        $(".fruits").append(li)//jQuery
        //删除节点
        ul1.removeChild(this)//js
        $(this).remove()//jQuery

        /*事件委托*/
        //js
        ul.addEventListener("click",function(e){
            ul.removeChild(e.target)
        })
        //jQuery
        $(".fruits").on("click","li",function(){
            $(this).remove();
        });
    </script>
</body>
</html>
html

标签:居中,function,center,100px,js,html,click,css
From: https://www.cnblogs.com/ben10044/p/17015077.html

相关文章

  • Docker 安装 Node.js
    Docker安装Node.jsNode.js是一个基于ChromeV8引擎的JavaScript运行环境,是一个让JavaScript运行在服务端的开发平台。Node.js使用了一个事件驱动、非阻塞式I/O的模型......
  • java 读取json文件到对象
    1、新建json文件[{"id":1,"name":"酒水专区","imageUrl":"7cf/e61b0aec87f07393.png","previewImageUrl":"/9f8d4360d3a125b5.png"},{......
  • 前端提交json对象前格式化对象数据和对象名称的方法
    1.格式化json对象名称,如把名称连接使用“_”剔除。constrenameFun=(obj)=>{lettoString=Object.prototype.toString;if(toString.call(obj)==='[object......
  • js 批量大文件上传下载
    ​ 以ASP.NETCoreWebAPI 作后端 API ,用 Vue 构建前端页面,用 Axios 从前端访问后端 API,包括文件的上传和下载。 准备文件上传的API #region 文件上传......
  • 静态页分页功能js代码
    <!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""​​http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd​​​"><htmlxmlns="​​​http://ww......
  • 直播平台制作,JS判断某个时间戳是否为当天时间
    直播平台制作,JS判断某个时间戳是否为当天时间vue中直接在标签中判断如下(item.PostTime为发帖时间戳) <imgclass="new"src="@/assets/img/new.png"v-if="newDate(Num......
  • 视频直播app源码,css预加载旋转动画与流光字体
    视频直播app源码,css预加载旋转动画与流光字体一、预加载旋转动画css body{}.concentric_round{width:200rpx;height:200rpx;position:relative;position:absolu......
  • list转json tree的工具类
    packagecom.glodon.safety.contingency.job;importcom.alibaba.fastjson.JSON;importcom.alibaba.fastjson.JSONArray;importcom.alibaba.fastjson.JSONObject;i......
  • Js 之拖拽动画
    一、效果图 二、示例代码<!DOCTYPEhtml><html><head><metacharset="utf-8"><metaname="viewport"content="width=device-width,initial-scale=1">......
  • Java 将HTML转为XML
    本文介绍如何通过Java后端程序代码来展示如何将html转为XML。此功能通过采用WordAPI-​​FreeSpire.DocforJava​​提供的Document.saveToFile()方法来实现;该方法支持的......