Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make an iframe to be 100% width of its container

Tags:

html

css

iframe

Okay so I would like this iframe to fill 100% of it's parent div which is wrapper with width 900 px and for some reason I'm unable to get this done

HTML

<fieldset>
  <legend>Random Patch:</legend>
  <iframe src="../../index.php?Patch_No='.$patches[$patch].'" frameborder="0" ></iframe>
</fieldset>';

CSS update the syntax is like that in code but still doesn't work I got confused with html for a second here is how it looks: http://i.imgur.com/9Jv5sFz.png

iframe {
   width: 100%;
   height: 500px;
}

UPdate 2 whole html

<body>
    <div id="wrapper">
        <header>
            <div id="menu"> <a href="new_patch/new_champions.php" id="new">NEW</a>
                <!-- Editing patches still in works href="edit_patch.php" -->
                <a id="edit" style="color: grey;" alt="Edit" title="Disabled still in works.">EDIT</a>
                <a href="delete_patch.php" id="delete">DELETE</a>
                <a href="logout.php" id="logout">LOGOUT</a>
            </div>
        </header>
        <div id="sitelive">
            <?php
            //Generating random patch from DB
            $sql="SELECT Patch_No FROM info";
            $result=$ conn->query($sql);
            $patches=$result->num_rows;
            if($patches!=0) {
                $patch = rand(1, $patches);
                $i = 1;
                $patches = array();
                while($data=$result->fetch_assoc()){
                    $patches[$i] = $data['Patch_No'];
                    $i+=1;
                }
                echo '
                <fieldset>
                    <legend>Random Patch:</legend>
                    <iframe src="../../index.php?Patch_No='.$patches[$patch].'" frameborder="0" height="500" width="100%" scrolling="no"></iframe>
                </fieldset>';
            } ?>
        </div>
    </div>
</body>
like image 710
Higeath Avatar asked Mar 11 '15 12:03

Higeath


2 Answers

Change your CSS like this: Updated Demo

iframe {
    width:100%;
    height:500px;
}
fieldset, legend {
    margin:0;
    padding:0;
    width:100%;
    height:100%;
}

HTML:

<fieldset>
    <legend>Random Patch:</legend>
    <iframe src="../../index.php?Patch_No='.$patches[$patch].'" frameborder="0"></iframe>
</fieldset>

Hope this is what you want..

like image 170
G.L.P Avatar answered Oct 09 '22 20:10

G.L.P


Your CSS syntax seems to be faulty

I think this will solve it:

iframe {
  width:100%;
  height:500px;
}
like image 27
Albin Avatar answered Oct 09 '22 19:10

Albin