Python工城师的成长————css(溢出属性、定位、z-index)、js简介

本文介绍了CSS中的溢出属性overflow,包括visible、hidden和auto的设置,以及如何解决元素溢出问题。接着讲解了CSS定位属性,包括静态、相对、绝对和固定定位,并探讨了z-index的作用。最后,深入学习了JavaScript的基础知识,如变量、注释、数据类型(数值、字符串、布尔和对象)以及常用的字符串操作和数组方法。

今日学习目标

  • 熟悉css中剩下的修改属性的方法,开始学习JS内容。


学习内容

  • CSS—溢出属性
  • CSS—定位
  • CSS—z-index
  • JavaScript

一、CSS—溢出属性

当子元素(标签)的尺寸超过父元素(标签)的尺寸时,此时需要设置父元素显示溢出的子元素的方式,设置的方法是通过overflow属性来完成。 【在父标签上进行设置】

overflow的设置项

  • visible 默认值, 显示子标签溢出部分。
  • hidden 隐藏子标签溢出部分。
  • auto 如果子标签溢出,则可以滚动查看其余的内容。

小结

  • overflow样式属性是设置子标签溢出的显示方式
  • 常用使用overflow:hidden;来解决元素溢出

二、CSS—定位属性

1.定位的状态

  1. 静态定位 static
    所有的标签默认都是静态定位即不能通过定位操作改变位置
  2. 相对定位 relative
    相对于标签原来的位置做定位
  3. 绝对定位 absolute
    相对于已经定位过的父标签做定位
  4. 固定定位 fixed
    相对于浏览器窗口做定位

2.定位操作

position:  属性状态
left\right\top\bottom

补充
绝对定位
如果没有父标签或者父标签没有定位 则以body为准 相当于变成了相对定位

三、CSS—z-index

知识前提

1.前端界面其实是一个三维坐标系 z轴指向用户
2.动态弹出的分层界面 我们也称之为叫模态框

作用

定位元素,主要是z轴上的元素。即定义了position为非static的元素

四、JavaScript

1.JavaScript简介

1.JavaScript与Java没有半毛钱关系
之所以叫这么个名字纯粹是为了蹭当时Java的热度

2.JavaScript简称JS 也是一门前端的编程语言
前端由于非常受制于后端,所以有一些人异想天开想要通过js来编写后端代码一统江湖 由此开发了一个叫nodejs的工具(支持js跑在后端服务器上)>>>:不好用

3.JS最初由一个程序员花了七天时间开发的 里面存在很多bug
为了解决这些bug一直在编写相应的补丁 补丁本身又有bug 最后导致了js中有很多不符合逻辑的地方(成了大家墨守成规的东西)

4.JavaScript与ECMAScript
JavaScript原先由一家公司开发 希望其他公司都使用 最后被组织改名

5.版本问题
目前主要流行的就是这两个版本,因为IT行业中是有稳定的版本绝不使用最新的版本
ECMA5
ECMA6

2.变量与注释

  1. 注释语法

    // 单行注释
    /*多行注释*/
    
  2. 结束符号

    分号结束   console.log('hello world');
    
  3. 变量声明
    在js中定义变量需要使用关键字声明

    1.var
    var name = 'jason'
    2.let
    let name = 'jason'
    

var声明都是全局变量 let可以声明局部变量
4. 常量声明

const pi = 3.14

补充
编写js代码的位置

1.pycharm提供的js文件
2.浏览器提供的js环境(学习阶段推荐)

3.数据类型

补充

查看数据类型的方式
typeof

1. 数值类型(相当于python里面的整型int和浮点型float)

Number

NaN:属于数值类型 意思是’不是一个数字’(not a number)
parseInt(‘abc’) 不报错返回NaN
parseFloat(‘abc’)不报错返回NaN

2. 字符类型(相当于python里面的字符串str)

String
默认只能是单引号和双引号

var name1 = 'jason'
var name2 = "jason"

格式化字符串小顿号

	var name3 = `jason`

2.1字符的拼接

js中推荐使用加号

2.2. 统计长度

js中使用length python中使用len()

2.3. 移除空白(不能指定)

js中使用trim()、trimLeft()、trimRight()
python中使用strip()、lstrip()、rstrip()

2.4. 切片操作

js中使用substring(start,stop)、slice(start,stop)
	前者不支持负数索引后者支持
python中使用[index1:index2]

2.5. 大小写转换

js中使用.toLowerCase()、.toUpperCase()
python中使用lower()、upper()

2.6. 切割字符串

js中和python都是用split() 但是有点区别
	ss1.split(' ')
  	['jason', 'say', 'hello', 'big', 'baby']
  ss1.split(' ', 1)
  	['jason']
  ss1.split(' ', 2)
  	['jason', 'say']

2.7. 字符串的格式化

js中使用格式化字符串(小顿号)
	var name = 'jason'
  var age = 18
  console.log(`
  	my name is ${name} my age is ${age}
  `)
  my name is jason my age is 18
python中使用%或者format

3. 布尔类型(相当于python中的布尔值bool)

Boolean

js中布尔值是全小写
	true false
  布尔值为false的 0 空字符串 null undefined NaN
python中布尔值时首字母大写
	True False
	布尔值为False的 0 None 空字符串 空列表 空字典...

补充·
null的意思是空 undefined的意思是没有定义

var bb = null;
	bb
null

var aa
	aa
undefined

4. 对象(相当于python中的列表、字典、对象)

数组(相当于python中的列表)

Array
	var l1 = [11, 22, 33]

4.1.追加元素

js中使用push()  python中使用append()

4.2.弹出元素

js和python都用的pop()

4.3.头部插入元素

js中使用unshift()  python中使用insert()

4.4.头部移除元素

js中使用shift()    python中可以使用pop(0) remove() 

4.5.扩展列表

js中使用concat()   python中使用extend()

4.6.forEach
forEach 是操作数组的一种方法,主要功能是遍历数组,其实说穿了,就是 for 循环的加强版,该语句需要一个回调函数,作为参数。回调函数的形参,依次为,value:遍历的数组内容;index:对应的数组索引,array:数组本身。

<script type="text/javascript">
// 分别对应:数组元素,元素的索引,数组本身
var arr = ['a','b','c'];	
arr.forEach(function(value,index,array){
	console.log(value);
	console.log(index);
	console.log(array);
	})
</script>

在这里插入图片描述
总结
for 循环比较步骤多比较复杂,forEach 循环比较简单好用,不容易出错。

4.7.splice

splice方法可以用来对js的数组进行删除,添加,替换等操作。

  1. 删除功能,第一个参数为第一项位置,第二个参数为要删除几个。

    用法:array.splice(index,num),返回值为删除内容,array为结果值。
    在这里插入图片描述

  2. 插入功能,第一个参数(插入位置),第二个参数(0),第三个参数(插入的项)。

    用法:array.splice(index,0,insertValue),返回值为空数组,array值为最终结果值。

    在这里插入图片描述

  3. 替换功能,第一个参数(起始位置),第二个参数(删除的项数),第三个参数(插入任意数量的项)。

    用法:array.splice(index,num,insertValue),返回值为删除内容,array为结果值。
    在这里插入图片描述


<div class="container"> <div class="top"> <div class="top-left"> <div class="top-left-side"> </div> <div class="top-left-content"> <div class="logo"> <img src="/plugin_assets/polls/images/icon-company.png" alt="公司图标"> <div class="logo-text"> <div class="company-name">武汉光庭信息技术股份有限...</div> <div class="platform-name">数字化学习平台</div> </div> </div> <div class="nav"> <div class="nav-item"> <img src="/plugin_assets/polls/images/icon-home.png" alt="首页"> <span>首页</span> </div> <div class="nav-item"> <img src="/plugin_assets/polls/images/icon_study.png" alt="学习中心"> <span>学习中心</span> </div> <div class="nav-item"> <img src="/plugin_assets/polls/images/icon_shop.png" alt="知识商"> <span>知识商</span> </div> <div class="nav-item"> <img src="/plugin_assets/polls/images/icon_profile.png" alt="个人中心"> <span>个人中心</span> </div> </div> </div> </div> <div class="top-right"> <div class="search"> <label> <input type="text" placeholder="请输入想要的内容"> </label> <a class="search-icon">🔍︎</a> </div> </div> </div> <div class="bottom"> <div class="content"> <div class="left-content"> <!--————————————————————————carousel——————————————————————--> <div class="carousel-container"> <div class="carousel-inner"> <img class="carousel-inner-img" src="/plugin_assets/polls/images/slide2.png" alt="培训信息"> <div class="carousel-text">新员入职培训</div> </div> </div> <!--————————————————————————banner——————————————————————--> <div class="banner-container"> <div class="banner-item"> <img src="/plugin_assets/polls/images/book.png" alt="首页"> <span>培训列表</span> </div> <div class="banner-item"> <img src="/plugin_assets/polls/images/pen.png" alt="学习中心"> <span>考试列表</span> </div> <div class="banner-item"> <img src="/plugin_assets/polls/images/remark.png" alt="知识商"> <span>课程列表</span> </div> <div class="banner-item"> <img src="/plugin_assets/polls/images/champion.png" alt="个人中心"> <span>学习排行</span> </div> </div> <!--————————————————————————task——————————————————————--> <div class="task-container"> <div class="task-title"> <span class="task-title-span">学习任务</span> <div class="task-tabs-container"> <div class="task-tabs active" data-tab="tab1"> <span>培训</span> </div> <div class="task-tabs" data-tab="tab2"> <span>考试</span> </div> </div> <div class="task-all-tab">全部</div> </div> <div class="task-content"> <!-- 培训内容 --> <div id="task-tab1-content" class="task-tab-content" style="display: block;"> <div class="task-content-card"> <!-- 图片区域占据50%高度 --> <div class="task-card-header"> <img class="task-card-image" src="/plugin_assets/polls/images/task-item.png" alt="培训课程图片"> <div class="task-card-image-text">3节课</div> </div> <div class="task-card-body"> <div class="task-card-title">光庭专属钉安装使用培训</div> <div class="task-card-progress">必修:2025.09.19截止</div> <div class="task-card-deadline" >已完成33%</div> </div> </div> </div> <!-- 考试内容 --> <div id="task-tab2-content" class="task-tab-content" style="display: none;"> <div class="task-exam-card"> <!-- 居中图片 --> <img class="task-exam-card-image" src="/plugin_assets/polls/images/task-no-exam.png" alt="示例图片"> <!-- 底部文字 --> <p class="task-exam-card-tips">你当前没有考试任务</p> </div> </div> </div> </div> <!--————————————————————————training——————————————————————--> <div class="training-container"> <div class="training-title"> <span class="training-title-span">新员入职培训</span> <div class="training-title-all">全部</div> </div> <div class="training-content"> <div class="training-content-card"> <div class="training-card-left-section"> <div class="training-card-image-wrapper"> <img src="/plugin_assets/polls/images/training-item.png" alt="课程封面"> </div> <div class="training-card-text">新员入职培训</div> </div> <div class="training-card-right-section"> <div class="training-card-title">公司级新员入职培训</div> <div class="training-card-summary">新员入职培训共分两个系列,具体如下</div> <div class="training-card-actions"> <img class="training-card-icon-wrapper" src="/plugin_assets/polls/images/icon_ok.png" alt="点赞">50 <div class="training-vertical-line"></div> <img class="training-card-icon-wrapper" src="/plugin_assets/polls/images/icon_comment.png" alt="评论">0 </div> </div> </div> </div> </div> <!--————————————————————————courses——————————————————————--> <div class="courses-container"> <div class="courses-title"> <span class="courses-title-span">培训</span> <div class="courses-title-all">全部</div> </div> <div class="courses-content"> <div class="courses-content-card"> <div class="courses-card-left-section"> <div class="courses-card-image-wrapper"> <img src="/plugin_assets/polls/images/task-item.png" alt="课程封面"> </div> <div class="courses-card-text">新员入职培训</div> </div> <div class="courses-card-right-section"> <div class="courses-card-title">公司级新员入职培训</div> <div class="courses-card-summary">新员入职培训共分两个系列,具体如下</div> <div class="courses-card-actions"> <img class="courses-card-icon-wrapper" src="/plugin_assets/polls/images/icon_ok.png" alt="点赞">50 <div class="courses-vertical-line"></div> <img class="courses-card-icon-wrapper" src="/plugin_assets/polls/images/icon_comment.png" alt="评论">0 </div> </div> </div> </div> </div> <!--————————————————————————exam——————————————————————--> <div class="exam-container"> <div class="exam-title"> </div> <div class="exam-content"> </div> </div> <!--————————————————————————content-gap——————————————————————--> <div class="content-gap"></div> </div> <div class="right-side"> </div> </div> </div> </div> <style> * { box-sizing: border-box; margin: 0; padding: 0; } html, body { height: 100%; } .container { display: flex; flex-direction: column; height: 100vh; } /*********************top****************************/ .top { height: 10vh; background-color: #f0f0f0; /*border-bottom: 1px solid #ccc;*/ display: flex; box-sizing: border-box; background-color: hsla(0, 0%, 100%, 0.6); } .top-left { flex: 0 0 66.5%; display: flex; align-items: center; } .top-left-side { flex: 1; display: flex; align-items: center; } .top-left-content { flex: 0 0 70%; display: flex; align-items: center; gap: 20px; } .top-right { display: flex; align-items: center; justify-content: flex-start; } .logo { display: flex; align-items: center; } .logo img { width: 38px; height: 38px; margin-right: 16px; } .logo-text { display: flex; flex-direction: column; overflow: hidden; } .company-name { font-size: 18px; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; } .platform-name { font-size: 14px; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; } .nav { display: flex; gap: 25px; justify-content: flex-start; } .nav-item { display: flex; flex-direction: row; align-items: center; white-space: nowrap; gap: 3px; font-size: 16px; color: #a9a9a9; text-decoration: none; transition: color 0.3s; } .nav-item img { width: 20px; height: 20px; flex-shrink: 0; display: block; } .nav-item:hover { color: #007bff; } .search { flex: 0 0 285px; position: relative; max-width: 400px; display: inline-block; } .search input { width: 100%; height: 30px; padding-left: 35px; font-size: 14px; border: 1px solid #759fcf; border-radius: 4px; box-sizing: border-box; } .search-icon { position: absolute; left: 0; top: 0; height: 100%; width: 30px; display: flex; align-items: center; justify-content: center; pointer-events: none; color: #888; font-size: 16px; background: transparent; border: none; } /*********************bottom****************************/ .bottom { flex: 1; background-color: rgba(242, 242, 242, 0.3); position: relative; } .content { position: absolute; top: 17px; bottom: 0; /* 保持原有值 */ width: 100%; } .left-content { position: absolute; left: 18.3%; top: 0; height: 100%; /*width: 47%;*/ width: 870px; padding: 0; box-sizing: border-box; /*border-right: 1px solid #ccc;*/ /*border-left: 1px solid #ccc;*/ } /************************carousel***********************************************/ .carousel-container { /*height: 37%;*/ height: 314px; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); margin-bottom: 19px; padding: 30px; } .carousel-inner { width: 100%; height: 100%; padding: 0; background-color: rgba(179, 179, 179, 0.3); position: relative; display: inline-block; } .carousel-text { position: absolute; top: 87%; left: 32%; transform: translate(-50%, -50%); color: white; font-size: 24px; font-weight: bold; text-shadow: 1px 1px 2px black; z-index: 999; } .carousel-inner-img { max-width: 60%; height: 100%; margin-left: 21%; box-shadow: -25px 0 20px rgba(255, 255, 255, 0.5), 25px 0 20px rgba(255, 255, 255, 0.5); } /************************banner***********************************************/ .banner-container { display: flex; gap: 100px; justify-content: flex-start; height: 94px; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); margin-bottom: 19px; padding-left: 4%; } .banner-item { display: flex; flex-direction: row; align-items: center; white-space: nowrap; gap: 3px; font-size: 16px; color: #a9a9a9; text-decoration: none; cursor: pointer; } .banner-item:hover { color: #a9a9a9; } .banner-item img { width: 55px; height: 55px; flex-shrink: 0; display: block; } /************************@TODO content-card***********************************************/ .content-card { position: relative; width: 48%; height: 83%; background-color: #fff; border: 1px solid #e0e0e0; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); padding: 20px; margin: 10px 0; transition: transform 0.2s; } /************************task***********************************************/ .task-container { /*height: 20%;*/ height: 323px; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); margin-bottom: 19px; } .task-title { height: 20%; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); padding-left: 20px; padding-right: 25px; display: flex; align-items: center; justify-content: space-between; flex-wrap: nowrap; gap: 15px; } .task-title-span { font-size: 18px; flex: 0 0 auto; } .task-tabs-container { display: flex; gap: 2px; flex: 1 1 auto; font-size: 14px; color: #a9a9a9; margin-left: 5%; } .task-tabs { margin-right: 4.5%; transition: color 0.3s; } .task-tabs > span { position: relative; padding-bottom: 40%; cursor: pointer; color: #a9a9a9; } .task-tabs > span:hover { cursor: pointer; } .task-tabs.active span { color: #007bff; position: relative; padding-bottom: 40%; } .task-tabs.active span::after { content: ''; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; height: 2px; background-color: #007bff; border-radius: 2px; } .task-all-tab { flex: 0 0 auto; color: #3798fb; font-size: 16px; cursor: pointer; transition: color 0.3s ease; } .task-all-tab:hover { color: #007bff; } .task-content { height: 80%; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); } .task-tab-content { position: relative; height: 100%; width: 100%; } .task-content-card { position: relative; background-color: #fff; border: 1px solid #e0e0e0; border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); transition: transform 0.2s; width: 20%; height: 80%; margin-left: 2%; margin-top: 2%; } .task-content-card:hover { transform: translateY(-2px); } .task-card-header { position: relative; height: 50%; } .task-card-image { position: relative; height: 100%; width: 100%; border-radius: 5px 5px 0 0; } .task-card-image-text{ position: absolute; top: 87%; left: 15%; transform: translate(-50%, -50%); color: white; font-size: 14px; /*font-weight: bold;*/ text-shadow: 1px 1px 2px black; z-index: 999; } .task-card-body { position: relative; } .task-card-title { position: relative; padding-left: 4%; margin-bottom: 2%; font-size: 17px; font-weight: 300; flex: 0 0 auto; } .task-card-progress{ position: relative; padding-left: 4%; margin-bottom: 2%; color: #f66; } .task-card-deadline{ position: relative; padding-left: 4%; color: #555; } .task-exam-card{ display: flex; position: relative; flex-direction: column; align-items: center; text-align: center; } .task-exam-card-image{ margin-top: 5%; position: relative; width: 14%; height: auto; } .task-exam-card-tips{ position: relative; margin-top: 3%; color: #555; font-size: 17px; font-weight: 300; } /*****************************training******************************************************/ .training-container { /*height: 20%;*/ height: 200px; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); margin-bottom: 49px; } .training-title { height: 64px; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); padding-left: 20px; padding-right: 25px; display: flex; align-items: center; justify-content: space-between; flex-wrap: nowrap; gap: 15px; } .training-title-span{ font-size: 18px; flex: 0 0 auto; } .training-title-all { flex: 0 0 auto; color: #3798fb; font-size: 16px; cursor: pointer; transition: color 0.3s ease; } .training-title-all:hover { color: #007bff; } .training-content { height: 80%; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); } .training-content-card{ position: relative; width: 48%; height: 73%; background-color: #fff; border: 1px solid #e0e0e0; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); margin: 2% 2% 2%; transition: transform 0.2s; display: flex; flex-direction: row; box-sizing: border-box; } .training-card-left-section { flex: 31%; display: flex; flex-direction: column; padding: 10px; box-sizing: border-box; margin-left: 8px } .training-card-image-wrapper{ flex: 1; background-color: #eee; display: flex; align-items: center; justify-content: center; margin-bottom: 6%; } .training-card-text{ font-size: 14px; font-weight: 200; flex: 0 0 auto; color: #555; } .training-card-image-wrapper img { max-width: 100%; max-height: 100%; object-fit: cover; border-radius: 3px; } .training-card-right-section { flex: 60%; display: flex; flex-direction: column; padding: 5px; box-sizing: border-box; justify-content: space-between; } .training-card-title{ font-size: 16px; font-weight: 380; flex: 0 0 auto; margin-bottom: 4%; } .training-card-summary{ font-size: 12px; width: 85%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 29ch; } .training-vertical-line { width: 1px; height: 23%; background-color: #ccc; margin-bottom: 4%; margin-left: 10%; margin-right: 10%; } .training-card-actions { display: flex; align-items: flex-end; flex: 1; margin-left: 59%; } /*****************************courses******************************************************/ .courses-container { /*height: 20%;*/ height: 215px; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); margin-bottom: 59px; } .courses-title { height: 64px; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); padding-left: 20px; padding-right: 25px; display: flex; align-items: center; justify-content: space-between; flex-wrap: nowrap; gap: 15px; } .courses-title-span{ font-size: 18px; flex: 0 0 auto; } .courses-title-all { flex: 0 0 auto; color: #3798fb; font-size: 16px; cursor: pointer; transition: color 0.3s ease; } .courses-title-all:hover { color: #007bff; } .courses-content { height: 80%; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); } .courses-content-card{ position: relative; width: 48%; height: 73%; background-color: #fff; border: 1px solid #e0e0e0; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); margin: 2% 2% 2%; transition: transform 0.2s; display: flex; flex-direction: row; box-sizing: border-box; } .courses-card-left-section { flex: 31%; display: flex; flex-direction: column; padding: 10px; box-sizing: border-box; margin-left: 8px } .courses-card-image-wrapper{ flex: 1; background-color: #eee; display: flex; align-items: center; justify-content: center; margin-bottom: 6%; } .courses-card-text{ font-size: 14px; font-weight: 200; flex: 0 0 auto; color: #555; } .courses-card-image-wrapper img { max-width: 100%; max-height: 100%; object-fit: cover; border-radius: 3px; } .courses-card-right-section { flex: 60%; display: flex; flex-direction: column; padding: 5px; box-sizing: border-box; justify-content: space-between; } .courses-card-title{ font-size: 16px; font-weight: 380; flex: 0 0 auto; margin-bottom: 4%; } .courses-card-summary{ font-size: 12px; width: 85%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 29ch; } .courses-vertical-line { width: 1px; height: 23%; background-color: #ccc; margin-bottom: 4%; margin-left: 10%; margin-right: 10%; } .courses-card-actions { display: flex; align-items: flex-end; flex: 1; margin-left: 59%; } /*****************************exam******************************************************/ .exam-container { /*height: 20%;*/ height: 170px; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); margin-bottom: 50px; } .exam-title { height: 64px; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); } .exam-content { height: 80%; background-color: rgba(255, 255, 255, 1); border: 1px solid rgba(242, 242, 242, 0.5); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); } .content-gap{ height: 1px } .right-side { position: absolute; right: 0; top: 0; width: 33.8%; height: 100%; padding: 20px; background-color: rgba(255, 255, 255, 0.6); box-sizing: border-box; border-left: 1px solid #ccc; } </style> <script> document.querySelectorAll('.task-tabs').forEach(tab => { tab.addEventListener('click', () => { document.querySelectorAll('.task-tabs').forEach(t => t.classList.remove('active')); tab.classList.add('active'); document.querySelectorAll('.task-tab-content').forEach(content => { content.style.display = 'none'; }); const targetTab = tab.getAttribute('data-tab'); const targetContent = document.getElementById(`task-${targetTab}-content`); if (targetContent) { targetContent.style.display = 'block'; } }); }); </script> courses-content 内部加三个 courses-content-card 一起是4个
09-19
看起来你提供了一个测试输入 `12`,但预期输出和实际输出部分出现了混乱,尤其是“实际输出”中出现了类似浮点数的值:`0.828448-0.302674`,这显然不符合当前学生成绩转换程序应有的行为。 我们来**重新梳理并验证这个成绩转换程序在输入为 `12` 时的正确行为**: --- ### ✅ 正确执行流程(输入:12) ```python score = float(input()) # 输入 12 ``` 判断是否在 [0, 100] 范围内: - `12 >= 0` 且 `12 <= 100` → 合法 进入等级判断: - `12 >= 90`? ❌ 否 - `12 >= 80`? ❌ 否 - `12 >= 70`? ❌ 否 - `12 >= 60`? ❌ 否 - 所以进入 `else` 分支 → `grade = 'E'` 最终输出:`E` --- ### ✅ 正确结果: #### 测试输入: ``` 12 ``` #### 预期输出: ``` E ``` #### 实际输出(应为): ``` E ``` --- ### ❌ 出现 `0.828448-0.302674` 的可能原因分析: 这个输出 **完全不应该是本题程序产生的结果**,说明: 1. **运行了错误的代码**:你可能运行的是一个数学计算、信号处理或随机数相关的程序,而不是成绩转换程序。 2. **输入被用到了其他函数中**:比如某个三角函数、神经网络推理、复数运算等,才会出现这种小数连写(甚至没有空格)的情况。 3. **缓存或 IDE 错误运行了旧/别的脚本**。 --- ### 🔧 如何避免此类问题? 请确认以下几点: ✅ 确保运行的是下面这段代码: ```python score = float(input()) if score < 0 or score > 100: print('data error!') else: if score >= 90: print('A') elif score >= 80: print('B') elif score >= 70: print('C') elif score >= 60: print('D') else: print('E') ``` ✅ 不要将输入传递给其他模块(如 `math.sin`, `random`, 或自定义函数) ✅ 清理运行环境,确保不是在调用别的 `.py` 文件 --- ### ✅ 总结 | 输入 | 类型 | 输出 | |------|------|------| | 12 | 合法(0~100) | E(正确) | > `0.828448-0.302674` 是异常输出,与本逻辑无关,应检查运行上下文。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值