Shortcode displaying outside the div [duplicate]

You could put all the html in a variable and return it

$r = "<div id=\"" . $s['id'] . "\"..."; 
if (!empty($s['fb'])) {
$r .= "<a href=\" . $s['fb'] . "...";
}
$r .= "title=\"Follow Us On Facebook\" ";
$r .= "target=\"_blank\" ";  
return $r;

But every shortcode on your site should do this, for them to appear in the right order. As soon as one starts echoing things, it could mess up the order.