当前位置:网站首页>使用transform:translate()出现内容模糊问题
使用transform:translate()出现内容模糊问题
2022-07-27 14:39:00 【前行的枫】

<div class="tancc" v-if="ifshow">
<div class="main">
<button class="close" @click="close()">X</button>
<ul>
<li>
<label for="name">姓名:</label>
<input type="text" id="name">
</li>
<li>
<label for="age">年龄:</label>
<input type="text" id="age">
</li>
<li>
<label for="address">地址:</label>
<input type="text" id="address">
</li>
</ul>
</div>
</div>
.tancc{
width:100%;
height:100%;
position:fixed;
background: rgba(0, 0, 0, 0.2);
top:0;
left:0;
z-index: 200;
}
.tancc .main{
width:75%;
height:67%;
color:#666;
background: #fff;
margin:0 auto;
position: absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
text-align:center;
}
内容出现了明显的模糊,去掉transform之后:
原来是transform: translate(-50%,-50%)的影响
原因:translate(-50%,-50%)计算结果出现小数
测试height:从201.0~201.9




测试结果:小数部位越接近1,输入框border越清晰
也就是说,translate(-50%,-50%)计算结果为整数时清晰度最高
解决方法:
1.元素宽高为绝对单位时
元素weidth和height设为偶数
2.元素宽高为相对单位时
计算结果不确定,使用display:flex或display:table来实现水平垂直居中效果
边栏推荐
猜你喜欢

面试重点——传输层的TCP协议

Insert sort directly

Constraints, design and joint query of data table -- 8000 word strategy + Exercise answers

CAS compares the knowledge exchanged, ABA problems, and the process of lock upgrading
![[sword finger offer] interview question 45: arrange the array into the smallest number](/img/d1/e2e21c95ecf5b8e3854f134cc47228.png)
[sword finger offer] interview question 45: arrange the array into the smallest number

网络原理(1)——基础原理概述

Addition, deletion, query and modification of MySQL table data

Six capabilities of test and development

UDP 的报文结构和注意事项

DRF学习笔记(四):DRF视图
随机推荐
__typeof和typeof的差异
Inter thread wait and wake-up mechanism, singleton mode, blocking queue, timer
QT (VI) value and string conversion
Pycharm导入已有的Project
DRF学习笔记(四):DRF视图
[regular expression] matches multiple characters
The difference between synchronized and reentrantlock
vant-ui toast和dialog使用
【云享读书会第13期】音频文件的封装格式和编码格式
借5G东风,联发科欲再战高端市场?
: 0xC0000005: 写入位置 0x01458000 时发生访问冲突----待解
[Yunxiang book club issue 13] coding format of video files
DRF学习笔记(三):模型类序列化器ModelSerializer
Spark 3.0 testing and use
The risk of multithreading -- thread safety
Under the ban, the Countermeasures of security giants Haikang and Dahua!
drf使用:get请求获取数据(小例子)
Modify spark to support remote access to OSS files
传美国政府将向部分美企发放对华为销售许可证!
CAS比较交换的知识、ABA问题、锁升级的流程