so on my registration .php screen, i have a form in that phone a table, in the table there is 2 columns and about 5 rows the table basically set out like this ...
| First Name | Last Name |
| Username | verifier* |
| Password | Verifier* |
| Retype Pass| Verifier* |
| City | Country |
|GenderSelect|DateOfBirth|
| ClearBtn | SubmitBtn |
So that's the original form, on the larger screen so I'm using Bootstrap v3.1.1, so it has responsive web desgin built in, but when i use a tablet and smartphone, i just cant work out how to get the form to appear in a specific way, in a perfect situation, i would get rid of the table, and have just the form
. id have each input
field on a single line, then a <br>
and where i have the verifiers, to check if the username is already in the system, if the email is currently registered part of the db, and if the password is at a decent strength to avoid people accessing your account. So the verifiers sit in the same line as the input field with just a space between them.
an ideal situation for me would be as simple as...
if (screen size is < x && > y) {
include 'includes/reg/form1';
}
if (screen size is < y) {
include 'includes/reg/form2';
}
but im guessing it wont be as easy as that, does anyone have any suggestions that could help with this??
PHP does not have a way of detecting screen size. It is a server side language only. However, you could do what you want in JavaScript. If the screen is a certain size, show one form and hide the other, and vice versa.
JavaScript example:
var browserWidth = window.innerWidth;
if (browserWidth < x && browserWidth > y) {
//Show this form
}
else if (browserWidth < y) {
//show this form
}
If you don't want to use JavaScript, you can use media queries.
Here is a great explanation / tutorial:
This is what a CSS media query would look like:
/*CSS Media Query for a tablet device*/
@media only screen and (min-width:481px) and (max-width:768px) {
/*CSS specific for tablets goes here (show the tablet form)*/
}
/*CSS Media Query for a mobile phone*/
@media only screen and (max-width:481px) {
/*CSS specific for mobile phones goes here (show the mobile form)*/
}
Hope this helps.