【消灭代办】第5周 - null拷贝,input自适应,进度条加载,颜色随机值
2018.12.10 代办一:javascript中js怎么拷贝null的值
null属于简单类型的数值,直接进行拷贝即可:

2018.12.11 代办二:怎么让input自适应宽度?
这样是写下代办不久后看到的一个面试题
解法一:flex:

<div class="box">
<input type="text">
<button>按钮</button>
</div>
.box{
background: rgb(218, 255, 184);
padding: 5px;
display: flex;
align-items: center;
justify-content: space-between;
}
input{
flex: 1;
}
button{
width: 80px;
}
解法二、float布局

<div class="box">
<button>按钮</button>
<div class="input-box">
<input type="text">
</div>
</div>
.box{
background: rgb(218, 255, 184);
padding: 5px;
/* display: flex;
align-items: center;
justify-content: space-between; */
}
.input-box{
width: 100%;
margin-left: 80px;
}
input{
width: 100%;
/* flex: 1; */
}
button{
width: 80px;
float: left;
}
解法三、float+margin负边距

<div class="box">
<div class="input-box">
<input type="text">
</div>
<button>按钮</button>
</div>
.box{
background: rgb(218, 255, 184);
padding: 5px;
/* display: flex;
align-items: center;
justify-content: space-between; */
}
.input-box{
float: left;
width: 100%;
margin-right: -80px;
}
input{
width: 100%;
border: 1px solid #eee;
padding: 5px 90px 4px 10px;
box-sizing: border-box;
/* flex: 1; */
}
button{
width: 80px;
}
padding-right: 90是为了留出按钮的位置,不让按钮挡住文字。

解法四、定位布局

<div class="box">
<div class="input-box">
<input type="text">
</div>
<button>按钮</button>
</div>
.box{
background: rgb(218, 255, 184);
padding: 5px;
/* display: flex;
align-items: center;
justify-content: space-between; */
position: relative;
height: 40px;
}
.input-box{
/* float: left;
width: 100%;
margin-right: -80px; */
position: absolute;
left: 0;
right: 80px;
}
input{
width: 100%;
border: 1px solid #eee;
/* padding: 5px 90px 4px 10px; */
padding: 5px 10px;
box-sizing: border-box;
/* flex: 1; */
}
button{
width: 80px;
position: absolute;
right: 0;
}
2018.12.12 代办三:原生js实现进度条加载 - 数字逐步变化的那种
看到一个demo,原理是定时器+递归。觉得很不错,整理到这里:
<div class="demo">
<form name=loading>
<p style="font-size:18px;"> 欢迎访第九站长!<a style="color:#3366cc;" href="http://www.dijiuzhanzhang.com">http://www.dijiuzhanzhang.com</a></p>
<p><input name="chart" size="46" style="color:#ff897c;" /></p>
<p><input name="percent" size="46" style="color:gray;text-align:center;" /></p>
</form>
</div>
*{margin:;padding:;list-style-type:none;}
a,img{border:;}
body{font:12px/180% Arial, Helvetica, sans-serif, "新宋体";}
.demo{width:750px;margin:40px auto;text-align:center;}
.demo p{height:38px;line-height:28px;}
.demo p input{border:none;background:none;font-family:arial;font-weight:bolder;}
<script type="text/javascript">
var bar = 0
var line = "||"
var amount ="||"
count()
function count(){
bar= bar+2
amount =amount + line
document.loading.chart.value=amount
document.loading.percent.value=bar+"%"
if(bar<99){
setTimeout("count()",100);
}else{
window.location = "http://www.dijiuzhanzhang.com";
}
}
</script>
转自:http://www.dijiuzhanzhang.com
1、他是通过js一次性定时器+递归不断向percent结构中添加"|"元素:

2、标签上有name属性,然后通过
document.loading.chart.value
这种形式,获取input的value的方式也是很别致。
3、input内部创建了一个div的场景也是第一次遇见。
看来第2条那种写法,还很值得研究啊。
2018.12.13 代办四:随机生成颜色值
第一种
function randomColor() {
let colorArr = ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'],
newColor = '#';
for (var i = 0; i < 6; i++) {
newColor += colorArr[Math.floor(Math.random() * 15)]
}
console.log(newColor);
return newColor
}
randomColor()
第二种
function getRandomColor() {
return "#" + ("00000" + ((Math.random() * 16777215 + 0.5) >> 0).toString(16)).slice(-6);
}
说明:
1、16777215为16进制的颜色ffffff转成10进制的数字
2、>>数字取整
3、转成16进制不足6位的以0来补充
【消灭代办】第5周 - null拷贝,input自适应,进度条加载,颜色随机值的更多相关文章
- qt 拷贝文件设置进度条
/** * @brief FuncModuleWin::copyFile * @param fromFIleName 优盘里面的文件 * @param toFileName 拷贝到/bin里面的启动文 ...
- delphi CopyFileProgressBar 拷贝文件显示进度条
CopyFileProgressBar(pwidechar(ListBox1.Items.Strings[I]),pwidechar(NewDir+'\'+ExtractFileName(ListBo ...
- 【消灭代办】第1周 - 敏感词判断、图片206、parseInt
11.16代办一:[敏感词判断] 代办描述: 一堆字符串组成的数组,给你一个字符串,让你去查找这个字符串是否在这个数组当中? 关键考点: 数组匹配,看一个数组中有没有这个字符串. 解决思路: 遍历数组 ...
- JVM加载类冲突,导致Mybatis查数据库返回NULL的一个小问题
今天碰到个bug,虽然小,但是有点意思 背景是SpringMVC + Mybatis的一个项目,mapper文件里写了一条sql 大概相当于 select a from tableA where b ...
- js中对arry数组的各种操作小结 瀑布流AJAX无刷新加载数据列表--当页面滚动到Id时再继续加载数据 web前端url传递值 js加密解密 HTML中让表单input等文本框为只读不可编辑的方法 js监听用户的键盘敲击事件,兼容各大主流浏览器 HTML特殊字符
js中对arry数组的各种操作小结 最近工作比较轻松,于是就花时间从头到尾的对js进行了详细的学习和复习,在看书的过程中,发现自己平时在做项目的过程中有很多地方想得不过全面,写的不够合理,所以说啊 ...
- js实现动态加载input 提示信息
思路:使用<datalist> 标签定义选项列表.请与 input 元素配合使用该元素,来定义 input 可能的值.datalist 及其选项不会被显示出来,它仅仅是合法的输入值列表.请 ...
- vant 使用field组件加载页面就触发input事件的坑,已解决
使用vant的时候,遇到一个坑,加载组件就自动触发input事件,input事件里写了验证,导致已加载就验证错误 原因:v-model绑定的时候写的是null, filed组件接收的时候把他转换成空字 ...
- input文本框设置和移除默认值
input文本框设置和移除默认值 这里想实现的效果是:设置和移除文本框默认值,如下图鼠标放到文本框中的时候,灰字消失. 1.可以用简单的方式,就是给input文本框加上onfocus属性,如下代码: ...
- System.BadImageFormatException : 未能加载文件或程序集“Medici.PaymentRecover, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。试图加载格式不正确的程序。
System.BadImageFormatException : 未能加载文件或程序集“xxxxx.xxxxx, Version=1.0.0.0, Culture=neutral, PublicKey ...
随机推荐
- 在Ubuntu1404的64bit版本下安装caffe
原创文章,未经允许不要转载 想安装很久了,一直到这时才开始安装,我是笔记本华硕FL5800L的,所以配置比较低.在win7 64位里面先装个vmware 12 pro,然后装了个Ubuntu140 ...
- 防止APACHE解析漏洞
一.PHP端,规范代码,加强尾缀验证 二.Apache端,在httpd.conf中加上如下代码: <Files~"\.(p|P)(h|H)(p|P)."> Deny f ...
- django生产环节部署
在linux下安装mysql yum install mysql-server mysql -u root(安装完后,你的root账户是没有密码的.所以你可以直接使用这条命令,就可以登陆控制台了) 如 ...
- 介绍三款串口监控工具:Device Monitoring Studio,portmon,Comspy
在开发上位机下位机通讯程序时,有一个好的监控工具会事半功倍.特在网上找了几款串口监控软件,作了简单对比: 一.Device Monitoring Studio 网址:http://www.hhdsof ...
- VS2008 编译出错 fatal error C1859: unexpected precompiled header error, simply rerunning the compiler might fix this problem
https://jingyan.baidu.com/article/d8072ac49ebd23ec95cefddd.html
- 利用StringEscapeUtils来转义和反转义html/xml/javascript中的特殊字符
我们经常遇到html或者xml在Java程序中被某些库转义成了特殊字符. 例如: 各种逻辑运算符: > >= < <= == 被转义成了 == ...
- CSS单行格式化与压缩
工具简介:CSS单行格式化与压缩工具
- Switch语句的参数是什么类型的?
在Java5以前,switch(expr)中,exper只能是byte,short,char,int类型. 从Java5开始,java中引入了枚举类型,即enum类型. 从Java7开始,exper还 ...
- .net core 2.0+superui +Dapper.SimpleCRUD+mysql+NLog
**_ .net core 2.0+superui +Dapper.SimpleCRUD+mysql+NLog _** 前端框架 superui http://www.supermgr.cn/ 1.组 ...
- Unity应用架构设计(10)——绕不开的协程和多线程(Part 1)
在进入本章主题之前,我们必须要了解客户端应用程序都是单线程模型,即只有一个主线程(Main Thread),或者叫做UI线程,即所有的UI控件的创建和操作都是在主线程上完成的.而服务器端应用程序,也就 ...