css调试方法_如何通过二等分来调试CSS

css调试方法

I had this problem today.

我今天有这个问题。

I added the Paddle button to my new online course page, so people could click the “Buy now” button and the nice Paddle popup would show up.

我在新的在线课程页面上添加了Paddle按钮,因此人们可以单击“立即购买”按钮,然后会显示漂亮的Paddle弹出窗口。

The popup has a loading indicator, a circle with a spinner inside, and there was an issue: when clicking the “Buy now” button, the spinner indicator was not centered inside the circle, as show in this gif:

弹出窗口中有一个加载指示器,里面是一个带有微调框的圆,这是一个问题:单击“立即购买”按钮时,微调框指示器未居中于圆的中心,如以下gif所示:

I didn’t really know what was causing the issue, so I was thinking how to solve it.

我真的不知道是什么引起了这个问题,所以我在考虑如何解决它。

The principle I use in these cases is bisect. I also call it divide et impera.

我在这些情况下使用的原理是二等分的 。 我也称它为分裂与不平等

I opened the DevTools and moved to the Sources panel, which showed all the files loaded in the page. I searched for one of my CSS files, as my intuition was that the page CSS was interfering with the Paddle own CSS rules.

我打开DevTools并移至“源”面板,该面板显示了页面中加载的所有文件。 我搜索了我CSS文件之一,因为我的直觉是CSS页面干扰了Paddle自己CSS规则。

So I removed all the content of that file.

因此,我删除了该文件的所有内容。

Chrome automatically changes the appearance of the page when you alter the CSS files in the Sources panel, so I was able to check and see that the spinner was now working fine!

当您在“源”面板中更改CSS文件时,Chrome会自动更改页面的外观,因此我能够检查并看到微调器现在工作正常!

So, one of the rules in that CSS is the problem.

因此,CSS中的规则之一就是问题。

How do I find out which line?

我如何找出哪条线?

The file has 312 lines. I select from line 150 to 312 and delete it. Try again. The problem is still there, so it must originate from the first 149 lines.

该文件有312行。 我从第150到312行中选择并删除它。 再试一次。 问题仍然存在,因此它必须起源于前149行。

I hit cmd-Z (undo) to put back those lines I removed, and delete lines 70-149.

我按下cmd-Z( undo )以放回我删除的那些行,并删除第70-149行。

The problem is gone, so the problematic line is in there. I hit cmd-Z again to restore the lines I deleted.

问题解决了,所以问题线就在那里。 我再次点击cmd-Z以恢复删除的行。

And so on, you got the idea. Rinse and repeat until you find the line that gives you the problem.

依此类推,您明白了。 冲洗并重复直到找到出现问题的线。

翻译自: https://flaviocopes.com/css-debugging-bisect/

css调试方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值