父级元素宽高为奇数时,绝对定位的right和bottom会有1px的偏差
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> .box{ width: 401px; height: 401px; background: red; position: relative; } .content{ width: 200px; height: 200px; background: blue; position: absolute; right: 0; bottom: 0; } </style> </head> <body> <div class="box"> <div class="content"></div> </div> </body> </html>
IE6显示效果如下:
解决方案:避免设置父级元素的宽高为奇数
时间: 2024-10-20 00:27:22