• Resolved frostybaggins

    (@frostybaggins)


    For some reason, any div with a width of 100% will only fill half the content area on desktop. I created a shortcake that is registered from my plugin, which adds divs to the given content filled with data retrieved from another server. This is occurring on both Safari and Firefox.

    If the screen is at a mobile width where the theme responds to mobile, it behaves normally. Anything else, and it fills to half.

    This is my plugin’s function as well as the add_shortcode at the bottom.

    function get_church_notices($content = null)
    {
    try {
    $sdk = new Aws\Sdk([‘region’ => ‘ap-southeast-2’, ‘version’ => ‘latest’,
    ‘credentials’ => [‘key’ => ‘[mykey]’, ‘secret’ => ‘[mysecret]’ ]]);
    $lambda = $sdk->createLambda();
    $result = $lambda->invoke([‘FunctionName’ => ‘[myfunctionname]’, ‘InvocationType’ => ‘RequestResponse’]);
    $payload = $result->get(‘Payload’);

    $array = json_decode($payload);

    if (empty($array)){
    $content .= “” . __(“No notices to display.”) . ““;
    return $content;
    }

    else{
    $content .= ”
    <style>
    #defaultParagraph {
    color: dimgray;
    }

    #defaultDiv {
    border-radius: 20px;
    border-width: 20px;
    background-color: #f0f0f0;
    border-color: black;
    padding: 15px;
    display: flex;
    stroke-width: 5px;
    float: right;
    }

    #noticeColumn{
    flex: 50%;
    }

    #defaultHeader{
    color: #0084ff;
    margin: 3px 0;
    }
    </style>”;

    foreach($array as $notice){
    $datePublished = strtotime($notice->DatePublished);
    $formattedDate = date(‘j/m/y’, $datePublished);

    $content .= “<br>
    <div id=’defaultDiv’>
    <div id=’noticeColumn’>
    <h2 id=’defaultHeader’>Title</h2>
    <p style=’font-weight: bold’ id=’defaultParagraph’>{$notice->Title}</p>
    </div>

    <div id=’noticeColumn’>
    <h2 id=’defaultHeader’>Message</h2>
    <p id=’defaultParagraph’>{$notice->Message}</p>
    </div>

    <div id=’noticeColumn’>
    <h2 id=’defaultHeader’>Date Published</h2>
    <p id=’defaultParagraph’>{$formattedDate}</p>
    </div>
    </div>

    <div style=’width: 200%; background-color: red’><p>Test</p></div>”;
    }

    return $content;
    }
    }

    catch(LambdaException $error) {
    $message = $error->getMessage();
    return “Failed to retrieve notices: ” . $message;
    }

    catch(Exception $error){
    return “Uh oh! An error has occurred!” . $error->getMessage();
    }
    }

    add_shortcode(‘church_notices’, ‘get_church_notices’);`

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Please post a link to the page where this behavior occurs.

    Best regards,
    Dumitru B.

    Thread Starter frostybaggins

    (@frostybaggins)

    I found that this was due to the default template in use. I feel this default template should have some more description of what it does.

    I’m glad that you have found your answer.
    But how and where would the default page template be better described? Where exactly would the description go?

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Div width at 100%, but only fills half the content area’ is closed to new replies.