E: Oh sorry this is a bit of a title gore, hope it's still legible.
This older thread might be worth a look.
There seems to be a lot of confusion regarding this question and many answers flying about so I will attempt to bring it all together. As with all borders in Europe, this is a complicated topic so I will try to keep it as simple as possible while touching on all the important issues which led to the modern borders. The main factors which have influenced the changing shape of the borders have been ethnic, religious and cultural divisions, political interests, and wars.
When talking about borders and geography in general i find that seeing a map is much more effective than trying to visualize it in your head.
Map 2 - The Kingdom of Croatia. This is roughly the area that was controlled by King Tomislav 910-915, the first King of Croatia.
Map 3 - Kingdom of Croatia in 1102. This date is important as the last King died without an heir, leading to a personal union with Hungary which lasted until the end of WWI.
Map 4 - Croatia in 1526. The green on the map shows the Ottoman advance into modern day Bosnia, the red is the territory controlled by Venice. The Republic of Ragusa (Dubrovnik) is an independent state from Croatia at this point. The Ottomans would continue to advance into Europe. The Austrians created the Croatian Military Frontier as a defense against the Ottomans (the map jumps ahead but the frontier was created in 1553).
Map 5 - Croatia in the Austro-Hungarian Empire 1918 Notice that there are 3 names, Hrvatska (Croatia), Slavonija (Slavonia) and Dalmacija (Dalmatia). This was known as the Triune Kingdom as the 3 separate kingdoms together formed the Kingdom of Croatia. The King of Austria was also crowned as the King of Croatia.
The 20th century is very messy.
Map 6 - The Kingdom of Serbs, Croats and Slovenes After WWI and the dissolution of the Austro-Hungarian Empire the Slovene and Croatian lands join the Kingdom of Serbia to create a unified kingdom with the Serbian King as the monarch. This map shows the division of territories, banovinas, within the new state.
Map 7 - The Kingdom of Yugoslavia 1929 The Banovina of Croatia is formed to incorporate the Hercegovinian lands where the majority of the population was Croatian while Srijem, where the majority was Serbian, is given to the Dunavska Banovina. This was done as the Croatians wanted to unify Croatian lands within the Kingdom, along with wanting more autonomy.
Map 8 - The Independent State of Croatia (NDH) This was a fascist puppet state created by the Nazis. This was the most extreme and terrible form of Croatian nationalism. The territory claimed by the state was similar in size to the territory in Map 2 of the Kingdom of Croatia. The fascists promoted the idea that these were Croatian lands and that they must be under Croatian control and populated by Croatians. Notice that there is no Istria and several major coastal cities which were under Italian control.
Map 9 - The Socialist Federal Republic of Yugoslavia Within Yugoslavia there were 6 federal states and 2 autonomous provinces. The state boundaries were finally official drawn up and they resemble closely todays borders.
I wont go into the modern war as that is a topic of its own and this has already gotten pretty long and maybe a bit off topic. Croatia still has many border disputes with its neighbors. Slovenia to the north, with Serbia along the Danube (there is even a micro nation which claimed a small piece of land that neither Croatia or Serbia claimed), with Montenegro in the south and with Bosnia regarding some peninsulas near Neum. Understanding the historical context of the area is essential to understanding why these issues are important and shows how far back they go.