You're probably looking for The Fantastic Dinosaur Adventure, a youth novel by Gerald Durrell, first published in 1989.
This is a sequel to the novel The Fantastic Flying Journey by the same author. In the first book, Uncle Lancelot takes his nephews on a journey around the globe in a hot air balloon. The uncle is an inventor who's built the hot air balloon himself, called Belladonna, with some fantastic capabilities, such as an unrealistically large board with fruit trees on board providing food and trained electric eels providing power. He also invented a magical green powder that lets humans understand and speak with animals. This ability helps with the educational content that this book is sprinkled with (just like many other Durrell books are). There are three nephews: a pair of twin boys of age 12, and a girl aged 15. The mother is reluctant to let the boys on the journey, because Lancelot is very unreliable as a guardian and a total mad scientist archetype, plus the children would be missing school, and from what we learn from the book, she's totally right.
In The Fantastic Dinosaur Adventure, the book you have probably read, the uncle returns to take the three children for a new voyage. This time he's upgraded the hot air ballon with a time machine that he's invented himself. A pair of criminals have stolen the time machine, and are using it to travel back to the age of dinosaurs. The criminals are depicted as stereotypical villains with no redeeming qualities. They're planning to capture dinosaurs, bring them to the present time, and get rich from selling them. The criminals however, haven't realized that the time machine they stole is lacking a crucial component, and because of that, it can only travel back in time, not forwards, so they're stuck in the past. The uncle builds a new time machine from his plans, and decides that he must chase the criminals into the past and catch them, and worse, take the children with them for that dangerous journey. The four of them travel back to the triassic age at first, then the jurassic age and finally the cretaceous age to follow the criminals.
During the journey, they use the magical green powder again to talk to dinosaurs, befriending some of them and barely escaping some others. In the jurassic age, the oldest child Emma is captured alive by a gnathosaurus, a flying dinosaur, who decides that she'll be suitable as food for her foals and takes her to her nest. Luckily the foals are unwilling to eat her. She's eventually rescued from the nest by a dinosaur they helped earlier. However, one of the gnathosaurus foals is curious and decides to follow Emma. When they return to the airship, Emma names the gnathosaurus foal Albert, and gives it sardines from a tin. Albert enjoys the sardines so much that she isn't willing to eat anything else after that, and decides to stay with the protagonists because of that.
The criminals have captured and subdued the two boys. They are preparing to kill them by tying them to a tree and luring a tyrannosaurus and eat them. The other two protagonists team up with multiple different type of dinosaurs, convincing each of them that the criminals are dangerous and hunting for them. Together they free the boys and eventually defeat the criminals. They free all the dinosaur foals that the criminals have captured, return them to their respective homes. The protagonist return to the present time with the criminals, Albert the gnathosaurus, and a diplodocus foal. Lancelot becomes famous as the inventor of the time machine, proving himself with the two live dinosaurs. He decides to keep the time machine for himself because he believes the world is not ready for it yet, but becomes rich from marketing deals where the two dinosaurs advertise sardines and fruit respectively. The criminals are sent to prison, but later escape. I'm not making any of that up, it's just this sort of book.
I've read this book in the Hungarian translation published by Park Könyvkiadó Kft. in 1990. The book has illustrations by Graham Percy which I believe are from the original edition. I show one below, showing the protagonists and the two dinosaur foals. There's no illustration showing the sardines in particular, they only appear in the text. (The colors don't match well, but the strange patterns come from the illustration and its medium quality color printing in the book, they're not scanning artifacts.)