how to add shortcode in wordpress container [duplicate]

This is most likely due to the way your shortcode is constructed. PHP scripts are run on the server before (as) the HTML is generated.

Try buffering your shortcode ouput like this:

function my_function( $atts ) {
    ob_start();
    // do some stuff

    $code_output = ob_get_contents();
    ob_end_clean();

    return $code_output;
}

More info: https://secure.php.net/manual/en/book.outcontrol.php