mercury0114 mercury0114 - 1 year ago 121
HTML Question

How to position iframe (calendar) inside php echo statement?

I am trying to place a calendar on the top right corner of my page:

echo 'other html 1';
echo 'other html 2';

// Calendar
echo '<iframe
style = "border: 0;
position: absolute;
width: 500; // This does not have any effect, why?
height: 500; // This does not have any effect, why?
top: 160px; // This does not have any effect, why?
frameborder: 0;
scrolling: no;">

The calendar is displayed and I can alternate its size, but I can't figure out how to move it to an arbitrary position. It always appears below other html code regardless of what I'm doing.

Note that:

  • I can't change php to html file, as this page is part of a larger system

  • I don't want to rely on other echo statements. It would be nice to fix this without the need of figuring out what's happening in rest of that file.

  • I would be happy to move style things specific to
    out to a separate css file.

How to place
wherever I want?

Answer Source

Since you are positioning your iframe, you should use position property and as you want your iframe appearing top right corner of the page then you should also use top and right properties to achieve this result


            echo '<iframe 
                  style = "
                  border: 0;
                  position: absolute;
                  display: block;
                  width: 500px;                  
                  height: 500px;             
                  top: 0px; 
                  right: 0px;
                  frameborder: 0; 
                  scrolling: no;">

Checkout the following link CSS position property

Note : since iframe is an old thing in html, there are so many attributes are deprecated. You should better take a look at those at the following page Iframe Tag

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download