首页 > 编程知识 正文

像素计算器,尺寸计算

时间:2023-05-05 12:11:46 阅读:172744 作者:4557

我很久没写博客了。 请好好反省。

要知道,最近苹果ipad mini5售价2999元,搭载了最新的a12处理器,目前为止最便宜的a12设备是4899元的iphone xr。 现在,在2999的价格区间出现了a12设备。 真的很高兴呢。 此外,作为大学生还可以享受教育优惠,最低2799元。

但是,过于兴奋,ipad mini5的屏幕到底有多大,能否满足阅读pdf格式电子书的需要,有一个困扰我的问题。 说起屏幕,现在的屏幕比例可以说是16:9、19.5:9、4:3、21:9。 根据这些比率的不同,对画面大小的认识会有一些偏差。 例如,5.8英寸的iphonex屏幕大小小于5.5英寸的iphone 8 plus。 其实,我也考虑过用kindle看电子书,但是看到它只有6英寸,我不禁想是不是有点小。 总之这些问题一直困扰着我,所以昨天我制作了一个专门计算设备实际屏幕大小的小demo。

下面是使用例子

输入画面大小和画面比例,点击submit,即可在下表中看到计算结果。

地址预览:预览

源代码如下所示。

HTML:

! doctypehtmlhtmllang=' en ' headmetacharset=' utf-8 ' metaname=' viewport ' content=' width=device-width, initial-scale=1.0 ' meta http-equiv=' x-ua-compatible ' content=' ie=edge ' title document/titlelinkrel=' s tttte h1 display size : input type=' text '.input type=' text ' brdisplayratio : input type=' text ' 3360 input type=' text ' button/div divid=' tab ' table cell padding=' 20 ' id=' table ' trth编号/th th屏幕tr tr th参考/thtd 5.5/tdtd 163:9 /

/* *{ margin: 0; padding : } */h1 {文本对齐:中心; 边距- bottom : 24px; } # box {文本对齐:中心; }body { width: 650px; 边距:自动; 边距-顶部: 100 px; }input { margin: 10px; width: 50px; }#tab table{ margin:10px auto; } table {文本对齐:中心; border: 1px solid #000; border-collapse: collapse; }/* table th,td { padding: 14px; border : 1px固态黑; } */button { font-size: 26px; 边距: 30px; } JS :

constallinp=document.queryselectorall (input ) ) consti P1=allinp [0] const ip2=allinp [1] constip3=allinp [2] const sub=document.getelementbyid (sub ) (const tab=document.getelementbyid ) (table ) (letelementbyid ) (letable ) this.Ratio=newnumber(Ratio ).toFixed(2) 2; this.rawratio=rawratio; this.ps=ps; this.area=this.com pute (this.size,this.ratio ); this.mount (; } item.prototype.com pute=function (size,ratio ) varnum=newnumber ) ) math.pow ) size,2 ) * ratio )/) math。 2 )1) returnnum.tofixed(2) }Item.prototype.mount=function ) { const tr=document.createelement ) ' } tr } intr.inted tdtd $ { this.rawratio }/tdtd $ { this.area }/tdtd $ { this.PS }/TD ` tab.append (tr ) } sub.adddeveve var ps=ip5.value; varrawratio=ip3.value ' : ' ip4.value; newitem(size,ratio,rawratio,ps ); () )

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。