Unable to align the button inside the input - html

I want to create an input that contains a button that has an arrow down so the user can click on it to open a list or close it. I can't put the button inside the input, what do i miss here?
.input-wrapper {
position: relative;
}
.combobox-input {
font-size: 16px;
font-weight: normal;
color: #4d4d4d;
background: #ffffff;
border: 1px solid #828995;
height: 30px;
padding: 4px 10px;
}
.combobox-arrow {
display: inline-block;
padding: 6px;
border: none;
background-color: white;
background-image: url(...);
width: 25px;
height: 25px;
}
<div className="input-wrapper">
<input className="combobox-input"/>
<button className="combobox-arrow" ></button>
</div>

Try this and see if it suits your need:
(you can modify the snippet code as per your need)
document.getElementById('caret').addEventListener('click', function() {
// your code here if you want to add some logic
});
button#caret {
border: none;
background: none;
position: absolute;
top: 0px;
right: 0px;
}
.input-wrap {
position: relative;
display: inline;
}
<label>List of places<br/>
<div class="datalist-wrap">
<div class="input-wrap">
<input id="placesText" type="text" name="places" list="places"/>
<button id="caret"> ▼</button>
</div>
<datalist id="places">
<label>Select from the list:
<select name="places" id="select">
<option value="A"></option>
<option value="B"></option>
<option value="C"></option>
</select>
</label>
</datalist>
</div>
</label>

Related

HTML style into simple search funtion

Im creating one simple html page as a firefox default homepage. I got the search function working, but now i want to add style into the page.
This is my funtion:
<form action="" onsubmit="return false">
<input name="term_1" size="38" maxlength="50" value="" id="searchbox" placeholder="Enter search term.."><br />
<select name="field_1" id="option">
<option value="t" selected="selected">Title</option>
<option value="a">Author</option>
<option value="s">Subject</option>
<option value="call_number">Call Number</option>
<option value="p">Publisher</option>
</select>
<input value="Submit" type="button" onclick=search()>
<input value="Reset" type="reset">
</form>
<script>
function search()
{
var search_input=document.getElementById("searchbox").value;// value of search box
var option=document.getElementById("option").value; //value of select
window.open('http://webpac.kdu.edu.my/search/query?match_1=MUST&field_1=' + option + '&term_1=' + search_input + '&facet_loc=20000&sort=relevance&theme=kdu', 'bswindow'); //proceed with search
}
</script>
I would like style something like this
https://www.w3schools.com/code/tryit.asp?filename=GAQ6A12ICCQF
In order to style something, you must apply CSS.
As per WW3 Schools Search Button Styling
I've modified your HTML code in the following ways to achieve this:
Changed your Submit input to type button to permit an inner text item (which is used for the magnifying glass search symbol).
Converted your Reset input to type button for the same reason as above.
Moved your input[type="term1"] after your select to be inline with the styling brief you supplied.
Included a reference to the FontAwesome library in the head so the refresh & magnifying glass symbols can be utilised
Referenced the refresh & magnifying glass symbols in an <i> tag inside the relevant <button's
Here is the updated HTML with CSS:
* {
font-size: 14px;
}
select {
height: 35px;
border: 1px solid grey;
background: #f1f1f1;
}
input[type="text"] {
height: 30px;
text-indent: 10px;
border: 1px solid grey;
background: #f1f1f1;
}
form {
display: flex;
flex-direction: row;
width: 100%;
}
input[name="term_1"] {
width: 100%;
}
button {
width: 100px;
background-color: #2196F3;
border: 1px solid grey;
color: white;
}
button:hover {
cursor: pointer;
background-color: #0b7dda;
}
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<form action="" onsubmit="return false">
<select name="field_1" id="option">
<option value="t" selected="selected">Title</option>
<option value="a">Author</option>
<option value="s">Subject</option>
<option value="call_number">Call Number</option>
<option value="p">Publisher</option>
</select>
<input type="text" name="term_1" size="38" maxlength="50" value="" id="searchbox" placeholder="Enter search term.."><br />
<button type="submit" onclick=search()><i class="fa fa-search" aria-hidden="true"></i></button>
<button type="reset"><i class="fa fa-refresh" aria-hidden="true"></i>
</button>
</form>
<script>
function search() {
var search_input = document.getElementById("searchbox").value; // value of search box
var option = document.getElementById("option").value; //value of select
window.open('http://webpac.kdu.edu.my/search/query?match_1=MUST&field_1=' + option + '&term_1=' + search_input + '&facet_loc=20000&sort=relevance&theme=kdu', 'bswindow'); //proceed with search
}
</script>
Here is a JSFiddle for reference as well.
See W3schools css page for more styles
https://www.w3schools.com/howto/howto_css_searchbar.asp
<div id="cover">
<form method="get" action="">
<div class="tb">
<div class="td"><input type="text" placeholder="Search" required></div>
<div class="td" id="s-cover">
<button type="submit">
<div id="s-circle"></div>
<span></span>
</button>
</div>
</div>
</form>
</div>
*
{
outline: none;
}
html, body
{
height: 100%;
min-height: 100%;
}
body
{
margin: 0;
background-color: #ffd8d8;
}
.tb
{
display: table;
width: 100%;
}
.td
{
display: table-cell;
vertical-align: middle;
}
input, button
{
color: #fff;
font-family: Nunito;
padding: 0;
margin: 0;
border: 0;
background-color: transparent;
}
#cover
{
position: absolute;
top: 50%;
left: 0;
right: 0;
width: 550px;
padding: 35px;
margin: -83px auto 0 auto;
background-color: #ff7575;
border-radius: 20px;
box-shadow: 0 10px 40px #ff7c7c, 0 0 0 20px #ffffffeb;
transform: scale(0.6);
}
form
{
height: 96px;
}
input[type="text"]
{
width: 100%;
height: 96px;
font-size: 60px;
line-height: 1;
}
input[type="text"]::placeholder
{
color: #e16868;
}
#s-cover
{
width: 1px;
padding-left: 35px;
}
button
{
position: relative;
display: block;
width: 84px;
height: 96px;
cursor: pointer;
}
#s-circle
{
position: relative;
top: -8px;
left: 0;
width: 43px;
height: 43px;
margin-top: 0;
border-width: 15px;
border: 15px solid #fff;
background-color: transparent;
border-radius: 50%;
transition: 0.5s ease all;
}
button span
{
position: absolute;
top: 68px;
left: 43px;
display: block;
width: 45px;
height: 15px;
background-color: transparent;
border-radius: 10px;
transform: rotateZ(52deg);
transition: 0.5s ease all;
}
button span:before, button span:after
{
content: '';
position: absolute;
bottom: 0;
right: 0;
width: 45px;
height: 15px;
background-color: #fff;
border-radius: 10px;
transform: rotateZ(0);
transition: 0.5s ease all;
}
#s-cover:hover #s-circle
{
top: -1px;
width: 67px;
height: 15px;
border-width: 0;
background-color: #fff;
border-radius: 20px;
}
#s-cover:hover span
{
top: 50%;
left: 56px;
width: 25px;
margin-top: -9px;
transform: rotateZ(0);
}
#s-cover:hover button span:before
{
bottom: 11px;
transform: rotateZ(52deg);
}
#s-cover:hover button span:after
{
bottom: -11px;
transform: rotateZ(-52deg);
}
#s-cover:hover button span:before, #s-cover:hover button span:after
{
right: -6px;
width: 40px;
background-color: #fff;
}
Demo for the search bar. You can follow this.
or
if you want more different ones. You can check this: https://freefrontend.com/css-search-boxes/

How to make the label go up after clicking with css?

I want to make a form when on clicked the label would go up 15px and you can write the text, but I can't figure out how to do it with my current code. I think the problem is how I select the label and input.
I tried these ways:
.form-row-field-input:focus ~ label,
.form-row-field-input:valid ~ label {
top: -12px;
left: 0;
font-size: 12px;
color: #003333;
font-weight: bold;}
input[type=text]:focus~label {
display:block;
color: black;
top: -20px;
font-size: 14px;}
<div class="form-inputs">
<form action="" method="POST">
<div class="form-row">
<span class="form-row-number">01</span>
<label for="POST-name" class="form-row-field">First name</label>
<input type="text" class="form-row-field-input">
</div>
<div class="form-row">
<span class="form-row-number">02</span>
<label for="POST-lastname" class="form-row-field">Last name</label>
<input type="text" class="form-row-field-input">
</div>
<div class="form-row">
<span class="form-row-number">03</span>
<label for="POST-email" class="form-row-field">Email</label>
<input type="text" class="form-row-field-input">
</div>
<input class="form-btn" type="submit" value="Get it">
</form>
</div><!--end-->
/** CSS **/
.form-inputs {
padding: 40px;
flex: 60%;
display: flex;
flex-direction: column;
align-content: center;
justify-content: center;
position: relative;
}
.form-btn {
margin: 20px 0px;
background-color: #f6fe00;
color: black;
padding: 10px 40px;
font-weight: 700;
border: none;
cursor: pointer;
}
.form-row {
border-bottom: 1px solid grey;
padding: 10px 0px;
position: relative;
}
.form-row-number {
color: #8f63ff;
padding-right: 10px;
}
.form-row-field {
color: #9b91f5;
position: absolute;
pointer-events: none;
transition: 0.5s;
top: 10px;
margin-left: 1em;
}
.form-row-field-input {
background-color: inherit;
border: none;
display: block;
position: absolute;
top: 10px;
transition: 0.5s;
margin-left: 1.5em;
}
I expect that when clicked on input, the label would go up with a transition
The general sibling selector in CSS that you're using can only target elements that come AFTER, so since the label comes before the input in your HTML, it's not actually applying the CSS.
You can get the intended effect simply be moving the label element after the input. Google's Material UI also takes this approach in order to keep it primarily CSS to achieve the intended visual effect.
Here it is with the label elements moved to after the input and slightly tweaked CSS:
<body>
<div class="form-inputs">
<form action="" method="POST">
<div class="form-row">
<span class="form-row-number">01</span>
<input type="text" class="form-row-field-input">
<label for="POST-name" class="form-row-field">First name</label>
</div>
<div class="form-row">
<span class="form-row-number">02</span>
<input type="text" class="form-row-field-input">
<label for="POST-lastname" class="form-row-field">Last name</label>
</div>
<div class="form-row">
<span class="form-row-number">03</span>
<input type="text" class="form-row-field-input">
<label for="POST-email" class="form-row-field">Email</label>
</div>
<input class="form-btn" type="submit" value="Get it">
</form>
</div>
<!--end-->
</body>
.form-inputs {
padding: 40px;
flex: 60%;
display: flex;
flex-direction: column;
align-content: center;
justify-content: center;
position: relative;
}
.form-btn {
margin: 20px 0px;
background-color: #f6fe00;
color: black;
padding: 10px 40px;
font-weight: 700;
border: none;
cursor: pointer;
}
.form-row {
border-bottom: 1px solid grey;
padding: 10px 0px;
position: relative;
}
.form-row-number {
color: #8f63ff;
padding-right: 10px;
}
.form-row-field {
color: #9b91f5;
position: absolute;
pointer-events: none;
transition: 0.5s;
top: 10px;
margin-left: 1em;
}
.form-row-field-input {
background-color: inherit;
border: none;
display: block;
position: absolute;
top: 10px;
transition: 0.5s;
margin-left: 1.5em;
}
.form-row-field-input:focus~label {
top: -5px;
font-size: 12px;
color: #003333;
font-weight: bold;
}
https://jsfiddle.net/7urgeL60/

How to fix disappearing hoverable Box with HTML-Select-Input (in Firefox)

I'm trying to fix an issue with a hoverable span in html. Inside the span element is a html-select option. When I try to select something, the hoverable span disappears.
This issue only occurs in Firefox. In Chrome I don't have this issue.
HTML Part:
<span class="over">
<i class="fa fa-cogs edit"></i>
<div>
<form method="post" accept-charset="utf-8" action="/edit">
<div class="input select">
<label for="select-id">Select</label>
<select name="select_id" id="select-id">
<option value="">-- select --</option>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
</select>
</div>
</form>
</div>
</span>
SCSS Part:
.over{
margin-right: 0.5em;
&>i{
color: #bbbbbb;
padding: 2px;
}
&>a{
padding: 2px;
display: none;
&:hover{
color: #000;
}
}
&>div{
display: none;
position: absolute;
border: 1px solid #ccc;
margin: 6px 0 0 -20px;
padding: 2px;
background: white;
border-radius: 4px;
min-width: 140px;
z-index: 100;
text-align: left;
input, select{
padding: 0 5px;
line-height: 1.5em;
width: auto;
display: inline-block;
}
label{
margin: -4px 4px;
display: inline-block;
}
}
&:hover{
border: 1px solid;
border-radius: 4px;
&>i{
color: #000;
}
&>a{
display: inherit;
}
&>div{
display: inline-block;
}
}
}
}
In Chrome I can hover over the span item and select a option from the select-element. Even if I leave the hoverable area.
In Firefox I can also hover over the div, but as soon as I leave the hoverable area, the box disappears and I cannot select an Item.
Problem seems to be fixed in Firefox now.

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 to centralize content inside a form

Could someone help me? I am with this form trying to centralize all fields in it. I've tried a bunch of different stuff, and I've noticed that the code works differently inside the theme that I am using. Is there another way to do it rather than margin: 0 auto;? Any help will be really appreciated. Here is the url. Thank you
<div id="instant-quote-form">
<form action="http://natesolutions.vonigo.com/external/" accept-charset="UTF-8" method="get" onsubmit="return submitForm(this)">
<div class="instant-quote">
<h3 class="quote-title">Instant Online Quote</h3>
</div>
<div class="house-type">
<input type="radio" onclick="showServices(this)" id="xclientTypeID" name="xclientTypeID" value="1" checked />Residential
<input type="radio" onclick="showServices(this)" id="xclientTypeID" name="xclientTypeID" value="2" />Commercial
</div>
<div class="zip-code">
<input type="text" id="zip" name="zip" value="" placeholder="Enter Postal Code"/>
</div>
<div class="house-size" id="divServices1">
<select id="xserviceTypeID1" onchange="changeService(this)">
<option value="14" selected>Small House (1200-2000sq.ft)</option>
<option value="17">Medium House (2001-2800sq.ft)</option>
<option value="18">Large House (2801-3500sq.ft)</option>
<option value="19">XL House (3500+)</option>
</select>
</div>
<div class="button-go">
<input type="submit" value="Go" />
</div>
<input type="hidden" id="xserviceTypeID2" value="20" />
<input type="hidden" id="xserviceTypeID5" value="20" />
<input type="hidden" id="clientTypeID" name="clientTypeID" value="1" />
<input type="hidden" id="serviceTypeID" name="serviceTypeID" value="14" />
</form>
</div>
<style>
#instant-quote-form {
width: 100%;
margin: 0 auto;
}
.instant-quote {
float: left;
margin: 20px 5px;
padding-top: 4px;
}
.house-type {
float: left;
margin: 20px 5px;
color: #ffffff;
font-size: 16px;
padding-top: 5px;
}
.zip-code {
float: left;
margin: 20px 5px;
border: 1px solid #ffffff;
border-radius: 3px;
color: #000000;
}
.house-size {
float: left;
margin: 20px 5px;
border: 1px solid #ffffff;
border-radius: 3px;
color: #000000;
}
select#xserviceTypeID1 {
border: 1px solid #ffffff;
font-size: 13px;
padding: 10px;
color: #000000;
}
.button-go {
float: left;
margin: 20px 5px;
}
h3.quote-title {
margin-bottom: 0;
color: #ffffff;
}
input#zip {
margin-bottom: 0;
border: 1px solid #ffffff;
font-size: 13px;
padding: 9px;
}
input#zip::placeholder {
color: #000000;
}
input[type=text]::placeholder {
color: #000000;
}
input#xclientTypeID {
margin: 0 5px;
}
input[type="submit"] {
height: 37px;
width: 50px;
background: #55b948;
color: #fff;
border-radius: 3px;
text-transform: uppercase;
border: 1px solid #55b948;
font-weight: bold;
}
</style>
As your #instant-quote-form is as wide as its parent, centering this element will not do anything. What you will need to do is to center the <form> inside of its container. This can be done by applying display:flex to #instant-quote-form and then margin:0 auto to #instant-quote-form > form:
#instant-quote-form {
display: flex;
}
#instant-quote-form > form {
margin: 0 auto;
}
Try enclosing your <form> within <center> tag
Additionally, If you want the form with elements in a vertically aligned fashion then set float to none for each direct child of your <form>
If this isn't what you were looking for, please elaborate your issue and expected outcome.