margin-top for this div does not work in Firefox - html

I have divided my layout into divs, and within the div="content" area I have a table and a filter option which need to be positioned. I'm trying to insert some margin between the filter option area and the navigation bar. This looks fine in Chrome but in Mozilla Firefox the filter options appear way below than they should.
This is my code and how it looks at the moment:
http://jsfiddle.net/elmiri/5mXJ7/ if you open this link in Chrome the filter option looks fine however in Mozilla it looks really bad.
Here is all of my code:
<div id="header">
<h1>LOGO</h1>
</div>
<div id="navigation">
<ul>
<li>Home</li>
<li>Test
<li>Test
<li>Test
<li>Activity Feed
<li>Stats
<li>Contact Us
<li>Users
<li>My account
</ul>
</div>
</body>
</html>
<div id="personalised">
<p>Hello, </p>
</div>
<div id="content">
<form id="form1" method="get" action="">
<div id= "filter">
<label for="column">Select client type:</label>
<select name="column" id="column">
<option selected>Key</option>
<option >Norm</option>
<option >Onb</option>
</select>
<input type="submit" name="change" id="change" value="Filter">
<input type="submit" name="Remove" id="Remove" value="Show all">
</div>
<table>
<tr>
<th scope="col">Client name</th>
<th scope="col">Client type</th>
<th> </th>
<th> </th>
</tr>
<tr>
<td>Client2</td>
<td>KEY</td>
<td>EDIT</td>
<td>DELETE</td>
</tr>
<tr>
<td>Client3</td>
<td>KEY</td>
<td>EDIT</td>
<td>DELETE</td>
</tr>
<tr>
<td>client4</td>
<td>NORM</td>
<td>EDIT</td>
<td>DELETE</td>
</tr>
<tr>
<td>client4</td>
<td>ONB</td>
<td>EDIT</td>
<td>DELETE</td>
</tr>
<tr>
<td>client100</td>
<td>Key</td>
<td>EDIT</td>
<td>DELETE</td>
</tr>
</table>
</div>
This is the part of the code that positions the filter option:
<div id= "filter">
<label for="column">Select client type:</label>
<select name="column" id="column">
<option <?php if ($col == 'Key') echo 'selected'; ?>>Key</option>
<option <?php if ($col == 'Norm') echo 'selected'; ?>>Norm</option>
<option <?php if ($col == 'Onb') echo 'selected'; ?>>Onb</option>
</select>
<input type="submit" name="change" id="change" value="Filter">
<input type="submit" name="Remove" id="Remove" value="Show all">
</div>
the css code:
#filter {
float:right;
margin-top: 2%;
}
THIS filter div is within the Content div so I'm not sure if that's causing problem. I tried to set margin-top to 20 px and it still did not work in Firefox.
Would be grateful if someone helped me put a gap between the navigation bar and the filter option so that it looks fine both in Chrome and Mozilla.
Thank you

That's because the margin-top if set in a percentage it is proportional to the element's parent width and not height as one would normally expect. Margin on MDN.

Related

having trouble with css floating forms left and right

I have a jsfiddle below:
http://jsfiddle.net/C95uc/3/
I am having trouble with my css. I want to display both drop down menus on the left above one another and I want to display the text inputs on the right hand side, but how can I do this?
Below is the html code:
<div class='lt-container'>
<form id='moduleForm'>
<select name="module" id="modulesDrop">
<option value="">Please Select Module</option>
</select>
</form>
</div>
<div class='lt-container' >
<form id='moduleExistForm'>
<select name="module" id="modulesDrop">
<option value="">Please Select Course</option>
</select> </form>
</div>
<div id='rt-container' >
<form id='detailsForm'>
<table>
<tr>
<th></th>
<td><input type='hidden' id='idmodule' name='moduleid' value='' /> </td>
</tr>
<tr>
<th>Module ID:</th>
<td><input type='text' id='nomodule' name='moduleno' readonly='readonly' value='' /> </td>
</tr>
<tr>
<th>Module Name:</th>
<td><input type='text' id='namemodule' name='modulename' readonly='readonly' value='' /> </td>
</tr>
<tr>
<th>Credits:</th>
<td><input type='text' id='credits' name='creditsname' readonly='readonly' value=''/> </td>
</tr>
</table>
<div id='moduleAlert'></div>
</form>
</div>
CSS:
.lt-container, #rt-container {
float: left;
}
#rt-container {
clear: right;
margin-left: 5%;
}
http://jsfiddle.net/C95uc/4/
<div class='lt-container'>
<form id='moduleForm'>
<select name="module" id="modulesDrop">
<option value="">Please Select Module</option>
</select>
</form>
<form id='moduleExistForm'>
<select name="module" id="modulesDrop">
<option value="">Please Select Course</option>
</select> </form>
</div>
Both <select> go in the same <div class='lt-container'>
The two dropdowns don't stack on top of each other because you have assigned both of them a "float:left" property which makes them go side by side. Instead, wrap them in a div and make that div float left.
<div class="lfloat">
<!-- Both Dropdowns -->
</div>
CSS:
.lfloat {
float:left;
}
Be sure to add a "float:right" property to the form so that it doesn't appear below the two drop downs.
Example: http://jsfiddle.net/C95uc/5/

Table disappears in Firefox and Chrome

I have a table and when I load the page in Firefox or chrome its shifted off the screen to the the right leading to most of the table disappearing, the table should be located in the middle of the screen and seems to be overlapping on the right outside of the page area.
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Small North Run</title>
<meta name="description" content=" ">
<meta name="keywords" content=" ">
<link rel="stylesheet" href="default.css" type="text/css">
<link rel="stylesheet" href="sponsor.css" type="text/css">
</head>
<body>
<div id="wrapper">
<header>
<h1>SMALL NORTH RUN</h1>
</header>
<nav>
<ul id="navlist">
<li>HOME</li>
<li>TRAINING REGIME</li>
<li>FORUM</li>
<li>SPONSOR</li>
<li>CONTACT</li>
</ul>
</nav>
<hr id="hrnav" />
<div id="content">
<p>This page allows you to sponsor a particular runner. Just simply select the name of the runner you wish to sponsor from the drop down list, then enter the amount you wish to donate followed by a brief message for the runner and then your name. Once making a donation the runner you have sponsored will be notified by email that you have made a donation.</p>
<br/>
<br/>
<br/>
<br/>
<form method="post" action="test.php">
<table>
<tr><td><label>Runner:</label></td>
<td>
<select name="fullname">
<?php do{?>
<option value="<?php echo $rsNames['user_ID']; ?>"> <?php echo $rsNames['first_Name'];?> <?php echo $rsNames['last_Name'];?></option>
<?php } while ( $rsNames= mysql_fetch_assoc($names_query))?>
</select>
</td>
</tr>
<tr><td><label>Donation (£):</label></td><td><input type="text" maxlength="9" value="0.00" name="donation"/></td></tr>
<tr>
<td>
<label>Message:</label>
</td>
<td>
<textarea name="donationmessage" maxlength="200" cols="25" rows="6"> </textarea>
</td>
</tr>
</tr>
<tr><td><label>Your Name:</label></td><td><input type="text" maxlength="30" name="donator"/></td></tr>
<tr>
<td>
<tr><td><input id="submit" type="submit" value="Confirm Donation"/></td></tr>
</table>
</form>
</div>
</div> <!-- END WRAPPER -->
</body>
</html>
CSS
#content { text-align: left; margin: 2px; padding: 10px; }
#content p { font: font: 12px/1.5 Verdana, sans-serif; float: left; }
try to add a doctype :
for example, here is the HTML5 doctype
<!DOCTYPE html>
It seems to work fine for me.
Maybe you have a problem in your css?
EDIT:
The float style on your P tag is causing the trouble.
A simple solution could be to use a defloating-break-div (I'm not sure what the proper name is) underneath your P tag:
<div style="float:none;">
<br />
</div>
This causes the rest of your code to resume the normal layout
1) You have some errors in table structure
2) If you need to center table, you can setup it margin-left and margin-right auto.
There is possible table code with align:
<table style='margin: 0 auto;'>
<tr>
<td><label>Runner:</label></td>
<td>
<select name="fullname">
<?php do{?>
<option value="<?php echo $rsNames['user_ID']; ?>"> <?php echo $rsNames['first_Name'];?> <?php echo $rsNames['last_Name'];?></option>
<?php } while ( $rsNames= mysql_fetch_assoc($names_query))?>
</select>
</td>
</tr>
<tr>
<td><label>Donation (£):</label></td>
<td><input type="text" maxlength="9" value="0.00" name="donation"/></td>
</tr>
<tr>
<td><label>Message:</label></td>
<td><textarea name="donationmessage" maxlength="200" cols="25" rows="6"> </textarea></td>
</tr>
<tr>
<td><label>Your Name:</label></td>
<td><input type="text" maxlength="30" name="donator"/></td>
</tr>
<tr>
<td><input id="submit" type="submit" value="Confirm Donation"/></td>
<td> </td>
</tr></table>
If you still have troubles: post somewhere full HTML and CSS code for detailed analysis.

Table Within Div Firefox vs Chrome

So I am web developer who used to have a kind graphics design person help me out on this sort of browser compatibility hell, but alas he has moved on to greener pastures. The following html looks fine and dandy on chrome, but the table I am using to align my form is sleeping on the job on the bottom in ie and firefox. Should I never use tables? Is the float in the div tags screwing everything up? Any hints or suggestions for improving my html and css would be much appreciated.
Also, the text area text gets a little screwy sometimes in terms of where it is positioned in the box.
Thank you all.
<div style="border-style:solid; border-color:#336699; padding: 5px; margin-left:auto; margin-right:auto; width:600px; height:300px;" id="demoContainer">
<div style="" id="demo">
<div style="" id="demoHeader">
<img src="someimage" />
<span style="font-size:32px;">Demo</span>
</div>
<div style="" id="demoBody">
<form method="get">
<div style="float:left; padding:5px;" id="demoBodyText">
<textarea style="resize:none;" rows="10" cols="30">
Enter demo text here...
</textarea>
</div>
<div style="float:right; padding:5px;" id="demoBodyOptions">
<table style="float:right;">
<tr>
<th>
Option 1:
</th>
<td>
<select style="">
<option>asdf</option>
</select>
</td>
</tr>
<tr>
<th>
Option 2:
</th>
<td>
<select style="align:left;">
<option value="320">Fastest</option>
<option value="260">Faster</option>
<option value="200">Fast</option>
<option value="170" selected="selected">Default</option>
<option value="130">Slow</option>
<option value="110">Slower</option>
<option value="80">Slowest</option>
</select>
</td>
</tr>
<tr>
<th>
Option 3:
</th>
<td>
<select>
<option value="4.2">Highest</option>
<option value="3">Higher</option>
<option value="2">High</option>
<option value="1" selected>Default</option>
<option value="0.8">Low</option>
<option value="0.6">Lower</option>
<option value="0.4">Lowest</option>
</select style="align:left;">
</td>
</tr>
<tr>
<th>
Option 4
</th>
<td>
<select>
<option value="none">None</option>
</select style="align:left;" >
</td>
</tr>
<tr>
<td>
<input type="submit" />
</td>
</tr>
</table>
</div>
</form>
</div>
<div style="clear:both;" id="demoFooter">
Footer
</div>
</div>
</div>
EDIT: Added image in how it displays in my firefox version 10.
If you have a float:right after a float:left this seems pretty normal.
Try to switch the order of the two or give the second one also float:left
Or maybe the padding is the problem?
http://jsfiddle.net/HerrSerker/55cXT/
What are the width of your floated divs #demoBodyText and #demoBodyOptions?
See the fiddle - Is this you are looking for?
Fiddle: http://jsfiddle.net/jKtkq/
Demo: http://jsfiddle.net/jKtkq/embedded/result/
Screen shot: http://img39.imageshack.us/img39/7676/tableissue.jpg

converting 2 html files into a single .vm file

I am making 2 different web application for smart phones, using jQuery mobile and webapp-net.
so far I have the following codes: (its just a part of these codes, since I can not put the whole thing here)
<div data-role="collapsible" data-collapsed="true">
<h3>Eenmalige machtiging </h3>
<div data-role="fieldcontain" >
<form >
<input type="number" pattern="[0-9]*" id="anum" maxlength="9" placeholder="Account Number" autocomplete="off" onBlur="isValidAnum()" onFocus="emptyAnum('anum')"/>
<input type="text" id="bname" placeholder="Beneficiary Name" autocomplete="off" onBlur="isValidBname()" onFocus="emptyBname('bname')"/>
<table>
<tr><td>
Select Your Bank
</td>
<td>
<select name="select-bank" id="select-bank" class="select-bank" data-inline = "true" >
<option value="abn">ABN Amro</option>
<option value="rabo">Rabo Bank</option>
<option value="ing">ING Bank</option>
<option value="overige"> --Overig--</option>
</select>
</td>
</tr>
</table>
<table>
<tr>
<td>I Agree </td>
<td><input type="checkbox" class = "checkbox" name="cbox" id="cbox2"/></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<br/>
<a data-role = "button" type="submit" data-icon = "check" data-theme="b">Pay</a>
</form>
</div>
</div>
</div>
</div>
and:
<button class="form_header" id="last_method"><img src="appimages/directdebit_NL.png" align="middle" /> Eenmalige Machtiging</button>
<div class="form_body">
<fieldset>
<ul>
<li>
<input type="number" pattern="[0-9]*" id="anum" maxlength="9" placeholder="Account Number" autocomplete="off" onBlur="isValidAnum()" onFocus="emptyAnum('anum')"/>
</li>
<li>
<input type="text" id="bname" placeholder="Beneficiary Name" autocomplete="off" onBlur="isValidBname()" onFocus="emptyBname('bname')"/>
</li>
<li>
<table>
<tr><td>
Select Your Bank
</td>
<td>
<select name="select-bank" id="select-bank" class="select-bank" data-inline = "true" >
<option value="abn">ABN Amro</option>
<option value="rabo">Rabo Bank</option>
<option value="ing">ING Bank</option>
<option value="overige"> --Overig--</option>
</select>
</td>
</tr>
</table>
</li>
<li>
<table>
<tr>
<td>I Agree </td>
<td><input type="checkbox" class = "checkbox" name="cbox" id="cbox2" /></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<input type="submit" value="Pay" class="pay_button"/>
</li>
</ul>
</fieldset>
</div>
</div>
</div>
Now I have to create a .vm file using these two codes, in order to do that I need to see what are the difference in html between these two. I tried to make it look alike each other as much as I could, I dont think I can change them any more. I was also trying to work with their css but I didnt change anything.
my question is there a possible way to put these html in a single .vm file??? if you know how to do it please help me, also if you need more info just ask me.
Are you talking about file diff? Where you check the differences in two files and merge them?
There is winmerge http://winmerge.org/
There is examdiff. Do a google search for file comparison or file diff

html and css: aligning a select to the right edge of a table

Consider the following HTML snippet. The desired effect is to have a dropdown be positioned right above a table.
<!-- this is actually in a proper CSS class, not inline-->
<div style="float:left;
min-height:1px;
padding:15px 2% 20px;
position:relative;
width:96%;">
<form method="post">
<div style="float:right;display:inline;">Show Me:
<select id="ddNumRecords" name="ddNumRecords" onchange="this.form.submit();">
<option>30</option>
<option>50</option>
<option>100</option>
</select>
</div>
The above renders like this:
table and select float right http://www.imagechicken.com/uploads/1253124526051538700.png
Question: How can I write my CSS to achieve positioning like this mockup?
desired http://www.imagechicken.com/uploads/1253124791005327900.png
Add clear: both; to your table's CSS. This will clear the float of the div (with the dropdown) above it.
But why don't you just text-align: right; your div, then you don't have to mess with floats and inline divs. That should work as well.
One way would be to add absolute positioning to both divs.
or
Other way would be to use table. For example:
<table>
<tr><td>
<form method="post">
<div style="float:right;display:inline;">Show Me:
<select id="ddNumRecords" name="ddNumRecords" onchange="this.form.submit();">
<option>30</option>
<option>50</option>
<option>100</option>
</select>
</div>
</form>
</td></tr>
<tr><td>
<div>
<div style="float:left;
min-height:1px;
padding:15px 2% 20px;
position:relative;
width:96%;">
hello world
</div>
</td></tr>
</table>
or
Add one more div around the div that has float:right. For example:
<form method="post">
<div style="float:left; width:300px">
<div style="float:right;display:inline;">Show Me:
<select id="ddNumRecords" name="ddNumRecords" onchange="this.form.submit();">
<option>30</option>
<option>50</option>
<option>100</option>
</select>
</div>
</div>
<div>
<div style="float:left;
min-height:1px;
padding:15px 2% 20px;
position:relative;
width:96%;">
hello world
</div>
you could make another cell for the table
<table>
<tr>
<td colspan="2">
<div style="float:right;display:inline;">Show Me:
<select id="ddNumRecords" name="ddNumRecords" onchange="this.form.submit();">
<option>30</option>
<option>50</option>
<option>100</option>
</select>
</div>
</td
</tr>
<tr>
<td>table head</td>
<td>table head</td>
</tr>
<tr>
<td>content1</td>
<td>ontent2</td>
</tr>
<tr>
<td>content3</td>
<td>content4</td>
</tr>
</table>
this should work.. or you could use css. but this is the fastest way to do it:-? at least until you make/find some css. you could use float left on both divs