web前端第二次作业

2024-04-19 21:28

本文主要是介绍web前端第二次作业,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1,对象

let{

    属性

    方法

}

2,闭包

只有函数内部的子函数才能读取局部变量,所以闭包可以理解成定义在一个函数内部的函数,在本质上,闭包是将函数内部和函数外部连接起来的桥梁。

3,math

 console.log(Math.floor(a))向下取整
 console.log(Math.ceil(b)) 向上取整
 console.log(Math.max())最大值
 console.log(Math.min())最小值
 console.log(Math.floor(Math.random() * ((20 - 10) + 1)) + 10)随机数
 console.log(Math.round()四舍五入
 console.log(Math.sqrt())开平方根
 console.log(Math.pow(, ))幂次方

4,date 

let year = date.getFullYear()年

let m = date.getMonth() + 1 月

let day = date.getDate()天

let hh = date.getHours()时

let mm = date.getMinutes()分

let ss = date.getSeconds()秒

let w = date.getDay()星期

return `${year}-${m}-${day} ${hh}:${mm}:${ss} 今天星期${w}`}

5, 获取元素对象

document.querySelector("css选择器")

document.querySelectorALL 选全部

 6,改变元素属性

对象.属性 = 值

7,改变Style样式

1、对象.style.样式 = ""

碰见带-的符合属性,采用小驼峰的方式规避使用

box.classList.add()追加新的类名到元素对象上

box.classList.remove("box1") 移除元素对象的类名

像是checked这样的属性名=属性值的属性,js再进行赋值时,通过true/false去控制属性值

8,事件监听

 事件:事件源 事件类型 处理函数

l0 on事件类型    

  1. 事件源.on事件类型=function(){}

  2. 同一个事件源,后面注册的事件会对前面注册的事件进行覆盖

l1 事件监听 不会覆盖

倒计时作业

小米

 

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>* {margin: 0;padding: 0;box-sizing: border-box;}li {list-style: none;}a {text-decoration: none;}.content {width: 1226px;margin: 0 auto;}.header {height: 40px;background-color: #333;color: #B0B0B0;font-size: 12.68px;}.header .content {display: flex;justify-content: space-between;}.header-left {width: 790px;}.header-right {width: 230px;}.header .content a {font-size: 12px;color: #B0B0B0;line-height: 40px;}.header .sep {margin: 0 3.6px;}.header .shopping {margin-left: 20px;}.top-nav {height: 100px;overflow: hidden;}.top-nav .content {display: flex;justify-content: space-between;}.top-nav-left {width: 56px;height: 56px;background: url("https://cdn.cnbj1.fds.api.mi-img.com/mi.com-assets/shop/img/logo-mi2.png") no-repeat;background-size: 56px;margin-top: 20px;}.top-nav-mid ul {display: flex;justify-content: space-between;width: 700px;height: 100px;line-height: 100px;}.top-nav-mid ul a {color: #333;}.top-nav-right {padding-top: 25px;width: 296px;height: 100px;line-height: 100px;}.top-nav-right form {position: relative;width: 296px;height: 50px;}.top-nav-right input {position: absolute;left: 0;top: 0;width: 245px;height: 50px;vertical-align: middle;outline: none;}.top-nav-right span {display: inline-block;position: absolute;right: 0;top: 0;width: 52px;height: 50px;line-height: 50px;border: 1px solid black;text-align: center;font-size: 24px;}.xia{width: 1226px;height: 460px;background: url("") no-repeat;background-size: 1226px 460px;margin: 0 auto;}.xia .content{position: relative;}.xia .content .left ul{width: 234px;height: 460px;display: block;font-size: 14px;font-weight: 400;line-height: 21px;padding: 20px 0px;}.xia .content .left ul li{display: list-item;text-align: left;}.xia ul li a{width: 234px;height: 42px;display: block;height: 42px;line-height: 42px;position: relative;padding-left: 30px;float: left;}a{font-size: 12px;text-decoration: none;color: inherit;}.xia .content .zb{left: 234px;top: 230px;position: absolute;}.xia .content .yb{right:0px;top: 230px;position: absolute;}.xia .content .xb{box-sizing:inherit;right:30px;bottom: 20px;position: absolute;}.xia .content .xb ul{display: flex;flex-direction: row;}.xia .content .xb a{width: 10px;height: 10px;}.xia .content .xb ul li{list-style: disc;}.xia .content .xb ul li::marker {font-size: 15px;}.buttom{margin-top: 15px;}.buttom .content .aaa{background-color: rgb(95, 87, 80);float: left;line-height: 21px;font-size: 12px;}.buttom .content .aaa ul{width: 234px;height: 170px;line-height: 18px;text-align: center;}.buttom .content .aaa ul li{display: list-item;float: left;width: 70px;height: 82px;padding: 0px 3px;position: relative;text-align: center;}.buttom .content .aaa li a{width: 70px;height: 64px;color: #ffff;display: block;font-size: 12px;line-height: 18px;padding-top: 18px;text-align: center;}.buttom .zhaopian{width: 978px;height: 170px;float: right;}.buttom .zhaopian ul{width: 978px;height: 170px;padding: 0;margin: 0;}.buttom .zhaopian ul li{float: left;margin-left: 15px;}.buttom .zhaopian ul li:nth-child(1) {margin-left: 0px;}.buttom .zhaopian ul li a{display: block;box-sizing: border-box;}.buttom .zhaopian ul li a img{height: 170px;width: 315px;text-align: left;position: relative;}</style>
</head><body><div class="header"><div class="content"><div class="header-left"><a rel="nofollow" href="//www.mi.com/" >小米官网</a><span class="sep">|</span><a rel="nofollow" href="//www.mi.com/shop" >小米商城</a><span class="sep">|</span><a rel="nofollow" href="//hyperos.mi.com/" target="_blank">小米澎湃OS</a><span class="sep">|</span><a rel="nofollow" href="//iot.mi.com" target="_blank">IoT</a><span class="sep">|</span><a rel="nofollow" href="//i.mi.com/" target="_blank">云服务</a><span class="sep">|</span><a rel="nofollow" href="//airstar.com/home" target="_blank">天星数科</a><span class="sep">|</span><a rel="nofollow" href="//youpin.mi.com/" target="_blank">有品</a><span class="sep">|</span><a rel="nofollow" href="//xiaoai.mi.com/" target="_blank">小爱开放平台</a><span class="sep">|</span><a rel="nofollow" href="//www.mi.com/aptitude/list/?id=88" target="_blank">资质证照</a><span class="sep">|</span><a rel="nofollow" href="//www.mi.com/aptitude/list/" target="_blank">协议规则</a><span class="sep">|</span><a rel="nofollow" href="//www.mi.com/appdownload/" target="_blank">下载app</a><span class="sep">|</span><a rel="nofollow" href="#">Select Location</a></div><div class="header-right"><a href="#">登录</a><span class="sep">|</span><a href="#">注册</a><span class="sep">|</span><a href="#">消息通知</a><span class="shopping"><a href="#"><span class="iconfont icon-gouwuche"></span>购物车</a></span></div></div></div><div class="top-nav"><div class="content"><div class="top-nav-left"></div><div class="top-nav-mid"><ul><li><a href="#">xiaomi手机</a></li><li><a href="#">xiaom手机</a></li><li><a href="#">手机</a></li><li><a href="#">小手机</a></li><li><a href="#">手机</a></li><li><a href="#">手机</a></li><li><a href="#">xia手机</a></li><li><a href="#">xiaomi手机</a></li><li><a href="#">手机</a></li></ul></div><div class="top-nav-right"><form action="#"><input type="text"><span class="iconfont icon-sousuo"></span>  </form></div></div></div><div class="xia"><div class="content"><div class="left"><ul><li><a rel="nofollow" href="#">手机</a></li><li><a rel="nofollow" href="#">电视</a></li><li><a rel="nofollow" href="#">家电</a></li><li><a rel="nofollow" href="#">笔记本平板</a></li><li><a rel="nofollow" href="#">出行穿戴</a></li><li><a rel="nofollow" href="#">耳机音响</a></li><li><a rel="nofollow" href="#">健康儿童</a></li><li><a rel="nofollow" href="#">生活箱包</a></li><li><a rel="nofollow" href="#">智能路由器</a></li><li><a rel="nofollow" href="#">电源配件</a></li></ul></div><div class="right"><div class="zb"><span class="iconfont icon-zuo"></div><div class="yb"><span class="iconfont icon-you"></div><div class="xb"><ul><li><a rel="nofollow" href="#">&ensp;</a></li><li><a rel="nofollow" href="#">&ensp;</a></li><li><a rel="nofollow" href="#">&ensp;</a></li><li><a rel="nofollow" href="#">&ensp;</a></li><li><a rel="nofollow" href="#">&ensp;</a></li><li><a rel="nofollow" href="#">&ensp;</a></li></ul></div></div></div></div>  <div class="buttom"><div class="content"><div class="aaa"><ul><li><a rel="nofollow" href="#"><span></span>保障范围</a></li><li><a rel="nofollow" href="#"><span></span>企业团购</a></li><li><a rel="nofollow" href="#"><span></span>F码通道</a></li><li><a rel="nofollow" href="#"><span></span>米粉卡</a></li><li><a rel="nofollow" href="#"><span></span>以旧换新</a></li><li><a rel="nofollow" href="#"><span></span>话费充值</a></li></ul></div><div class="zhaopian"><ul><li></li><li></li><li></li></ul></div></div></div>
</body>
</html>

这篇关于web前端第二次作业的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/918498

相关文章

部署Vue项目到服务器后404错误的原因及解决方案

《部署Vue项目到服务器后404错误的原因及解决方案》文章介绍了Vue项目部署步骤以及404错误的解决方案,部署步骤包括构建项目、上传文件、配置Web服务器、重启Nginx和访问域名,404错误通常是... 目录一、vue项目部署步骤二、404错误原因及解决方案错误场景原因分析解决方案一、Vue项目部署步骤

前端原生js实现拖拽排课效果实例

《前端原生js实现拖拽排课效果实例》:本文主要介绍如何实现一个简单的课程表拖拽功能,通过HTML、CSS和JavaScript的配合,我们实现了课程项的拖拽、放置和显示功能,文中通过实例代码介绍的... 目录1. 效果展示2. 效果分析2.1 关键点2.2 实现方法3. 代码实现3.1 html部分3.2

解决JavaWeb-file.isDirectory()遇到的坑问题

《解决JavaWeb-file.isDirectory()遇到的坑问题》JavaWeb开发中,使用`file.isDirectory()`判断路径是否为文件夹时,需要特别注意:该方法只能判断已存在的文... 目录Jahttp://www.chinasem.cnvaWeb-file.isDirectory()遇

CSS弹性布局常用设置方式

《CSS弹性布局常用设置方式》文章总结了CSS布局与样式的常用属性和技巧,包括视口单位、弹性盒子布局、浮动元素、背景和边框样式、文本和阴影效果、溢出隐藏、定位以及背景渐变等,通过这些技巧,可以实现复杂... 一、单位元素vm 1vm 为视口的1%vh 视口高的1%vmin 参照长边vmax 参照长边re

JavaWeb-WebSocket浏览器服务器双向通信方式

《JavaWeb-WebSocket浏览器服务器双向通信方式》文章介绍了WebSocket协议的工作原理和应用场景,包括与HTTP的对比,接着,详细介绍了如何在Java中使用WebSocket,包括配... 目录一、概述二、入门2.1 POM依赖2.2 编写配置类2.3 编写WebSocket服务2.4 浏

CSS3中使用flex和grid实现等高元素布局的示例代码

《CSS3中使用flex和grid实现等高元素布局的示例代码》:本文主要介绍了使用CSS3中的Flexbox和Grid布局实现等高元素布局的方法,通过简单的两列实现、每行放置3列以及全部代码的展示,展示了这两种布局方式的实现细节和效果,详细内容请阅读本文,希望能对你有所帮助... 过往的实现方法是使用浮动加

css渐变色背景|<gradient示例详解

《css渐变色背景|<gradient示例详解》CSS渐变是一种从一种颜色平滑过渡到另一种颜色的效果,可以作为元素的背景,它包括线性渐变、径向渐变和锥形渐变,本文介绍css渐变色背景|<gradien... 使用渐变色作为背景可以直接将渐China编程变色用作元素的背景,可以看做是一种特殊的背景图片。(是作为背

CSS自定义浏览器滚动条样式完整代码

《CSS自定义浏览器滚动条样式完整代码》:本文主要介绍了如何使用CSS自定义浏览器滚动条的样式,包括隐藏滚动条的角落、设置滚动条的基本样式、轨道样式和滑块样式,并提供了完整的CSS代码示例,通过这些技巧,你可以为你的网站添加个性化的滚动条样式,从而提升用户体验,详细内容请阅读本文,希望能对你有所帮助...

css实现图片旋转功能

《css实现图片旋转功能》:本文主要介绍了四种CSS变换效果:图片旋转90度、水平翻转、垂直翻转,并附带了相应的代码示例,详细内容请阅读本文,希望能对你有所帮助... 一 css实现图片旋转90度.icon{ -moz-transform:rotate(-90deg); -webkit-transfo

vue基于ElementUI动态设置表格高度的3种方法

《vue基于ElementUI动态设置表格高度的3种方法》ElementUI+vue动态设置表格高度的几种方法,抛砖引玉,还有其它方法动态设置表格高度,大家可以开动脑筋... 方法一、css + js的形式这个方法需要在表格外层设置一个div,原理是将表格的高度设置成外层div的高度,所以外层的div需要