屏幕实际尺寸计算器

屏幕实际尺寸计算器很久没写博客了 要好好反省一下

大家好,欢迎来到IT知识分享网。

很久没写博客了,要好好反省一下。

最近,苹果在商店悄无声息地上架了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 就可以在下面的表格看到计算结果了。
预览地址:预览

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="./style.css">
</head>

<body>
    <div id="box">
        <h1>screen compute</h1>
        display size : <input type="text"> . <input type="text"><br>
        display ratio : <input type="text"> : <input type="text"><br>
        postscript : <input type="text"><br>
        <button id="sub">submit</button>
    </div>
    <div id="tab">
        <table cellpadding='20' id="table">
            <tr>
                <th>编号</th>
                <th>屏幕尺寸</th>
                <th>宽长比</th>
                <th>实际面积</th>
                <th>基准</th>
                <th>备注</th>
            </tr>
            <tr>
                <th>参考</th>
                <td>5.5</td>
                <td>16:9</td>
                <td>12.93</td>
                <td>100%</td>
                <td>iPhone8 plus</td>
            </tr>
        </table>
    </div>
    <script src="./index.js"></script>
</body>

</html>

CSS :

/* *{ margin: 0; padding: 0 } */ h1 { text-align: center; margin-bottom: 24px; } #box { text-align: center; } body { width: 650px; margin: auto; margin-top: 100px; } input { margin: 10px; width: 50px; } #tab table{ margin:10px auto; } table { text-align: center; border: 1px solid #000; border-collapse: collapse; } /* table th,td { padding: 14px; border: 1px solid black; } */ button { font-size: 26px; margin: 30px; } 

JS :

const allinp = document.querySelectorAll('input') const ip1 = allinp[0] const ip2 = allinp[1] const ip3 = allinp[2] const ip4 = allinp[3] const ip5 = allinp[4] const sub = document.getElementById('sub') const tab = document.getElementById('table') let index = 0; function Item(size, ratio, rawratio, ps) { this.size = size; this.ratio = new Number(ratio).toFixed(2); this.rawratio = rawratio; this.ps = ps; this.area = this.compute(this.size, this.ratio); this.mount(); } Item.prototype.compute = function (size, ratio) { var num = new Number((Math.pow(size, 2) * ratio) / (Math.pow(ratio, 2) + 1)) return num.toFixed(2) } Item.prototype.mount = function () { const tr = document.createElement('tr'); tr.innerHTML = ` <th>${index++}</th> <td>${this.size}</td> <td>${this.rawratio}</td> <td>${this.area}</td> <td>${((this.area/12.93)*100).toFixed(2) + '%'}</td> <td>${this.ps}</td> ` tab.append(tr) } sub.addEventListener('click', function () { var size = (+ip1.value) + (ip2.value / 10); var ratio = (ip3.value) / (ip4.value); var ps = ip5.value; var rawratio = ip3.value + ':' + ip4.value; new Item(size, ratio, rawratio, ps); }) 

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/135292.html

(0)
上一篇 2025-07-05 19:45
下一篇 2025-07-05 20:00

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信