当前位置:网站首页>搜索框和按钮缩放时会有缝隙的bug
搜索框和按钮缩放时会有缝隙的bug
2022-07-01 15:42:00 【崽崽的谷雨】
问题描述:
做一个类似于 百度的搜索框时,浏览器 100% 没什么问题,但是缩放到175% 时按钮和input会出现缝隙。
100%效果图

175%效果图

如上图:明显能看出 有空白的缝隙
产生这个的原因是:当缩放到175%时,应该1.75格代表1像素,但由于硬件层次限制,比如一格用四个物理像素点绘制,0.25格就不绘制,故1.75格中的0.75,只能用三格绘制,未绘制的一格产生了空隙(css 页面缩放边框产生空隙相关)
如果是 按钮和 input 之间有缝隙 且对不齐 可以参考:input输入框和button确定按钮之间的默认间距问题
代码如下:
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div class="search">
<input type="search" name="" id="" placeholder="搜索" />
<button>搜索</button>
</div>
<style type="text/css">
.search {
position: absolute;
top: 25px;
left: 346px;
width: 534px;
height: 32px;
border: 2px solid #b1191a;
}
.search input {
float: left;
padding-left: 10px;
width: 454px;
height: 32px;
vertical-align: middle;
border: none;
outline: none;
}
.search button {
float: left;
width: 80px;
height: 32px;
background-color: #b1191a;
color: #f8f7f7;
border: none;
}
</style>
</body>
</html>解决方案:
1.可以给 button 加一个 outline:1px solid xxx ;
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div class="search">
<input type="search" name="" id="" placeholder="搜索" />
<button>搜索</button>
</div>
<style type="text/css">
.search {
position: absolute;
top: 25px;
left: 346px;
width: 534px;
height: 32px;
border: 2px solid #b1191a;
}
.search input {
float: left;
padding-left: 10px;
width: 454px;
height: 32px;
vertical-align: middle;
border: none;
outline: none;
}
.search button {
float: left;
width: 80px;
height: 32px;
background-color: #b1191a;
color: #f8f7f7;
border: none;
outline: solid 1px #b1191a;
}
</style>
</body>
</html>100%效果图:

175%效果图

边栏推荐
猜你喜欢

软件测试的可持续发展,必须要学会敲代码?

What is the forkjoin framework in the concurrent programming series?

Short Wei Lai grizzly, to "touch China" in the concept of stocks for a living?

异常检测中的浅层模型与深度学习模型综述(A Unifying Review of Deep and Shallow Anomaly Detection)
![[STM32 learning] w25qxx automatic judgment capacity detection based on STM32 USB storage device](/img/41/be7a295d869727e16528041ad08cd4.png)
[STM32 learning] w25qxx automatic judgment capacity detection based on STM32 USB storage device

One revolution, two forces, three links: the "carbon reduction" roadmap behind the industrial energy efficiency improvement action plan
![[300 + selected interview questions from big companies continued to share] big data operation and maintenance sharp knife interview question column (III)](/img/cf/44b3983dd5d5f7b92d90d918215908.png)
[300 + selected interview questions from big companies continued to share] big data operation and maintenance sharp knife interview question column (III)

【STM32学习】 基于STM32 USB存储设备的w25qxx自动判断容量检测

Zero copy technology of MySQL

Hardware design guide for s32k1xx microcontroller
随机推荐
Samsung took the lead in putting 3nm chips into production, and Shanghai's fresh master students can settle directly. Nankai has established a chip science center. Today, more big news is here
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
有些能力,是工作中学不来的,看看这篇超过90%同行
S32K1xx 微控制器的硬件設計指南
软件测试的可持续发展,必须要学会敲代码?
MySQL backup and restore single database and single table
Wechat applet 01 bottom navigation bar settings
【云动向】6月上云新风向!云商店热榜揭晓
STM32F411 SPI2输出错误,PB15无脉冲调试记录【最后发现PB15与PB14短路】
Some abilities can't be learned from work. Look at this article, more than 90% of peers
Go zero actual combat demo (I)
Stm32f4-tft-spi timing logic analyzer commissioning record
你TM到底几点下班?!!!
Overview | slam of laser and vision fusion
TensorFlow團隊:我們沒被拋弃
One revolution, two forces, three links: the "carbon reduction" roadmap behind the industrial energy efficiency improvement action plan
Qt+pcl Chapter 6 point cloud registration ICP Series 2
七夕表白攻略:教你用自己的专业说情话,成功率100%,我只能帮你们到这里了啊~(程序员系列)
张驰课堂:六西格玛数据的几种类型与区别
ABAP-屏幕切换时,刷新上一个屏幕