HTML Content gets cropped - html

I have a problem. I created the following page:
#newOrderControl {
display: flex;
align-items: center;
flex-direction: column;
border-style: solid;
border-color: black;
border-width: 1px;
width: min-content;
font-size: 14px;
}
#newOrderInputFields {
display: grid;
grid-template-columns: auto auto auto auto;
column-gap: 20px;
padding-bottom: 20px;
}
#newOrderInputFields .inputField {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
#newOrderInputFields label {
flex-shrink: 0;
}
#newOrderButtons {
align-self: flex-end;
padding-bottom: 20px;
}
#newOrderButtons button {
float: right;
border-style: solid;
border-color: black;
border-width: 2px;
color: white;
height: 30px;
width: auto;
padding: 0px 15px;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 10px;
margin: 0px 5px;
}
.btnAll {
background-color: #6DA0ED;
border-style: solid;
border-color: black;
border-width: 1px;
color: white;
border-radius: 5px;
}
#btnTakeProfit {
background-color: #33AB37;
}
#btnPlaceOrder {
background-color: #6DA0ED;
}
.title {
display: block;
text-align: center;
color: #1D0F73;
font-size: 22px;
font-weight: bold;
margin: 5px;
}
<div id="newOrderControl">
<label class="title">New order</label>
<div id="newOrderInputFields">
<div class="inputField">
<label>Action:</label>
<select id="txtOrderAction">
<option value="">-</option>
<option value="Buy">Buy</option>
<option value="Sell">Sell</option>
</select>
</div>
<div class="inputField">
<label>Quantity:</label>
<input type="text" id="txtOrderQuantity">
<button class="btnAll" onclick="setAllQuantity()">All</button>
</div>
<div class="inputField">
<label>Target price:</label>
<input type="text" id="txtOrderTargetPrice">
</div>
<div class="inputField">
<label>Target perc:</label>
<input type="text" id="txtOrderTargetPerc">
</div>
<div class="inputField">
<label>Coin:</label>
<select id="txtOrderCoin">
<option value="">-</option>
<option value="">SPTF</option>
<option value="">TLS</option>
</select>
</div>
<div class="inputField">
<label>Amount:</label>
<input type="text" id="txtOrderAmount">
<button class="btnAll" onclick="setAllAmount()">All</button>
</div>
<div class="inputField">
<label>Limit price:</label>
<input type="text" id="txtOrderLimitPrice">
</div>
<div class="inputField">
<label>Limit perc:</label>
<input type="text" id="txtOrderLimitPerc">
</div>
</div>
<div id="newOrderButtons">
<button id="btnTakeProfit">Take profit</button>
<button id="btnPlaceOrder">Place order</button>
</div>
</div>
Now with this code I have a few problems:
The 2 selects (action and coin) don't have an equal width, so they are not aligned perfectly
When I resize my page everything goes trough each other
I thought I could fix it by setting width: min-content; in #newOrderControl, but that crops everything trough each other:
So I tried setting it to auto, but then it uses the entire page:
How can I keep the positions while resizing the page and give the #newOrderControl the width it needs to place everything, without using the entire page?

Did this solve the issue? I removed a couple of things. The biggest issues were width: min-content and display: flex on #newOrderControl, and using margin instead of padding. Margin doesn't work well with grid and flex.
I also removed the float, and all display properties on children of #newOrderInputFields, because it didn't seem like they did anything.
Whenever you have problem with CSS, try removing as much code as possible and start again.
As mentioned in the comments. Don't use float in design, unless it's an element that text should flow around.
I didn't focus on fixing the different input field widths. I would probably solve that by using a min-width, as you stated, or use Material Design's suggestion for text fields.
#newOrderControl {
/* display: flex; */
display: inline-flex; /* ADDED */
align-items: center;
flex-direction: column;
border-style: solid;
border-color: black;
border-width: 1px;
/* width: min-content; */
font-size: 14px;
}
#newOrderInputFields {
display: grid;
grid-template-columns: auto auto auto auto;
column-gap: 20px;
padding-bottom: 20px;
}
/* #newOrderInputFields .inputField {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}*/
/* #newOrderInputFields label {
flex-shrink: 0;
}*/
#newOrderButtons {
align-self: flex-end;
padding-bottom: 20px;
}
#newOrderButtons button {
/*float: right;*/
border-style: solid;
border-color: black;
border-width: 2px;
color: white;
height: 30px;
width: auto;
padding: 0px 15px;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 10px;
/* margin: 0px 5px; */
padding: 0px 5px; /* ADDED */
}
.btnAll {
background-color: #6DA0ED;
border-style: solid;
border-color: black;
border-width: 1px;
color: white;
border-radius: 5px;
}
#btnTakeProfit {
background-color: #33AB37;
}
#btnPlaceOrder {
background-color: #6DA0ED;
}
.title {
display: block;
text-align: center;
color: #1D0F73;
font-size: 22px;
font-weight: bold;
/* margin: 5px; */
padding: 5px; /* ADDED */
}
<div id="newOrderControl">
<label class="title">New order</label>
<div id="newOrderInputFields">
<div class="inputField">
<label>Action:</label>
<select id="txtOrderAction">
<option value="">-</option>
<option value="Buy">Buy</option>
<option value="Sell">Sell</option>
</select>
</div>
<div class="inputField">
<label>Quantity:</label>
<input type="text" id="txtOrderQuantity">
<button class="btnAll" onclick="setAllQuantity()">All</button>
</div>
<div class="inputField">
<label>Target price:</label>
<input type="text" id="txtOrderTargetPrice">
</div>
<div class="inputField">
<label>Target perc:</label>
<input type="text" id="txtOrderTargetPerc">
</div>
<div class="inputField">
<label>Coin:</label>
<select id="txtOrderCoin">
<option value="">-</option>
<option value="">SPTF</option>
<option value="">TLS</option>
</select>
</div>
<div class="inputField">
<label>Amount:</label>
<input type="text" id="txtOrderAmount">
<button class="btnAll" onclick="setAllAmount()">All</button>
</div>
<div class="inputField">
<label>Limit price:</label>
<input type="text" id="txtOrderLimitPrice">
</div>
<div class="inputField">
<label>Limit perc:</label>
<input type="text" id="txtOrderLimitPerc">
</div>
</div>
<div id="newOrderButtons">
<button id="btnTakeProfit">Take profit</button>
<button id="btnPlaceOrder">Place order</button>
</div>
</div>

If you're not opposed to using flex and grid together here's another option for you
EDIT to add mobile:
#newOrderControl {
display: flex;
align-items: center;
flex-direction: column;
border-style: solid;
border-color: black;
border-width: 1px;
width: min-content;
font-size: 14px;
padding: 0px 10px 10px 10px;
}
#newOrderInputFields {
display: grid;
grid-template-rows: 2em 2em;
grid-template-columns: 9em 18em 16em 16em;
padding-bottom: 1em;
padding-top: 1em;
}
input {
width: 10em;
}
select {
width: 5em;
}
#txtOrderAmount {
margin-left: 2px;
}
#txtOrderLimitPrice {
margin-left: 4px;
}
#txtOrderLimitPerc {
margin-left: 4px;
}
#txtOrderCoin {
margin-left: 10px;
}
#newOrderButtons {
align-self: end;
}
#newOrderButtons button {
float: right;
border-style: solid;
border-color: black;
border-width: 2px;
color: white;
height: 30px;
width: auto;
padding: 0px 15px;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 10px;
margin: 0px 5px;
}
.btnAll {
background-color: #6da0ed;
border-style: solid;
border-color: black;
border-width: 1px;
color: white;
border-radius: 5px;
}
#btnTakeProfit {
background-color: #33ab37;
}
#btnPlaceOrder {
background-color: #6da0ed;
}
.title {
display: block;
text-align: center;
color: #1d0f73;
font-size: 22px;
font-weight: bold;
margin: 5px;
}
#media screen and (max-width: 1000px) {
#newOrderControl {
width: min-content + 10;
}
input {
width: 5em;
}
#newOrderInputFields {
grid-template-rows: 2em 2em 2em 2em;
grid-template-columns: 13.5em 13.5em;
}
#txtOrderAmount {
margin-left: 19px;
}
#txtOrderLimitPrice {
margin-left: 2px;
}
#txtOrderLimitPerc {
margin-left: 7px;
}
#txtOrderCoin {
margin-left: 37px;
}
#txtOrderTargetPrice {
margin-left: 5px;
}
#txtOrderAction {
margin-left: 27px;
}
#txtOrderQuantity {
margin-left: 17px;
}
#txtOrderTargetPrice {
margin-left: 0px;
}
#txtOrderTargetPerc {
margin-left: 4px;
}
#Action_Quantity {
grid-area: 2 / 1 / span 1 / span 1;
}
#Action_TrgtPrice {
grid-area: 3 / 1 / span 1 / span 1;
}
#Action_TrgtPerc {
grid-area: 4 / 1 / span 1 / span 1;
}
#newOrderButtons {
display: flex;
width: 100%;
height: auto;
justify-content: space-evenly;
}
}
<div id="newOrderControl">
<label class="title">New order</label>
<div id="newOrderInputFields">
<div class="inputField">
<label class="inputLabel">Action:</label>
<select id="txtOrderAction">
<option value="">-</option>
<option value="Buy">Buy</option>
<option value="Sell">Sell</option>
</select>
</div>
<div class="inputField" id="Action_Quantity">
<label class="inputLabel">Quantity:</label>
<input type="text" id="txtOrderQuantity">
<button class="btnAll" onclick="setAllQuantity()">All</button>
</div>
<div class="inputField" id="Action_TrgtPrice">
<label class="inputLabel">Target price:</label>
<input type="text" id="txtOrderTargetPrice">
</div>
<div class="inputField" id="Action_TrgtPerc">
<label class="inputLabel">Target perc:</label>
<input type="text" id="txtOrderTargetPerc">
</div>
<div class="inputField">
<label>Coin:</label>
<select id="txtOrderCoin">
<option value="">-</option>
<option value="">SPTF</option>
<option value="">TLS</option>
</select>
</div>
<div class="inputField">
<label class="inputLabel">Amount:</label>
<input type="text" id="txtOrderAmount">
<button class="btnAll" onclick="setAllAmount()">All</button>
</div>
<div class="inputField">
<label class="inputLabel">Limit price:</label>
<input type="text" id="txtOrderLimitPrice">
</div>
<div class="inputField">
<label class="inputLabel">Limit perc:</label>
<input type="text" id="txtOrderLimitPerc">
</div>
</div>
<div id="newOrderButtons">
<button id="btnTakeProfit">Take profit</button>
<button id="btnPlaceOrder">Place order</button>
</div>
</div>

Related

Image not allowing neighboring div to align correctly

I'm designing an online clothing store, and on the product's page I want the product info (on the right) to align with the center of the image (on the left) while both of the divs are centered with the page. However, it seems that no matter what I do, the product info is always pushed down to the bottom corner of the image. It works when the image is removed completely, but unless that happens no formatting in CSS will affect the product-info div.
I've tried floating the elements to the left but that negates the text-align that keeps them centered, and any padding, margin, or dimension changes I make to the product-info only adds to the bottom of the div rather than shifting it up. There's probably something obvious that I'm overlooking, but I've been working on this problem for so long and just can't seem to find a fix.
Can someone please help me?
> Screenshot of how it looks <
* {
margin: 0px;
padding: 0px;
}
.product {
text-align: center;
}
.product-view {
top: 40px;
padding: 10px;
margin: 10px;
display: inline-block;
}
#product-image {
width: 400px;
height: 40%;
min-width: 40%;
min-height: 40%;
padding: 20px;
}
.product-info {
display: inline-block;
padding: 10px;
margin: 10px;
}
#product-name {
font-size: 25px;
text-transform: uppercase;
text-align: left;
}
#product-price {
font-size: 20px;
padding: 20px 0px;
text-align: left;
}
.product-info hr {
width: 278px;
opacity: 0.4;
}
#product-sizes {
padding: 5px;
text-align: center;
text-transform: uppercase;
width: fit-content;
}
#size-radio-btn {
display: inline-block;
width: 40px;
height: 40px;
text-align: center;
font-size: 15px;
border: 1px solid black;
margin: 5px 10px;
margin-left: 5px;
margin-right: 5px;
line-height: 40px;
color: black;
cursor: pointer;
}
#add-to-cart {
width: 278px;
height: 40px;
margin: 0 5px;
cursor: pointer;
background-color: black;
color: white;
text-transform: uppercase;
font-size: 15px;
float: left;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<div class="content">
<div class="product">
<div class="product-view">
<img id="product-image" src="/Media/hoodieblack.png">
</div>
<div class="product-info">
<div id="product-name">
<h3>Hoodie - Black</h3>
</div>
<div id="product-price">
<p>$80.00</p>
</div>
<hr>
<div id="product-sizes">
<label for="size-select">Size</label>
<div id="size-select">
<input type="radio" name="size" value="s" hidden id="s-size">
<label for="s-size" id="size-radio-btn">S</label>
<input type="radio" name="size" value="m" hidden id="m-size">
<label for="m-size" id="size-radio-btn">M</label>
<input type="radio" name="size" value="l" hidden id="l-size">
<label for="l-size" id="size-radio-btn">L</label>
<input type="radio" name="size" value="xl" hidden id="xl-size">
<label for="xl-size" id="size-radio-btn">XL</label>
<input type="radio" name="size" value="xxl" hidden id="xxl-size">
<label for="xxl-size" id="size-radio-btn">XXL</label>
</div>
</div>
<button type="button" id="add-to-cart">Add to Cart</button>
</div>
</div>
</div>
</body>
</html>
Simply add display: flex; to the main parent, in this case, .product. Then you can use align-items: center; to get them in line with one another.
You can also add max-width: 100%; to the image so it resizes accordingly.
* {
margin: 0px;
padding: 0px;
}
.product {
text-align: center;
}
.product-view {
top: 40px;
padding: 10px;
margin: 10px;
display: inline-block;
}
#product-image {
width: 400px;
height: 40%;
min-width: 40%;
min-height: 40%;
padding: 20px;
}
.product-info {
display: inline-block;
padding: 10px;
margin: 10px;
}
#product-name {
font-size: 25px;
text-transform: uppercase;
text-align: left;
}
#product-price {
font-size: 20px;
padding: 20px 0px;
text-align: left;
}
.product-info hr {
width: 278px;
opacity: 0.4;
}
#product-sizes {
padding: 5px;
text-align: center;
text-transform: uppercase;
width: fit-content;
}
#size-radio-btn {
display: inline-block;
width: 40px;
height: 40px;
text-align: center;
font-size: 15px;
border: 1px solid black;
margin: 5px 10px;
margin-left: 5px;
margin-right: 5px;
line-height: 40px;
color: black;
cursor: pointer;
}
#add-to-cart {
width: 278px;
height: 40px;
margin: 0 5px;
cursor: pointer;
background-color: black;
color: white;
text-transform: uppercase;
font-size: 15px;
}
.product {
display: flex;
align-items: center;
justify-content: center;
}
#product-image {
max-width: 100%;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<div class="content">
<div class="product">
<div class="product-view">
<img id="product-image" src="https://dummyimage.com/800/000/fff">
</div>
<div class="product-info">
<div id="product-name">
<h3>Hoodie - Black</h3>
</div>
<div id="product-price">
<p>$80.00</p>
</div>
<hr>
<div id="product-sizes">
<label for="size-select">Size</label>
<div id="size-select">
<input type="radio" name="size" value="s" hidden id="s-size">
<label for="s-size" id="size-radio-btn">S</label>
<input type="radio" name="size" value="m" hidden id="m-size">
<label for="m-size" id="size-radio-btn">M</label>
<input type="radio" name="size" value="l" hidden id="l-size">
<label for="l-size" id="size-radio-btn">L</label>
<input type="radio" name="size" value="xl" hidden id="xl-size">
<label for="xl-size" id="size-radio-btn">XL</label>
<input type="radio" name="size" value="xxl" hidden id="xxl-size">
<label for="xxl-size" id="size-radio-btn">XXL</label>
</div>
</div>
<button type="button" id="add-to-cart">Add to Cart</button>
</div>
</div>
</div>
</body>
</html>

CSS divs not horizontally aligned properly [duplicate]

This question already has answers here:
Align inline-block DIVs to top of container element
(5 answers)
Closed 4 years ago.
This is probably a stupid question, but it has been driving me crazy the whole day. I need both divs with the class of contacthor to be aligned on the top, but not forcing them by using margin-top: -x or etc. Here is an image of the issue.
Also, Im new to web design so if I have useless code please explain.
Thanks.
#redcontact {
margin-bottom: 0;
padding-left: 5vh;
font-size: 15px;
line-height: 30px;
background: black;
}
.contacthor {
display: inline-block;
}
form > .contacthor > .input {
color: #C5B358;
font-size: 15px;
background-color: black;
margin-top: 0;
margin-left: 1vh;
margin-bottom: 1vh;
height: 30px;
width: 190px;
display: block;
}
.contacthor > textarea {
color: #C5B358;
font-size: 15px;
font-family: 'Montserrat', sans-serif;
width: 60vh;
height: 25vh;
background: black;
border: 1px;
border-style: solid;
border-radius: 3px;
border-color: grey;
padding-left: 4px;
margin-top: 0;
margin-bottom: 1vh;
margin-left: 1vh;
}
<div id="redcontact">
<form action="action_page.php">
<div class="contacthor">
<label for="name">Nombre</label>
<input class="input" type="text" name="name_user" placeholder="test">
<label for="org">Empresa</label>
<input class="input" type="text" name="org" placeholder="test">
<label for="mail">Mail</label>
<input class="input" type="text" name="mail" placeholder="contacto#test.com">
</div>
<div class="contacthor">
<p>Mensaje</p>
<textarea name="mensaje" tabindex="5" placeholder="text..."></textarea>
<input type="submit" value="enviar">
</div>
</form>
</div>
I would agree with Chere's answer in that you should be using something like CSS Grid or Flexbox. However, if you want to stay simple for this example, or just want to know why your code isn't working, here is a solution:
#redcontact {
margin-bottom: 0;
padding-left: 5vh;
font-size: 15px;
line-height: 30px;
background: black;
}
.contacthor {
display: inline-block;
}
form>.contacthor>.input {
color: #C5B358;
font-size: 15px;
background-color: black;
margin-top: 0;
margin-left: 1vh;
margin-bottom: 1vh;
height: 30px;
width: 190px;
display: block;
}
.contacthor>textarea {
color: #C5B358;
font-size: 15px;
font-family: 'Montserrat', sans-serif;
width: 60vh;
height: 25vh;
background: black;
border: 1px;
border-style: solid;
border-radius: 3px;
border-color: grey;
padding-left: 4px;
margin-top: 0;
margin-bottom: 1vh;
margin-left: 1vh;
}
.contacthor>p {
margin-bottom: 5px;
margin-top: 0;
margin-bottom: 1vh;
margin-left: 1vh;
}
.contacthor>input[value=enviar] {
display: block;
margin-top: 0;
margin-bottom: 1vh;
margin-left: 1vh;
}
/* ===== Styles to fix example ===== */
label, p {
color: white;
}
/* ===== Styles to answer your question ===== */
.contacthor {
vertical-align: top;
}
<div id="redcontact">
<form action="action_page.php">
<div class="contacthor">
<label for="name">Nombre</label>
<input class="input" type="text" name="name_user" placeholder="test">
<label for="org">Empresa</label>
<input class="input" type="text" name="org" placeholder="test">
<label for="mail">Mail</label>
<input class="input" type="text" name="mail" placeholder="contacto#test.com">
</div>
<div class="contacthor">
<p>Mensaje</p>
<textarea name="mensaje" tabindex="5" placeholder="text..."></textarea>
<input type="submit" value="enviar">
</div>
</form>
</div>
The main thing to take away from this is the addition of vertical-align: top. Here is a similar question and here is the documentation for the vertical-align property.
Note: I think there may have been some CSS missing, so the snippet looks a bit odd and I had to make a couple of unrelated changes.
Why is there a . before the input?
Also, I highly recommend not using vh or pixels. You should go with em. Without doing everything, you should probably try to do something like that, with flexbox.
#redcontact {
width: 100%;
height: 100%;
font-size: 15px;
line-height: 1.5;
background-color: #000;
color: #fff;
}
form {
display: flex;
padding: 2em;
.contacthor {
display: flex;
flex-direction: column;
width: 50%;
padding: 0 2em;
input,
textarea {
color: #C5B358;
background-color: transparent;
margin-left: 1em;
margin-bottom: 1em;
padding: 0.5em 1em;
width: auto;
display:block;
}
input {
border: 0;
}
textarea {
border: 1px solid grey;
border-radius: 3px;
}
}
}
I have made a grid. See if you are looking for somewhat similar thing.
https://codepen.io/kalpeshshende/pen/qJjomO
form{
display:grid;grid-gap:10px;
grid-template-columns:1fr 2fr;
}
.holder{
max-width:600px;
margin:auto;
background:black;
color:#C5B358;padding:10px;
}
.contacthor{
display:grid;grid-gap:10px;
}
textarea{
height:100px;
}
input[type=submit]{
width:120px;
}
p{
padding:0px;
}
input[type=text]{
background:black;
color:;border:none;
}
Markup :
<body>
<div class="holder">
<form action="">
<div class="contacthor">
<label for="name" >Nombre</label>
<input class="input" type="text" name="name_user" placeholder="test">
<label for="org">Empresa</label>
<input class="input" type="text" name="org" placeholder="test">
<label for="mail">Mail</label>
<input class="input" type="text" name="mail" placeholder="contacto#test.com">
</div>
<div class="contacthor">
<label for="Mensaje">Mensaje</label>
<textarea name="mensaje" tabindex="5" placeholder="text..."></textarea>
<input type="submit" value="enviar">
</div>
</form>
</div>
</body>
Try adding vertical-align: top; to contracthor.

How to properly absolute positioning in reactjs

The whole thing is a misunderstanding on my part please ignore!
I have tried to research this problem but the only solution that came up were for react native. My problem basically is that the CSS behaves differently in reactjs environment then in a regular one. Here is what I mean:
class TodoApp extends React.Component {
constructor(props) {
super(props)
this.state = {
items: [
{ text: "Learn JavaScript", done: false },
{ text: "Learn React", done: false },
{ text: "Play around in JSFiddle", done: true },
{ text: "Build something awesome", done: true }
]
}
}
render() {
return (
<form>
<div id="cart">
{/* Cart Header */}
<div id="cart-header">
<div id="edit-icon" className="header-icon">
<p>EDIT</p>
</div>
<div className="header-line"></div>
<div id="payment-icon" className="header-icon">
<p>PAYMENT</p>
</div>
<div className="header-line"></div>
<div id="confirm-icon" className="header-icon">
<p>COMFIRM</p>
</div>
</div>
{/* Cart Body */}
{/* Personal information */}
<div id="cart-body-left" className="cart-body">
<h2>Personal information</h2>
<fieldset id="info-fieldset">
<div id="name" className="input-div-container">
<div id="first-name" className="input-div">
<input type="text" placeholder="First Name"/>
<label className="input-label">First Name</label>
</div>
<div id="last-name" className="input-div">
<input type="text" placeholder="Last Name" />
<label className="input-label">Last Name</label>
</div>
</div>
<div id="email" className="input-div">
<input type="email" placeholder="Email" />
<label className="input-label">Email</label>
</div>
<div id="number" className="input-div">
<input type="text" placeholder="Number" />
<label className="input-label">Number</label>
</div>
<div id="address-apt" className="input-div-container">
<div id="address" className="input-div">
<input type="text" placeholder="Address" />
<label className="input-label">Adress</label>
</div>
<div id="apt" className="input-div">
<input type="text" placeholder="Apt, Unit, etc" />
<label className="input-label">Apt, Unit, etc</label>
</div>
</div>
<div id="zip-city-state" className="input-div-container">
<div id="zip" className="input-div">
<input type="text" placeholder="Zip" />
<label className="input-label">Zip</label>
</div>
<div id="city" className="input-div">
<input type="text" placeholder="City" />
<label className="input-label">City</label>
</div>
<div id="state" className="input-div">
<select id="state-select">
<option value="AL">AL</option>
<option value="AK">AK</option>
<option value="AS">AS</option>
<option value="AZ">AZ</option>
<option value="AR">AR</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DE">DE</option>
<option value="DC">DC</option>
<option value="FM">FM</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="GU">GU</option>
<option value="HI">HI</option>
<option value="ID">ID</option>
<option value="IL">IL</option>
<option value="IN">IN</option>
<option value="IA">IA</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="ME">ME</option>
<option value="MH">MH</option>
<option value="MD">MD</option>
<option value="MA">MA</option>
<option value="MI">MI</option>
<option value="MN">MN</option>
<option value="MS">MS</option>
<option value="MO">MO</option>
<option value="MT">MT</option>
<option value="NE">NE</option>
<option value="NV">NV</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>
<option value="NY">NY</option>
<option value="NC">NC</option>
<option value="ND">ND</option>
<option value="MP">MP</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>
<option value="PW">PW</option>
<option value="PA">PA</option>
<option value="PR">PR</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SD</option>
<option value="TN">TN</option>
<option value="TX">TX</option>
<option value="UT">UT</option>
<option value="VT">VT</option>
<option value="VI">VI</option>
<option value="VA">VA</option>
<option value="WA">WA</option>
<option value="WV">WV</option>
<option value="WI">WI</option>
<option value="WY">WY</option>
</select>
</div>
</div>
</fieldset>
</div>
{/* Credit Card Information */}
<div id="cart-body-right" className="cart-body">
<h2>Credit Card Information</h2>
<fieldset id="cc-fieldset">
<div id="cc-number" className="input-div">
<input type="number" placeholder="Credit Card Number" />
</div>
<div id="cc-valid" className="input-div-container">
<div id="cc-expiration" className="input-div">
<input type="text" placeholder="MM/YY" />
</div>
<div id="cc-cvv" className="input-div">
<input type="text" placeholder="CVV" />
</div>
<div id="cvv-help" className="input-div">
<img height="18px" width="18px" src="store/img/question-mark.png" />
</div>
</div>
</fieldset>
<div id="cart-stats">
<div className="stats">
<span>cart total:</span>
<span>something</span>
</div>
<div className="stats">
<span>cart total:</span>
<span>something</span>
</div>
<div className="stats">
<span>cart total:</span>
<span>something</span>
</div>
</div>
<div id="terms-conditions">
<div className="checkbox">
<input type="checkbox" id="tc-checkbox" value="0" />
<label htmlFor="tc-checkbox">Bla bla bla </label>
</div>
</div>
</div>
{/* Cart Footer */}
<div className="cart-footer" id="cart-footer-left">
<div id="coupon">
<div id="coupon-input">
<input type="text"/>
</div>
<div id="coupon-button">
<button>hello</button>
</div>
</div>
</div>
<div className="cart-footer" id="cart-footer-right">
</div>
</div>
</form>
)
}
}
ReactDOM.render(<TodoApp />, document.querySelector("#app"))
:root {
--gold: #e5cb51;
--silver: #666666;
--light-silver: #ddd;
}
::placeholder {
color: var(--silver);
}
h2 {
text-align: center;
color: white;
color: var(--light-silver);
font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
}
body {
background-color: black;
}
p {
font-family: Raleway;
}
#cart {
margin: auto;
margin-top: 100px;
width: 800px;
display: grid;
grid-template-areas:
"h h" /* Header */
"bl br" /* Body left right */
"fl fr"; /* Footer left right */
}
#cart-header {
background-color: black;
border: 1.5px solid var(--gold);
border-bottom: 0px;
border-top-left-radius: 1em;
border-top-right-radius: 1em;
grid-area: h;
display: flex;
justify-content: center;
padding: 1em 0;
}
#cart-body-left {
grid-area: bl;
}
#cart-body-right {
grid-area: br;
border-left-width: 0;
}
#cart-footer-left {
grid-area: fl;
border-bottom-left-radius: 1em;
}
#cart-footer-right {
grid-area: fr;
border-bottom-right-radius: 1em;
}
.cart-body {
width: 400px;
height: 400px;
border: 1.5px solid var(--gold);
background-color: black;
}
.cart-footer {
height: 50px;
width: 400px;
background-color: var(--gold);
}
#email {
box-sizing: border-box;
padding-bottom: 1em;
}
#number {
box-sizing: border-box;
}
#state > select{
height: 100%;
border: 1.5px var(--silver) solid;
border-radius: 3px;
}
#cc-paypal-option {
padding-left: 50%;
margin: 1em;
border: 1px solid white;
border-bottom-left-radius: .5em;
border-bottom-right-radius: .5em;
padding-bottom: 1em;
}
#cc-paypal-option > button {
height: 31px;
}
#cart-stats {
margin: 1em;
border: 1.5px var(--gold) solid;
border-radius: .5em;
}
#cart-stats > div:nth-child(2) {
border-top: 1px var(--gold) solid;
border-bottom: 1px var(--gold) solid;
padding: .5em 0;
margin: .5em 0;
}
#coupon {
height: 40px;
width: 300px;
margin: 5px 50px;
background-color: black;
display: flex;
}
#coupon > div {
width: 200px;
position: relative;
}
#coupon-input input {
position: absolute;
height: 100%;
right: 0;
width: 0;
opacity: 1;
transition: all .2s ease-in;
}
#coupon-button button {
height: 100%;
}
#cart-footer-left:hover input[type="text"] {
width: 100px;
opacity: 1;
transition: all .2s ease-out;
}
.header-line {
width: 75px;
height: 0px;
border: 1px solid var(--gold);
margin: auto 0;
background-color: var(--gold);
}
.header-icon {
height: 2em;
width: 120px;
border: 1.5px solid var(--gold);
border-radius: 4px;
margin: .5em 0px;
padding-top: .1em;
}
.active-icon {}
.header-icon:hover {
background-color: var(--gold);
}
.header-icon:hover > p{
color: black;
}
.header-icon > p {
text-align: center;
color: var(--light-silver);
font-weight: bold;
font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 1.2em;
letter-spacing: 2px;
line-height: 1.45;
}
.input-label {
visibility: visible;
position: absolute;
display: block;
color: white;
top: 0;
font-size: 1em;
opacity: 1;
transform: translateY(-1.5em);
transition: all 0.2s ease-out;
margin-left: 10px;
display: inline;
}
input:placeholder-shown + label {
opacity: 0;
visibility: hidden;
text-align: center;
transform: translateY(.5em);
}
.input-div-container {
display: flex;
}
.input-div {
position: relative;
padding: 1em;
/* height: 33px; */
}
/* #first-name,
#last-name {
width: 198.5px;
} */
.input-div > input {
width: 100%;
padding: 5px 10px;
border-radius: 3px;
border: 1.5px var(--silver) solid;
display: block;
}
.input-div > input:focus, #state > select:focus {
outline: none;
border: solid var(--gold) 1.5px;
box-shadow: 0 0 5px var(--gold);
}
.stats {
margin: .5em;
display: flex;
justify-content: center;
}
.stats > span {
padding: 0 1em;
color: var(--light-silver);
}
.checkbox {
position: relative;
margin: 1em;
margin-top: 1.3em;
}
.checkbox input[type="checkbox"] {
position: absolute;
top: 0;
left: 0;
width: 0;
height: 0;
opacity: 0;
pointer-events: none;
}
.checkbox label::before {
display: block;
position: absolute;
top: 0;
left: 0;
width: 28px;
height: 28px;
background-color: white;
content: '';
}
.checkbox input[type="checkbox"]:checked + label::before {
background-color: var(--gold);
color: white;
}
.checkbox input[type="checkbox"]:checked + label::after {
display: block;
position: absolute;
top: 1px;
left: 8.5px;
width: 10px;
height: 20px;
/* background: black; */
border: solid black;
border-width: 0 3px 3px 0;
transform: rotate(45deg);
content: '';
}
#media screen and (max-width: 900px) {
#cart {
width: 400px;
display: grid;
grid-template-areas:
"h"
"bl"
"fl"
"br"
"fr";
}
#cart-header {
width: 400px;
}
.header-icon {
width: 75px;
}
.header-icon p {
font-size: .7em;
letter-spacing: 2px;
line-height: 2.5;
}
#cart-body-right {
border-left-width: 1.5px;
}
#cart-footer-left {
border-radius: 0px;
}
#cart-footer-right {
border-bottom-left-radius: 1em;
border-bottom-right-radius: 1em;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="app"></div>
Here is how it looks like when I render it without react
How it looks like after I paste my code into jsx
I hope I have provided enough code and if not I can add on to it
I'm not sure this is a react specific issue. I pasted your code into JSFiddle and did not run into the same issues you are having. Positioned elements will only default to root if there are no other positioned ancestors. Might be worth looking through your HTML to see if there is a positioned parent or ancestor messing with your positioning.

How can I get the label text to the left of the input field?

I am not able to understand how I can get the label from top of the input field to the left. The label text is on top of the input field. How can I get it to the left of the input field for the contact information part? Any help would be appreciated. Thanks a lot.
This is my code:
#p1 {
text-align: center;
background-color: black;
color: white;
padding: 20px;
}
#h31 {
text-align: center;
}
#p2 {
text-align: center;
}
input[type="text"] {
border: 2px solid grey;
border-radius: 4px;
padding: 6px;
width: 90%;
background-color: #d3d3d3;
display: block;
margin: 8px 0;
}
input[type="text"]:focus {
border: 2px solid blue;
}
input[type="email"]:focus {
border: 2px solid blue;
}
::placeholder {
text-align: right;
}
input[type="submit"] {
background-color: #3cbc8d;
color: white;
border-radius: 4px;
padding: 16px 32px;
width: 100%;
}
input[type="email"] {
border: 2px solid grey;
padding: 6px;
width: 90%;
background-color: #d3d3d3;
display: block;
margin: 8px 0;
}
#p3 {
text-align: center;
}
#submitdiv {
text-align: center;
}
#textareadiv {
text-align: center;
}
textarea {
width: 100%;
}
hr {
width: 100%;
}
select {
background-color: #d3d3d3;
padding: 6px;
width: 90%;
display: block;
margin: 8px 0;
}
input[id="zipcode"] {
width: 40%;
}
body {
font-family: 'Merriweather', serif;
}
fieldset {
border: none;
}
#media screen and (min-width: 768px) {
.formcenter {
text-align: center;
display: block;
}
form {
text-align: left;
margin-left: auto;
margin-right: auto;
display: inline-block;
}
select {
width: 90%;
padding: 6px;
border-radius: 4px;
}
#p1 {
width: 100%;
}
hr {
width: 100%;
}
}
<link href="https://fonts.googleapis.com/css?family=Merriweather" rel="stylesheet">
<p id="p1">THE CODE REVIEW</p><br><br>
<div class="formcenter">
<form method="post" action="project3.html">
<h3 id="h31">Sign up for our newsletter</h3>
<p id="p2">Get the latest news on how your code is doing right in your inbox</p>
<hr>
<hr>
<fieldset>
<legend>
<h3 id="h32">Contact Information</h3>
</legend>
<label for="inputfield">Full Name</label>
<input type="text" name="fullname" placeholder="Required" id="inputfield">
<label for="inputfield1">Email Address</label>
<input type="email" name="emailaddress" placeholder="Required" id="inputfield1">
<label for="inputfield2">Phone Number</label>
<input type="text" name="phonenumber" id="inputfield2">
<label for="inputfield3">Street Address</label>
<input type="text" name="streetaddress" id="inputfield3">
<label for="inputfield4">City</label>
<input type="text" name="city" id="inputfield4">
<label for="stateselect">State</label>
<select name="state" id="stateselect">
<option>Choose State</option>
<option value="mah">Maharashtra</option>
<option value="guj">Gujarat</option>
<option value="pun">Punjab</option>
</select>
<label for="zipcode">Zip Code</label>
<input type="text" name="zipcode" id="zipcode">
</fieldset>
<hr>
<fieldset>
<legend>
<h3>Newsletter</h3>
</legend><br>
<label>Select the newsletters you would like to receive</label><br><br>
<input type="checkbox" name="htmlnews"><label>HTML News</label><br><br>
<input type="checkbox" name="css"><label>CSS News</label><br><br>
<input type="checkbox" name="javascript"><label>Javascript News</label><br><br>
<label>Newsletter format</label><br><br>
<input type="radio" name="newsletter" value="html"><label>HTML</label><br><br>
<input type="radio" name="newsletter" value="plaintext"><label>Plain Text</label><br><br>
<label>Other topics you'd like to hear about</label><br><br>
<div id="textareadiv">
<textarea rows="5" cols="30"></textarea><br><br>
</div>
<div id="submitdiv">
<input type="submit" value="Sign Up"><br><br>
</div>
</fieldset>
<p id="p3"><i>Copyright The Code Review</i></p>
</form>
</div>
You can reset width and display on inputs and/or use float.
It can be a reset at any time or within the mediaquerie.
You can also filter within which fieldset you need this reset to be effective.(example below)
.formcenter fieldset:first-of-type label,
.formcenter fieldset:first-of-type input{
float: left;
line-height: 1.2em;
padding: 6px;
margin: 8px 0;
width: 50%;
}
.formcenter fieldset:first-of-type label {
clear: left;
width: 35%;
}
input[type="checkbox"],
input[type="radio"]{
margin-right:1em;
}
fieldset ~ fieldset br + label {
margin:1em;
color:gray
}
#p1 {
text-align: center;
background-color: black;
color: white;
padding: 20px;
}
#h31 {
text-align: center;
}
#p2 {
text-align: center;
}
input[type="text"] {
border: 2px solid grey;
border-radius: 4px;
padding: 6px;
width: 90%;
background-color: #d3d3d3;
display: block;
margin: 8px 0;
}
input[type="text"]:focus {
border: 2px solid blue;
}
input[type="email"]:focus {
border: 2px solid blue;
}
::placeholder {
text-align: right;
}
input[type="submit"] {
background-color: #3cbc8d;
color: white;
border-radius: 4px;
padding: 16px 32px;
width: 100%;
}
input[type="email"] {
border: 2px solid grey;
padding: 6px;
width: 90%;
background-color: #d3d3d3;
display: block;
margin: 8px 0;
}
#p3 {
text-align: center;
}
#submitdiv {
text-align: center;
}
#textareadiv {
text-align: center;
}
textarea {
width: 100%;
}
hr {
width: 100%;
}
select {
background-color: #d3d3d3;
padding: 6px;
width: 90%;
display: block;
margin: 8px 0;
}
input[id="zipcode"] {
width: 40%;
}
body {
font-family: 'Merriweather', serif;
}
fieldset {
border: none;
}
#media screen and (min-width: 768px) {
.formcenter {
text-align: center;
display: block;
}
form {
text-align: left;
margin-left: auto;
margin-right: auto;
display: inline-block;
}
select {
width: 90%;
padding: 6px;
border-radius: 4px;
}
#p1 {
width: 100%;
}
hr {
width: 100%;
}
.formcenter fieldset:first-of-type label,
.formcenter fieldset:first-of-type input{
float: left;
line-height: 1.2em;
padding: 6px;
margin: 8px 0;
width: 50%;
}
.formcenter fieldset:first-of-type label {
clear: left;
width: 35%;
}
input[type="checkbox"],
input[type="radio"]{
margin-right:1em;
}
fieldset ~ fieldset br + label {
margin:1em;
color:gray
}
}
<link href="https://fonts.googleapis.com/css?family=Merriweather" rel="stylesheet">
<p id="p1">THE CODE REVIEW</p><br><br>
<div class="formcenter">
<form method="post" action="project3.html">
<h3 id="h31">Sign up for our newsletter</h3>
<p id="p2">Get the latest news on how your code is doing right in your inbox</p>
<hr>
<hr>
<fieldset>
<legend>
<h3 id="h32">Contact Information</h3>
</legend>
<label for="inputfield">Full Name</label>
<input type="text" name="fullname" placeholder="Required" id="inputfield">
<label for="inputfield1">Email Address</label>
<input type="email" name="emailaddress" placeholder="Required" id="inputfield1">
<label for="inputfield2">Phone Number</label>
<input type="text" name="phonenumber" id="inputfield2">
<label for="inputfield3">Street Address</label>
<input type="text" name="streetaddress" id="inputfield3">
<label for="inputfield4">City</label>
<input type="text" name="city" id="inputfield4">
<label for="stateselect">State</label>
<select name="state" id="stateselect">
<option>Choose State</option>
<option value="mah">Maharashtra</option>
<option value="guj">Gujarat</option>
<option value="pun">Punjab</option>
</select>
<label for="zipcode">Zip Code</label>
<input type="text" name="zipcode" id="zipcode">
</fieldset>
<hr>
<fieldset>
<legend>
<h3>Newsletter</h3>
</legend><br>
<label>Select the newsletters you would like to receive</label><br><br>
<input type="checkbox" name="htmlnews"><label>HTML News</label><br><br>
<input type="checkbox" name="css"><label>CSS News</label><br><br>
<input type="checkbox" name="javascript"><label>Javascript News</label><br><br>
<label>Newsletter format</label><br><br>
<input type="radio" name="newsletter" value="html"><label>HTML</label><br><br>
<input type="radio" name="newsletter" value="plaintext"><label>Plain Text</label><br><br>
<label>Other topics you'd like to hear about</label><br><br>
<div id="textareadiv">
<textarea rows="5" cols="30"></textarea><br><br>
</div>
<div id="submitdiv">
<input type="submit" value="Sign Up"><br><br>
</div>
</fieldset>
<p id="p3"><i>Copyright The Code Review</i></p>
</form>
</div>
You can use display:flex with a container for each lines
.line
{
display:flex;
align-items:center;
}
.line label
{
min-width:200px;
}
input
{
flex:1;
margin:10px;
}
#p1 {
text-align: center;
background-color: black;
color: white;
padding: 20px;
}
#h31 {
text-align: center;
}
#p2 {
text-align: center;
}
input[type="text"] {
border: 2px solid grey;
border-radius: 4px;
padding: 6px;
width: 90%;
background-color: #d3d3d3;
display: block;
margin: 8px 0;
}
input[type="text"]:focus {
border: 2px solid blue;
}
input[type="email"]:focus {
border: 2px solid blue;
}
::placeholder {
text-align: right;
}
input[type="submit"] {
background-color: #3cbc8d;
color: white;
border-radius: 4px;
padding: 16px 32px;
width: 100%;
}
input[type="email"] {
border: 2px solid grey;
padding: 6px;
width: 90%;
background-color: #d3d3d3;
display: block;
margin: 8px 0;
}
#p3 {
text-align: center;
}
#submitdiv {
text-align: center;
}
#textareadiv {
text-align: center;
}
textarea {
width: 100%;
}
hr {
width: 100%;
}
select {
background-color: #d3d3d3;
padding: 6px;
width: 90%;
display: block;
margin: 8px 0;
}
input[id="zipcode"] {
width: 40%;
}
body {
font-family: 'Merriweather', serif;
}
fieldset {
border: none;
}
#media screen and (min-width: 768px) {
.formcenter {
text-align: center;
display: block;
}
form {
text-align: left;
margin-left: auto;
margin-right: auto;
display: inline-block;
}
select {
width: 90%;
padding: 6px;
border-radius: 4px;
}
#p1 {
width: 100%;
}
hr {
width: 100%;
}
}
<link href="https://fonts.googleapis.com/css?family=Merriweather" rel="stylesheet">
<p id="p1">THE CODE REVIEW</p><br><br>
<div class="formcenter">
<form method="post" action="project3.html">
<h3 id="h31">Sign up for our newsletter</h3>
<p id="p2">Get the latest news on how your code is doing right in your inbox</p>
<hr>
<hr>
<fieldset>
<legend>
<h3 id="h32">Contact Information</h3>
</legend>
<div class="line">
<label for="inputfield">Full Name :</label>
<input type="text" name="fullname" placeholder="Required" id="inputfield">
</div>
<div class="line">
<label for="inputfield1">Email Address :</label>
<input type="email" name="emailaddress" placeholder="Required" id="inputfield1">
</div>
<div class="line">
<label for="inputfield2">Phone Number :</label>
<input type="text" name="phonenumber" id="inputfield2">
</div>
<div class="line">
<label for="inputfield3">Street Address :</label>
<input type="text" name="streetaddress" id="inputfield3">
</div>
<div class="line">
<label for="inputfield4">City :</label>
<input type="text" name="city" id="inputfield4">
</div>
<div class="line">
<label for="stateselect">State :</label>
<select name="state" id="stateselect">
<option>Choose State</option>
<option value="mah">Maharashtra</option>
<option value="guj">Gujarat</option>
<option value="pun">Punjab</option>
</select>
</div>
<div class="line">
<label for="zipcode">Zip Code :</label>
<input type="text" name="zipcode" id="zipcode">
</div>
</fieldset>
<hr>
<fieldset>
<legend>
<h3>Newsletter</h3>
</legend><br>
<label>Select the newsletters you would like to receive</label><br><br>
<input type="checkbox" name="htmlnews"><label>HTML News</label><br><br>
<input type="checkbox" name="css"><label>CSS News</label><br><br>
<input type="checkbox" name="javascript"><label>Javascript News</label><br><br>
<label>Newsletter format</label><br><br>
<input type="radio" name="newsletter" value="html"><label>HTML</label><br><br>
<input type="radio" name="newsletter" value="plaintext"><label>Plain Text</label><br><br>
<label>Other topics you'd like to hear about</label><br><br>
<div id="textareadiv">
<textarea rows="5" cols="30"></textarea><br><br>
</div>
<div id="submitdiv">
<input type="submit" value="Sign Up"><br><br>
</div>
</fieldset>
<p id="p3"><i>Copyright The Code Review</i></p>
</form>
</div>
Swap your labels and inputs to get desired result:
#p1 {
text-align: center;
background-color: black;
color: white;
padding: 20px;
}
#h31 {
text-align: center;
}
#p2 {
text-align: center;
}
input[type="text"] {
border: 2px solid grey;
border-radius: 4px;
padding: 6px;
width: 90%;
background-color: #d3d3d3;
display: block;
margin: 8px 0;
}
input[type="text"]:focus {
border: 2px solid blue;
}
input[type="email"]:focus {
border: 2px solid blue;
}
::placeholder {
text-align: right;
}
input[type="submit"] {
background-color: #3cbc8d;
color: white;
border-radius: 4px;
padding: 16px 32px;
width: 100%;
}
input[type="email"] {
border: 2px solid grey;
padding: 6px;
width: 90%;
background-color: #d3d3d3;
display: block;
margin: 8px 0;
}
#p3 {
text-align: center;
}
#submitdiv {
text-align: center;
}
#textareadiv {
text-align: center;
}
textarea {
width: 100%;
}
hr {
width: 100%;
}
select {
background-color: #d3d3d3;
padding: 6px;
width: 90%;
display: block;
margin: 8px 0;
}
input[id="zipcode"] {
width: 40%;
}
body {
font-family: 'Merriweather', serif;
}
fieldset {
border: none;
}
#media screen and (min-width: 768px) {
.formcenter {
text-align: center;
display: block;
}
form {
text-align: left;
margin-left: auto;
margin-right: auto;
display: inline-block;
}
select {
width: 90%;
padding: 6px;
border-radius: 4px;
}
#p1 {
width: 100%;
}
hr {
width: 100%;
}
}
<link href="https://fonts.googleapis.com/css?family=Merriweather" rel="stylesheet">
<p id="p1">THE CODE REVIEW</p><br><br>
<div class="formcenter">
<form method="post" action="project3.html">
<h3 id="h31">Sign up for our newsletter</h3>
<p id="p2">Get the latest news on how your code is doing right in your inbox</p>
<hr>
<hr>
<fieldset>
<legend>
<h3 id="h32">Contact Information</h3>
</legend>
<label for="inputfield">Full Name</label>
<input type="text" name="fullname" placeholder="Required" id="inputfield">
<label for="inputfield1">Email Address</label>
<input type="email" name="emailaddress" placeholder="Required" id="inputfield1">
<label for="inputfield2">Phone Number</label>
<input type="text" name="phonenumber" id="inputfield2">
<label for="inputfield3">Street Address</label>
<input type="text" name="streetaddress" id="inputfield3">
<label for="inputfield4">City</label>
<input type="text" name="city" id="inputfield4">
<label for="stateselect">State</label>
<select name="state" id="stateselect">
<option>Choose State</option>
<option value="mah">Maharashtra</option>
<option value="guj">Gujarat</option>
<option value="pun">Punjab</option>
</select>
<label for="zipcode">Zip Code</label>
<input type="text" name="zipcode" id="zipcode">
</fieldset>
<hr>
<fieldset>
<legend>
<h3>Newsletter</h3>
</legend><br>
<label>Select the newsletters you would like to receive</label><br><br>
<label>HTML News</label><input type="checkbox" name="htmlnews"><br><br>
<label>CSS News</label><input type="checkbox" name="css"><br><br>
<label>Javascript News</label><input type="checkbox" name="javascript"><br><br>
<label>Newsletter format</label><br><br>
<label>HTML</label><input type="radio" name="newsletter" value="html"><br><br>
<label>Plain Text</label><input type="radio" name="newsletter" value="plaintext"><br><br>
<label>Other topics you'd like to hear about</label><br><br>
<div id="textareadiv">
<textarea rows="5" cols="30"></textarea><br><br>
</div>
<div id="submitdiv">
<input type="submit" value="Sign Up"><br><br>
</div>
</fieldset>
<p id="p3"><i>Copyright The Code Review</i></p>
</form>
</div>
You can do this fairly easily:
Full Name: <input type="text" name="fullname" placeholder="Required" id="inputfield">
This will just make the text appear to the left side of the input itself.
I used this method for a newsletter input I was doing:
Name: <input id="nameInput" type="text" name="name" required><br>

Icons after radio button

Why can't I put icon after the radio button ?
Where am I wrong ? I also would like to put three radio buttons horizontally. How can i make this ? It should look like this http://imgur.com/3FbbAql
JS Fiddle : http://jsfiddle.net/5urfzLg3/
#visa:after {
content: '';
display: block;
width: 32px;
height: 28px;
background: url('img/https://upload.wikimedia.org/wikipedia/commons/1/13/Farm-Fresh_visa.png'); }
Replaced Elements(img,input,area,etc.) cannot have :before or :after(Learn more from this SO answer).
To make them horizontal, just display them inline-block:
.box input[type="radio"]{
display:inline-block;
}
I think this is what you want !! Welcome in advance :)
body {
background-image: url('img/formBackground.jpg');
background-repeat: no-repeat;
}
#wrapper {
width: 420px;
height: 900px;
margin: 20 auto;
}
h2 {
color: white;
font-family: Verdana;
font-size: 18px;
padding: 5px;
margin-top: 5px;
margin-bottom: 0px;
}
.box {
padding: 10px;
margin: 5px;
margin-bottom: 2px;
margin-top: 2px;
border: 1px solid rgb(210, 210, 210);
border-radius: 5px;
background-color: rgba(255, 255, 255, 0.2);
}
.box span {
display: inline-block;
width: 100px;
height: 18px;
}
.box input {
width: 210px;
margin: 0 auto;
padding: 4px;
}
.box textarea {
width: 210px;
height: 130px;
max-width: 210px;
}
#specific {
height: 100px;
vertical-align: top;
padding-top: 5px;
padding-left: 5px;
}
::-webkit-input-placeholder {
color: grey;
}
:-moz-placeholder {
/* Firefox 18- */
color: grey;
}
::-moz-placeholder {
/* Firefox 19+ */
color: grey;
}
:-ms-input-placeholder {
color: grey;
}
#visa:after {
content: '';
display: block;
width: 32px;
height: 28px;
background: url('img/Farm-Fresh_visa.png');
}
.box.cards {
clear: both;
display: table;
}
.box.cards span {
float: left;
}
#cards {
float: left;
clear: none;
}
label {
float: left;
clear: none;
display: block;
padding: 0px 1em 0 0;
}
input[type=radio],
input.radio {
float: left;
clear: none;
margin: 3px 3px 0 2px;
width: auto;
}
<body>
<div id="wrapper">
<h2>Step 1: Your details</h2>
<div class="box">
<span>User</span>
<input type="text" name="username" placeholder="First and last name">
</div>
<div class="box">
<span>Email</span>
<input type="email" name="email" placeholder="example#domain.com">
</div>
<div class="box">
<span>Phone</span>
<input type="text" name="phone" placeholder="eg. +44750000000">
</div>
<h2>Step 1: Delivery adress</h2>
<div class="box">
<span id="specific">Adress</span>
<textarea></textarea>
</div>
<div class="box">
<span>Post Code</span>
<input type="text" name="post-code">
</div>
<div class="box">
<span>Country</span>
<input type="text" name="country">
</div>
<h2>Step 1: Card details</h2>
<div class="box cards">
<span>Card type</span>
<div id="cards">
<input type="radio" name="visa" id="visa">
<label for="visa">visa</label>
<input type="radio" name="AmEx" id="AmEx">
<label for="AmEx">AmEx</label>
<input type="radio" name="mastercard" id="mastercard">
<label for="mastercard">mastercard</label>
</div>
</div>
</div>
</body>