首页 > 其他分享 >前端三剑客快速入门(三)

前端三剑客快速入门(三)

时间:2022-10-07 22:13:26浏览次数:83  
标签:10 console log 前端 var world 三剑客 hello 入门

前言

前端三剑客快速入门(一)
前端三剑客快速入门(二)
书接上文,重新排版了。

CSS

  1. 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>
        body{
            height: 2000px;
        }
        .box{
            width: 100px;
            height: 100px;
            background-color: red;
            border: 1px solid black;
        }
        .pro{
            /* 绝对定位 脱离文档流 参照物视窗左上角 */
            /* position: absolute; */
            /* 相对定位  不脱离 元素原来位置 */
            /* position: relative; */
            /* 固定定位 脱离 当前视窗 */
            position: fixed;
            top: 80px;
            left: 80px;
            z-index: -100;
        }
        .pro-ab{
            position: absolute;
            /* z-index 只能为整数,值越大,就越在上层 */
            z-index: 999;
            top: 50px;
            left: 50px;
        }
    </style>
</head>
<body>
    <div class="box">1</div>
    <div class="box pro">2</div>
    <div class="box pro-ab">3</div>
    </body>
</html>

设置参照物:

<!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>
        .pic-box{
            width: 800px;
            margin: auto;
            position: relative;
        }
        .list{
            position: absolute;
            top: 80px;
            left: 300px;
        }
    </style>
</head>
<body>
    <div class="pic-box">
        <img src="pic/th.jpg" alt="图片正在加载ing...">
        <ul class="list">
            <li>1</li>
            <li>2</li>
            <li>3</li>
        </ul>
    </div>
</body>
</html>

返回顶部效果

<!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>
        body{
            height: 2000px;
        }
        .box{
            position: fixed;
            bottom: 100px;
            right: 100px;
        }
    </style>
</head>
<body>
    <h1>hello world</h1>
    <h1>hello world</h1>
    <h1>hello world</h1>
    <h1>hello world</h1>
    <h1>hello world</h1>
    <h1>hello world</h1>
    <h1>hello world</h1>
    <h1>hello world</h1>
    <h1>hello world</h1>
    <h1>hello world</h1>
    <div class="box">
        <button>
            <a href="#">返回顶部</a>
        </button>
    </div>
</body>
</html>

还原设计稿
因为主要要做JavaWeb,这学期还有Hadoop的学习,所以先开始JS,为JavaWeb做好铺垫。另外我也看了一下还原设计稿,需要ps,真就是照着文件一点一点编码,确实很符合工作实际,不过相对需要的时间也会变多,所以还是暂时跳过。可能会在寒假补上,总之肯定是要学完善的。

JavaScript

JavaScript简称JS,是一种脚本语言,主要控制网页的行为。即用户与浏览器的交互、浏览器与服务器的交互。以ECMAScriptS为标准,可以理解为ECMAScriptS是JS的版本。

入门例子

<!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>
</head>
<body>
    <h1>hello world</h1>

    <script>
        //注释
        // alert("hello world");
        console.log("hello world");
    </script>
</body>
</html>

变量与数据类型

<!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>
</head>
<body>
    <h1>hello world</h1>

    <script>
        // var 声明变量
        // var firstName = "hello world";
        // console.log(firstName);
        
        // var声明多个变量
        // var s1 = "hello",s2 = "woeld";
        // console.log(s1);
        // console.log(s2);

        //数据类型
        // var s = "hello"; //字符串 string
        // var n = 100;//数值 number
        // var b = true;//布尔 只有true 真、false 假

        // 数值计算 + - * /
        var n1 = 20,n2 = 10;
        var result = n1 + n2;
        console.log(result);
        
        // 字符串的拼接
        var s1 = "hello ",s2 = "world";
        result = s1 + s2;
        console.log(result);
    </script>
</body>
</html>

表达式与运算符

<!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>
</head>
<body>
    <h1>你好</h1>

    <script>
        // str1 = "hello";//将字面量赋值给变量
        // str2 = "world";
        // result = str1 + str2;//将表达式赋值给变量
        // console.log(result);

        // 表达式
        // var num1 = 188;
        // console.log(++num1 + num1++)//189 + 189
        // console.log(num1)
        // console.log("-----------")

        // var num2 = 188;
        // console.log(num2++ + ++num2)//188 + 190
        // console.log(num2)

        // 比较运算符
        // console.log(10 == "10");//不比较数据类型,会自动进行数据转换
        // console.log(10 != "10");//不比较数据类型,会自动进行数据转换

        // console.log(10 !== "10")
        // console.log(10 === "10");

        // 逻辑运算符
        var username = "admin";
        var password = "123456";
        console.log(username === "admin" && password === "123456");

        var username1 = "admin";
        console.log(username1 === "admin" || username1 === "test");

        console.log(!false)

        //赋值运算符 = += -= *= /=
    </script>
</body>
</html>

后言

这几节的JS内容都比较简单,学过别的语言的都会,再冗杂的去练习就属于鸡肋了。我就挑了一点有JS特点的简单的练习了练习,想要学习的小伙伴把上边的例子练习一下即可。后面的就是条件、循环、对象、函数、数组,这部分也是别的语言都包含的。再后面的正则表达式、DOM、BOM才是JS核心。估计可能周日去了。明天假期主要学习Hadoop,简单的跟一下JS。总的来说今天博客质量不是很高,还是得努力啊。

标签:10,console,log,前端,var,world,三剑客,hello,入门
From: https://www.cnblogs.com/he-cheng/p/16758585.html

相关文章

  • 【开悟篇】Java多线程之JUC从入门到精通
    1.多线程J.U.C1.1线程池1.1.1线程回顾1)回顾线程创建方式继承Thread实现Runnable2)线程的状态NEW:刚刚创建,没做任何操作Threadthread=newThread();System.out.println(......
  • 前端周刊第三十八期
    前端周刊发表每周前端技术相关的大事件、文章教程、一些框架的版本更新、以及代码和工具。每周定期发表,欢迎大家关注、转载。如果外链不能访问,关注公众号「前端每周看」,里......
  • 深入剖析 Kubernetes-1容器技术概念入门
    1从进程说开去1.1前言容器技术的兴起来源于PaaS技术的普及Docker公司发布的Docker项目具有里程碑式的意义Docker项目通过“容器镜像”,解决了应用打包这个根本性难题......
  • spring cloud config 入门
    简介Springcloudconfig分为两部分serverclientconfig-server配置服务端,服务管理配置信息config-client客户端,客户端调用server端暴露接口获取配置信息config-server......
  • java入门(1) 程序运行机制及运行过程
    首先我们来看一下java程序在底层是怎么工作的:JAVA有两种核心机制:Java虚拟机(JavaVirtualMachine):1、java虚拟机可以理解成一个以字节码为机器指令的CPU。2、对于不同的平台......
  • 入门神经网络-Python 实现(下)
    假设对BP的认识回顾紧接着上篇,整到了,MES的公式和代码的实现.\(MSE=\frac{1}{n}\sum\limits_{i=1}^n(y_i-\haty_i)^2\)n表示样本数,这......
  • 补充(代码)-入门神经网络-Python 实现(下)
    以案例+公式推导+代码编写,来走一遍神经网络的FG,BP算法.回顾紧接着上篇,整到了,MES的公式和代码的实现.\(MSE=\frac{1}{n}\sum\limi......
  • 前端妹子问我 position fixed 失效问题该如何解决?
    背景这两天公司一位妹子问我,“我这边调试的时候本地显示没问题,到手机端就有问题,该怎么办呢?”测试环境没问题到线上就有问题了?对此我也很纳闷。下图是复现的效果图,这个是一......
  • 玻璃拟态是什么?前端该如何实现
    你好,玻璃拟态玻璃拟态是目前市面上的新风格,越来越受欢迎。新拟态(Neumorphism)模仿了受到挤压的塑料材质(凹凸质感,凸显层次感),这个新的视觉风格更加注重垂直空间z轴的使用。它......
  • JPA 入门实战(1)--简介
    JPA(JavaPersistenceAPI)是SUN公司推出的一套ORM 规范,充当Java对象和关系数据库系统之间的桥梁;本文主要介绍其基本概念。1、JPA发展历史JPA1.0:于2006年发布JPA......