Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make an html page automatically fit mobile device screens?

I am putting a Formidable Form on an html page by using an <iframe>, but I'd like it to be full screen on a mobile device. So far I'm using the following code:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <style>
  @import url(http://fonts.googleapis.com/css?family=Londrina+Sketch);

  body {
  background-color: #f3eedd;
  width: 750px;
  overflow:scroll;
    overflow-x:hidden;
  }

h2 {
    font-size: 20px;
    color: #c13e18;
    margin: 10px 30px 10px 30px;
}

</style>
</head>
<body>
<div id="header">
<h2>Book Supheroes Unite</h2>
</div>
<div id="form">
<iframe src="http://challenge-the-box.com/wp-admin/admin-ajax.php?action=frm_forms_preview&form=sbyrt02
" frameborder="0" scrolling="no" style="width:280px;height:535px;"></iframe></div>
</html>

I believe it has something to do with viewports? However, I'm not entirely sure on this!

like image 366
Marc Avatar asked Sep 25 '15 12:09

Marc


1 Answers

<meta name="viewport" content="width=device-width, initial-scale=1.0">

This meta tag allows you to target mobile devices and sets the width to the screen size.

Documentation provided here!

Also consider migrating to bootstrap a CSS framework for Responsive web design! Twitter Bootstrap

like image 151
Chris Avatar answered Oct 31 '22 08:10

Chris