Although it is possible for an Elector to cast his or her vote for someone other than for the popular vote winner in their state, this is quite rare in modern times. As a result, Electoral Votes for a state tend to be "all or nothing".
Maine and Nebraska have taken a slightly different approach in recent years. These states allocate two Electoral Votes to the popular vote winner, and then one each to the popular vote winner in each Congressional district (2 in Maine, 3 in Nebraska) in their state. This creates multiple popular vote contests in these states, which could lead to a split Electoral Vote.
Mathematically, the popular vote winner of a state must win at least one of the districts. That is why you cannot assign all the district Electoral Votes to the losing party in the state. Note that since these rules were adapted, Maine has never split its Electoral Votes. However, in 2008, Nebraska did for the first time, as Barack Obama won the 2nd Congressional District (Omaha and its suburbs), gaining a Democratic Electoral Vote in Nebraska for the first time since 1964.