Border Disappears on Zoom Out/in In all Browser - html

I am working on a project with different browsers.
I am having a table with borders and when I zoom out my page border disappears.
This happens in all browsers like IE, EDGE, and Chrome Browser.
Is it the DOM structure problem?
It needs to supports with zoom level 75% to 125%. To be specific set zoom to 67% in Chrome and see the change
Please provide the possible solution to this question.
.mEditor {
display: flex;
border-bottom: 1px solid #d7d7d7;
}
.m-label {
width: 30%;
display: flex;
background-color: #f2f2f2;
}
.m-editor-noc {
flex: 1;
display: flex;
background-color: #FFFFFF;
border-left: 1px solid #d7d7d7;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.mfEditor {
display: flex;
flex: 1 0 auto;
}
.mEditor-li {
vertical-align: middle;
border-left: 1px solid #d7d7d7;
height: 18px;
display: inline-block;
margin-top: 3px;
}
.mEditor .tEditor {
border: none;
flex: 1;
padding-right: 6px;
}
<div class="m-group">
<div id="id251" class="mEditor">
<div class="m-label">
<label for="id223" title="Address">Address</label>
</div>
<div class="m-editor-noc">
<div id="id252" class="mfEditor">
<input type="text" class="tEditor" value="Address" name="" id="id223" maxlength="255" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id254" class="mEditor">
<div class="m-label">
<label for="id224" title="Address 2">Address 2</label>
</div>
<div class="m-editor-noc">
<div id="id255" class="mfEditor">
<input type="text" class="tEditor" value="16" name="" id="id224" maxlength="30" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id257" class="mEditor">
<div class="m-label">
<label for="id225" title="Postcode">Postcode</label>
</div>
<div class="m-editor-noc">
<div id="id258" class="mfEditor">
<input type="text" class="tEditor" value="Post Code" name="" id="id225" maxlength="10" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id25a" class="mEditor ">
<div class="m-label">
<label for="id20f" title="City">City</label>
</div>
<div class="m-editor-noc">
<div id="id25b" class="mfEditor">
<input type="text" class="tEditor" value="City" name="" id="id20f" autocomplete="off" maxlength="50" tabindex="0">
</div>
<div class="editor-links">
</div>
</div>
</div>
<div id="id25d" class="mEditor">
<div class="m-label">
<label for="id228" title="District">District</label>
</div>
<div class="m-editor-noc">
<div id="id25e" class="mfEditor">
<input type="text" class="tEditor" value="" name="" id="id228" maxlength="100" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id260" class="mEditor ">
<div class="m-label">
<label for="id210" title="Country">Country</label>
</div>
<div class="m-editor-noc">
<div id="id261" class="mfEditor">
<input type="text" class="tEditor" value="Country" name="" id="id210" autocomplete="off" maxlength="50" tabindex="0">
</div>
<div class="editor-links">
</div>
</div>
</div>
</div>

If by "We supporting all browser and Zoom level 75% - 125%" you mean you want a border to have the same size in actual pixels regardless of zoom level, you're out of luck. It's not technically possible.
You should only develop for zoom level of 100%.
There is no reliable cross-browser method to know the zoom level, which means this information is not available inside your Window object, so you can't use it to adjust values of properties on your elements.
As a fallback, you could just make the border thicker, so it will be visible even when zoomed. Now it's not displayed because it probably gets a sub-pixel size and estimated by the browser into non-renderable.
Do note everything you that's rendered at zoom levels other than 100% is entirely at the whim of how each browser internally chooses to estimate and render, which you:
have no control on
could change without notice.
In other words, your initial statement should have a minor footnote:
* Within reasonable limits. Rendering while zoomed is browser dependent.

I encountered a similar issue with border disappearing. This answer was extremely helpful to me. Draw borders by pseudo-elements. The solution for your case could be like:
.mEditor {
display: flex;
/*border-bottom: 1px solid #d7d7d7; <- REMOVE */
position: relative; /* <- ADD */
}
.mEditor::after{ /* <- ADD */
content: "";
position: absolute;
top:0;
bottom:0;
right:0;
left:0;
border-bottom: 1px solid #d7d7d7;
}
.m-label {
width: 30%;
display: flex;
background-color: #f2f2f2;
}
.m-editor-noc {
flex: 1;
display: flex;
background-color: #FFFFFF;
/*border-left: 1px solid #d7d7d7; <- REMOVE */
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
position: relative; /* <- ADD */
}
.m-editor-noc::after{ /* <- ADD */
content: "";
position: absolute;
top:0;
bottom:0;
right:0;
left:0;
border-left: 1px solid #d7d7d7;
}
.mfEditor {
display: flex;
flex: 1 0 auto;
}
.mEditor-li {
vertical-align: middle;
border-left: 1px solid #d7d7d7;
height: 18px;
display: inline-block;
margin-top: 3px;
}
.mEditor .tEditor {
border: none;
flex: 1;
padding-right: 6px;
}
<div class="m-group">
<div id="id251" class="mEditor">
<div class="m-label">
<label for="id223" title="Address">Address</label>
</div>
<div class="m-editor-noc">
<div id="id252" class="mfEditor">
<input type="text" class="tEditor" value="Address" name="" id="id223" maxlength="255" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id254" class="mEditor">
<div class="m-label">
<label for="id224" title="Address 2">Address 2</label>
</div>
<div class="m-editor-noc">
<div id="id255" class="mfEditor">
<input type="text" class="tEditor" value="16" name="" id="id224" maxlength="30" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id257" class="mEditor">
<div class="m-label">
<label for="id225" title="Postcode">Postcode</label>
</div>
<div class="m-editor-noc">
<div id="id258" class="mfEditor">
<input type="text" class="tEditor" value="Post Code" name="" id="id225" maxlength="10" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id25a" class="mEditor ">
<div class="m-label">
<label for="id20f" title="City">City</label>
</div>
<div class="m-editor-noc">
<div id="id25b" class="mfEditor">
<input type="text" class="tEditor" value="City" name="" id="id20f" autocomplete="off" maxlength="50" tabindex="0">
</div>
<div class="editor-links">
</div>
</div>
</div>
<div id="id25d" class="mEditor">
<div class="m-label">
<label for="id228" title="District">District</label>
</div>
<div class="m-editor-noc">
<div id="id25e" class="mfEditor">
<input type="text" class="tEditor" value="" name="" id="id228" maxlength="100" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id260" class="mEditor ">
<div class="m-label">
<label for="id210" title="Country">Country</label>
</div>
<div class="m-editor-noc">
<div id="id261" class="mfEditor">
<input type="text" class="tEditor" value="Country" name="" id="id210" autocomplete="off" maxlength="50" tabindex="0">
</div>
<div class="editor-links">
</div>
</div>
</div>
</div>

Related

Flex Layout not responding properly in reactJs

Currently what Im trying to achieve is this:
But I tried this using flex attribute but the layout is messed up. Here is my code for the same.
<div className="contact-container" style={{flexDirection:"row",backgroundColor:"#ECECEC"}}>
<div style={{padding:"30px"}}>
<div style={{flexDirection:"column"}}>
<p style={{color:"#0E2043",backgroundColor:"#ECECEC", fontSize:"22px",fontWeight:"700", textAlign:"justify"}}>If you are looking to enjoy exactly these benefits, Passport Legacy is here to assist you with your second citizenship. </p>
<p style={{color:"#0E2043", paddingTop:"30px",backgroundColor:"#ECECEC", textAlign:"justify"}}>If you would like more information about any of the qualifying programs, or our services, please do not hesitate to contact us.</p>
</div>
</div>
<div style={{padding:"30px"}}>
<div>
<div style={{padding:"5px"}}>
<input style={{padding:"5px", width:"100%"}} type="text" placeholder="Name"/>
</div>
<div style={{width:"100%",display:"flex", flexWrap:"wrap", justifyContent:"space-between"}}>
<div style={{padding:"5px"}}>
<input style={{padding:"5px",width:"100%"}} type="text" placeholder="email"/>
</div>
<div style={{padding:"5px"}}>
<input style={{padding:"5px",width:"100%"}} type="text" placeholder="phone"/>
</div>
</div>
<div style={{padding:"5px"}}>
<input style={{padding:"5px", width:"100%"}} type="text" placeholder="Subject"/>
</div>
<div style={{padding:"5px"}}>
<textarea style={{padding:"5px", width:"100%"}} rows="4" placeholder="Message"/>
</div>
</div>
</div>
</div>
Ive added a sandbox too, Please feel free to make changes.
https://codesandbox.io/s/divine-dawn-l27wy?file=/src/App.tsx:71-1766
Here is your code with a little changes, I made it responsive too for width less than 400px.
const App=()=>{
return(
<div className="contact-container" style={{backgroundColor:"#ECECEC"}}>
<div style={{padding:"30px"}}>
<div style={{flexDirection:"column"}}>
<p style={{color:"#0E2043",backgroundColor:"#ECECEC", fontSize:"22px",fontWeight:"700", textAlign:"justify"}}>If you are looking to enjoy exactly these benefits, Passport Legacy is here to assist you with your second citizenship. </p>
<p style={{color:"#0E2043", paddingTop:"30px",backgroundColor:"#ECECEC", textAlign:"justify"}}>If you would like more information about any of the qualifying programs, or our services, please do not hesitate to contact us.</p>
</div>
</div>
<div style={{padding:"30px"}}>
<div>
<div style={{padding:"5px"}}>
<input style={{padding:"5px", width:"100%"}} type="text" placeholder="Name"/>
</div>
<div style={{width:"100%",display:"flex", flexWrap:"wrap", justifyContent:"space-between"}}>
<div style={{padding:"5px"}}>
<input style={{padding:"5px",width:"100%"}} type="text" placeholder="email"/>
</div>
<div style={{padding:"5px"}}>
<input style={{padding:"5px",width:"100%"}} type="text" placeholder="phone"/>
</div>
</div>
<div style={{padding:"5px"}}>
<input style={{padding:"5px", width:"100%"}} type="text" placeholder="Subject"/>
</div>
<div style={{padding:"5px"}}>
<textarea style={{padding:"5px", width:"100%"}} rows="4" placeholder="Message"/>
</div>
</div>
</div>
</div>
)}
ReactDOM.render(
<App />,
document.getElementById("react")
);
.contact-container {
display: flex;
flex-direction: row;
}
.contact-container > div {
width:50%;
}
#media (max-width: 400px) {
.contact-container {
flex-direction: column;
}
.contact-container > div {
width:100%;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<div id="react"></div>
All you have to do is specify the "width" for the "div" on the left.
<div style={{padding:"30px", width:"50%"}}>
First of all it is not a ReactJS issue. It is just you are not configuring the flexbox propertly.
* {
margin: 0;
padding: 0;
outline: 0;
box-sizing: border-box;
}
body {
height: 100vh;
display: grid;
place-items: center;
}
.container {
width: 90%;
display: flex;
max-width: 500px;
flex-direction: column;
border: 1px solid red;
}
.container input,
.container textarea {
width: 100%;
padding: 0.75rem;
border: 1px solid #e5e5e5;
}
.container input {
margin-top: 1rem;
}
.container .flex {
display: flex;
justify-content: space-between;
}
.container .flex input:nth-child(2) {
margin-left: 1rem;
}
.container textarea {
display: block;
margin-top: 1rem;
}
<div class="container">
<form>
<input type="text" placeholder="Name" />
<div class="flex">
<input type="text" placeholder="Email">
<input type="text" placeholder="Phone">
</div>
<input type="text" placeholder="Subject">
<textarea id="" cols="20" rows="10"></textarea>
</form>
</div>
Let me know if this works? 😊

popup at different position where the cursor clicks css

Here is my code:
<div class="checkbox">
<input id="230am" type="checkbox" onclick="openPopup()"> <label for="230am"></label>
<div id="popupBk">
<div id="title">Reminder</div>
<div id="timeSelect">
Start time: <input id="field1" /><br /><br />
End time: <input id="field2" /><br /><br />
</div>
<button onclick="processTime('field1','field2')" name="submit" id="submitButton"/>Create</button>
<div id="close_popup" title="Close this menu" onclick="closePopup()">
<p>X</p>
</div>
</div>
</div>
<div class="checkbox">
<input id="3am" type="checkbox"> <label for="3am"></label>
<div id="popupBk">
<div id="title">Reminder</div>
<div id="timeSelect">
Start time: <input id="field1" /><br /><br />
End time: <input id="field2" /><br /><br />
</div>
<button onclick="processTime('field1','field2')" name="submit" id="submitButton"/>Create</button>
<div id="close_popup" title="Close this menu" onclick="closePopup()">
<p>X</p>
</div>
</div>
</div>
Below are my css:
#popupBk{
position: absolute;
width: 25%;
height: 20%;
border: 2px solid grey;
border-radius: 2px;
background-color: white;
margin-left: 3%;
box-shadow: 2px 2px 10px;
display: none;
}
So I am trying to do a calendar app. I put two popup in two checkboxes just want to do that different popup will display under each checkbox once I click. Any ideas how to do this?
i think there is a way to make each class name differently and then create its own css, but if that it might needs a huge work. Or is there any other way?
Thanks.
You can use the :checked state of checkboxes in CSS, coupled with the general sibling selector (~) to do this.
Read about sibling selectors here: https://css-tricks.com/child-and-sibling-selectors/
Here's a live example:
.wrapper {
float: left;
}
.hidden {
border: 1px solid #000;
display: none;
}
input[type="checkbox"]:checked ~ .hidden {
display: block;
}
<div class="wrapper">
<input type="checkbox" id="box1" /> <label for="box1">Show Box 1</label>
<div class="hidden">Box 1</div>
</div>
<div class="wrapper">
<input type="checkbox" id="box2" /> <label for="box2">Show Box 2</label>
<div class="hidden">Box 2</div>
</div>

Why div are not aligned horizontally

I am trying to align 2 divs horizontally inside one div.
Here is codepen link Check Here. When I add margin-top to left div it is not moving up.
What am I doing wrong?
<footer id="contact">
<div class="reservation" style="display: block;border:1px solid red; ">
<div class="reserve-address-div" style="display: inline-block;width:45%;border:1px solid red;margin-top:-40px;">
<h4>51 Area, Barmuda Triangle, Mars</h4>
<h4>0165466546</h4>
<h4>vivek.tarun17#gmail.com</h4>
</div>
<div class="reserve-booking-div" style="display: inline-block; width:45%;border:1px solid red; ">
<form>
<input type="text" name="name" placeholder="Name" /><br>
<input type="email" name="email" placeholder="Email"/><br>
<input type="text" name="subject" placeholder="Subject"/><br>
<textarea placeholder="message" rows="5"></textarea><br>
<input type="button" value="Submit">
</form>
</div>
</div>
</footer>
Please try to use vertical-align: top something like this:
<div class="reservation">
<div class="reserve-address-div" style="display: inline-block; ... vertical-align:top">
...
</div>
<div class="reserve-booking-div" style="display: inline-block; ... vertical-align:top">
...
vertical-align property is useful.
You can put inline-blocks along with the top of parent element, e.g., div.
The reason .reserve-address-div is being pushed down is because the default vertical-align value is set to baseline. As another poster mentioned, setting the vertical-align property to top for .reserve-address-div will remove the space above that div.
You can read more about the issue here.
An alternate solution would be to use flexbox on the .reservation container, as I've demonstrated in the snippet below.
Hope this helps!
.reservation {
border: 1px solid red;
display: flex;
align-content: center;
justify-content: center;
width: 100%;
}
.reserve-address-div {
display: inline-block;
width: 45%;
border: 1px solid red;
}
.reserve-booking-div {
display: inline-block;
width: 45%;
border: 1px solid red;
}
<footer id="contact">
<div class="reservation">
<div class="reserve-address-div">
<h4>51 Area, Barmuda Triangle, Mars</h4>
<h4>0165466546</h4>
<h4>vivek.tarun17#gmail.com</h4>
</div>
<div class="reserve-booking-div">
<form>
<input type="text" name="name" placeholder="Name" /><br>
<input type="email" name="email" placeholder="Email" /><br>
<input type="text" name="subject" placeholder="Subject" /><br>
<textarea placeholder="message" rows="5"></textarea><br>
<input type="button" value="Submit">
</form>
</div>
</div>
</footer>
How about the Flexbox solution:
.reservation {
display: flex;
padding: 2.5px;
border: 1px solid red;
}
.reserve-address-div, .reserve-booking-div {
flex: 1;
margin: 2.5px;
padding: 5px;
border: 1px solid red;
}
<footer id="contact">
<div class="reservation">
<div class="reserve-address-div">
<h4>51 Area, Barmuda Triangle, Mars</h4>
<h4>0165466546</h4>
<h4>vivek.tarun17#gmail.com</h4>
</div>
<div class="reserve-booking-div">
<form>
<input type="text" name="name" placeholder="Name"><br>
<input type="email" name="email" placeholder="Email"><br>
<input type="text" name="subject" placeholder="Subject"><br>
<textarea placeholder="message" rows="5"></textarea><br>
<input type="button" value="Submit">
</form>
</div>
</div>
</footer>
Adjust margins and padding to your needs.

How do I get these text input boxes to line up?

How do I get the text input boxes to line up?
The password input box is slightly to the left, it is not aligned with the username text input box.
I am using Java, in Eclipse.
<div>
<div id="header">
<h1>Login</h1>
</div>
<form name="loginform">
<fieldset>
<legend>Login Form</legend>
<label>Username:
<input type="text" name="username" /><span>*</span>
</label>
<label>Password:
<input type="password" name="pass" /><span>*</span>
</label>
<input type="reset" class="resetButton" />
<input type="submit" value="Login" class="submitButton" />
</fieldset>
</form>
</div>
If you want it to be dynamic, you need a grid (row/column) structure, and the best one (cross browser) today is display: table, as display: grid is still widely unsupported (working draft | caniuse)
h1 {letter-spacing: 1px; font-size: .4in; color: green;}
legend {font-variant: small-caps; font-weight: bold}
fieldset{width: 300px; font-family: Arial, sans-serif;
background-color : limegreen}
label {display: block; position: relative; line-height: 2;}
.text {position: absolute; margin-left: 20px; width: 15em; left: 80px}
.grid {
display: table;
}
.row {
display: table-row;
}
.col {
display: table-cell;
padding: 6px 0 0 6px;
}
.col.after:after {
content: ' *';
color: red;
}
<div>
<div id="header">
<h1>Login</h1>
</div>
<form name="loginform">
<fieldset>
<legend>Login Form</legend>
<div class="grid">
<div class="row">
<div class="col">
<label for="username">Username:</label>
</div>
<div class="col after">
<input type="text" name="username" id="username"/>
</div>
</div>
<div class="row">
<div class="col">
<label for="pass">Password:</label>
</div>
<div class="col after">
<input type="password" name="pass" id="pass"/>
</div>
</div>
<div class="row">
<div class="col">
</div>
<div class="col">
<input type="reset" class ="resetButton"/>
<input type="submit" value = "Login" class="submitButton"/>
</div>
</div>
</div>
</fieldset>
</form>
</div>
In a perfect W3 standard world, your label would be a field that stands on its own, not a field that encapsulates the input. So, for instance:
<label for="username">Username:</label>
<input id="username" type="text" name="username"/><span>*</span>
The "for" tag refers to the ID of the input field that you'd have to add. Styling, then would be as simple as adding on a width to the style of the label. For positioning purposes, you could display-inline on the required asterisk to position it after the input.
Enclose the username and password labels in an inline-block span and give that span a width.
Your updated html looks like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1"/>
<title>Test</title>
</head>
<body>
<style tpye ="text/css">
h1 {letter-spacing: 1px; font-size: .4in; color: green;}
span {color: red}
legend {font-variant: small-caps; font-weight: bold}
fieldset{width: 300px; font-family: Arial; sans-serif;
background-color : limegreen}
label {display: block; position relative; line-height: 2;
margin: 10px 0px;}
.text {position: absolute; margin-left: 20px; width: 15em; left: 80px}
span.myspan{width: 100px; display:inline-block;}
</style>
<div>
<div id="header">
<h1>Login</h1>
</div>
<form name="loginform">
<fieldset>
<legend>Login Form</legend>
<label><span class="myspan">Username:</span> <input type="text" name="username"/><span>*</span></label>
<label><span class="myspan">Password:</span> <input type="password" name="pass"/><span>*</span></label>
<input type="reset" class ="resetButton"/>
<input type="submit" value = "Login" class="submitButton"/>
</fieldset>
</form>
</div>
</body>
</html>
Test here: https://jsfiddle.net/nabtron/d4cr66oa/
This one worked, thank you.
h1 {letter-spacing: 1px; font-size: .4in; color: green;}
legend {font-variant: small-caps; font-weight: bold}
fieldset{width: 300px; font-family: Arial, sans-serif;
background-color : limegreen}
label {display: block; position: relative; line-height: 2;}
.text {position: absolute; margin-left: 20px; width: 15em; left: 80px}
.grid {
display: table;
}
.row {
display: table-row;
}
.col {
display: table-cell;
padding: 6px 0 0 6px;
}
.col.after:after {
content: ' *';
color: red;
}
<div>
<div id="header">
<h1>Login</h1>
</div>
<form name="loginform">
<fieldset>
<legend>Login Form</legend>
<div class="grid">
<div class="row">
<div class="col">
<label for="username">Username:</label>
</div>
<div class="col after">
<input type="text" name="username" id="username"/>
</div>
</div>
<div class="row">
<div class="col">
<label for="pass">Password:</label>
</div>
<div class="col after">
<input type="password" name="pass" id="pass"/>
</div>
</div>
<div class="row">
<div class="col">
</div>
<div class="col">
<input type="reset" class ="resetButton"/>
<input type="submit" value = "Login" class="submitButton"/>
</div>
</div>
</div>
</fieldset>
</form>
</div>

Css Align Div next to another Div

Can someone please help me with this css? I am very new and for some reason cannot figure something out that seems to be extremely simple. What I am trying to do is have gvw_field align next to the ew_field. I am not sure how to align the <div> 's next to each other.
http://jsfiddle.net/r45xfbex/
#gvw_field {
text-align:center;
}
<div class="clearfix">
<div id="ew_field">
<label for="ew">Empty Weight:</label>
<input type="text" name="ew" id="ew" value="">
</div>
<div id="gvw_field">
<label for="gvw" >Gross Vehicle Weight:*</label>
<input type="text" name="gvw" id="gvw" value="">
</div>
<div id="ft_field">
<label for="ft">Feet:</label>
<input type="text" name="ft" id="ft" value="">
</div>
</div>
Working jsFiddle Demo
The display: inline property will do it.
#gvw_field, #ew_field{
display: inline;
}
Readup about display property on MDN.
Working code snippet:
#gvw_field {
text-align:center;
}
#gvw_field, #ew_field{
display: inline;
}
<div class="clearfix">
<div id="ew_field">
<label for="ew">Empty Weight:</label>
<input type="text" name="ew" id="ew" value="">
</div>
<div id="gvw_field">
<label for="gvw" >Gross Vehicle Weight:*</label>
<input type="text" name="gvw" id="gvw" value="">
</div>
<div id="ft_field">
<label for="ft">Feet:</label>
<input type="text" name="ft" id="ft" value="">
</div>
</div>
Use floats to align each <div>
#gvw_field {
text-align:center;
}
.column{
width: 33.33%;
float: left;
}
<div class="clearfix">
<div class="column" id="ew_field">
<label for="ew">Empty Weight:</label>
<input type="text" name="ew" id="ew" value="">
</div>
<div class="column" id="gvw_field">
<label for="gvw" >Gross Vehicle Weight:*</label>
<input type="text" name="gvw" id="gvw" value="">
</div>
<div class="column" id="ft_field">
<label for="ft">Feet:</label>
<input type="text" name="ft" id="ft" value="">
</div>
</div>
use float and don't use same id for many items:
CSS:
.ft_field
{
float: right;
width: 50%;
}
label {
display: inline-block;
width: 170px;
}
.gvw_field {
float: right;
width: 50%;
}
HTML:
<div class="clearfix">
<div class="ew_field">
<label for="ew">Empty Weight:</label>
<input type="text" name="ew" id="ew" value=""/>
</div>
<div class="gvw_field">
<label for="gvw" >Gross Vehicle Weight:*</label>
<input type="text" name="gvw" id="gvw" value=""/>
</div>
<div class="ft_field">
<label for="ft">Feet:</label>
<input type="text" name="ft" id="ft" value=""/>
</div>
</div>
jsfiddle
You you need a display value of inline and also a given width.
#ew_field, #ft_field, #gvw_field {
text-align: center;
display: inline-block;
width: 150px; /* Adjust as needed */
}
See working demo here