当前位置:网站首页>使用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来实现水平垂直居中效果
边栏推荐
- 快速高效删除node_modules
- 折半插入排序
- Breaking through soft and hard barriers, Xilinx releases Vitis unified software platform for developers
- 网络设备硬核技术内幕 路由器篇 22
- Is low code the future of development? On low code platform
- Embedded development: tips and techniques -- seven techniques to meet the real-time deadline
- 多线程带来的的风险——线程安全
- 【云享读书会第13期】音频文件的封装格式和编码格式
- [sword finger offer] interview question 51: reverse pairs in the array - merge sort
- 携手SiFive,格兰仕进军半导体领域!两款自研芯片曝光
猜你喜欢

CAS compares the knowledge exchanged, ABA problems, and the process of lock upgrading

Learn parquet file format

C language: string function and memory function
![[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

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

scrapy爬虫框架

低代码是开发的未来吗?浅谈低代码平台
![[sword finger offer] interview question 50: the first character that appears only once - hash table lookup](/img/72/b35bdf9bde72423410e365e5b6c20e.png)
[sword finger offer] interview question 50: the first character that appears only once - hash table lookup

DRF学习笔记(一):数据序列化

Network principle (1) - overview of basic principles
随机推荐
[sword finger offer] interview question 42: the maximum sum of continuous subarrays -- with 0x80000000 and int_ MIN
[regular expression] matches multiple characters
Embedded development: tips and techniques -- seven techniques to meet the real-time deadline
Binder初始化过程
Understand │ what is cross domain? How to solve cross domain problems?
Live broadcast software development, customized pop-up effect of tools
初识MySQL数据库
Openwrt增加对 sd card 支持
Insert sort directly
多行文本溢出打点
[sword finger offer] interview question 51: reverse pairs in the array - merge sort
Pycharm导入已有的本地安装包
Is low code the future of development? On low code platform
Three uses of static keyword
C language: function stack frame
C语言实现字节流与十六进制字符串的相互转换
携手SiFive,格兰仕进军半导体领域!两款自研芯片曝光
Catalog component design and custom extended catalog implementation in spark3
Network principle (2) -- network development
The difference between synchronized and reentrantlock