Same with me, I am easily distracted when I use online resources.
Personally I find there are pros and cons to any method of learning. With online learning, being surrounded and distracted by such a wealth of knowledge on every link you click, the pros are you can get ideas and learn how to think more like a coder (for coders, respectively).
But if I really want to focus on a project or something new, I'll download the resources, even if it's a webpage (which I'll either save as offline, or print to PDF, or use a tool like devdocs.io which can be used offline) and then disconnect the modem.
Even if there's something I need to know, like a definition of a word, I'd keep it in a memo, and look it up after I spent at least 1-3 hours on the offline project. I learnt that this is an excellent method to keep your focus on something, get it deep set into your memory, and gain a proper understanding on the subject.
I've been learning this way for the past 2 years and although it's frustrating to be offline (at times you might feel a bit 'chained down' cause the windows are closed/resources are restricted) but it's been a wonderful experience :-)
You'll notice the difference if you try it out for some time!