I have a problem. I want to create a input text field with icons inside of the code.
I want to have my icons inside of the input text field. Unfortunately my CSS style didn't work. With others code the icons disappeared. I hope you can help me. Thank you in advance. Please see below for my code.
HTML
<div class="col-md-6 login-form">
<h3>Los gehts</h3>
<div class="form_login">
<div class="form-group">
<input type="text" id="email_field" placeholder="Email *">
<i class="fa fa-user" aria-hidden="true"></i>
</span>
</div>
<div class="form-group">
<input type="password" id="password_field" placeholder="Passwort *">
<i class="fa fa-lock" aria-hidden="true"></i>
</span>
</div>
<div class="form-group">
<button type="submit" class="btnSubmit" onclick="signIn()">Login</button>
</div>
<!--
<div class="form-group">
Forget Password?
</div> -->
</div>
</div>
CSS
.login-container {
margin-top: 5%;
margin-bottom: 5%;
text-align: center;
margin: auto;
padding-bottom: 5%;
}
.login-form {
padding: 5%;
text-align: center;
margin: auto;
}
.login-form h3 {
text-align: center;
color: #333;
}
.login-container form {
padding: 10%;
text-align: center;
display: inline-block;
position: relative;
width: 100%;
z-index: 1;
margin-bottom: 10px;
}
.btnSubmit {
width: 50%;
border-radius: 1rem;
padding: 1.5%;
border: none;
cursor: pointer;
}
.btnLogout {
margin-top: 1rem;
border-radius: 1rem;
cursor: pointer;
color: #fff;
background-color: #0062cc;
text-align: center;
display: inline-block;
border: none;
margin-bottom: 10px;
}
.btnLogout:hover {
background-color: #0575ec;
}
.login-form .btnSubmit {
font-weight: 600;
color: #fff;
background-color: #0062cc;
}
.login-form .ForgetPwd {
color: #0062cc;
font-weight: 600;
text-decoration: none;
}
.loggedin-div {
text-align: center;
padding-bottom: 5%;
}
You need to create a div with border that imitate a input border. Then, you need to create the text input at the left and add this code: <input type="image" src="yourimagefile.jpg">
I hope I help you.
If you want something to float somewhere else, you can use a combination of position:relative; and top/left with CSS. For instance, let's add an id to that login button and make it our icon...
<div class="form-group" id="submit">
<button type="submit" class="btnSubmit" onclick="signIn()">Login</button>
</div>
Then some styling...
#submit {
top:-21px;
left:228px;
position:relative;
width:100px;
}
And what we get, then, is an icon floating over the input field. Working Demo.
Works for me. Before:
After:
Here's an example with the blank <i> elements (converted to <img> so we could see something, as they had no href): Working Demo.
Related
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>
I am trying to use a search bar css from code pen. I used their exact code but the search bar seems to be really buggy on react.
Here is code sandbox for better reference. https://codesandbox.io/s/sad-moser-mdxmd?file=/src/Dashboard.js
Here's the code that I am currently using.
<div class="wrap">
<div class="search">
<input type="text" class="searchTerm" id="input_text"></input>
<button type="submit" class="searchButton">
<i class="fa fa-search"></i>
</button>
</div>
</div>
.search {
width: 100%;
position: center;
display: flex;
}
.searchTerm {
width: 100%;
border: 3px solid #00b4cc;
border-right: none;
padding: 5px;
height: 20px;
border-radius: 5px 0 0 5px;
outline: none;
color: #9dbfaf;
}
.searchTerm:focus {
color: #00b4cc;
}
.searchButton {
width: 40px;
height: 36px;
border: 1px solid #00b4cc;
background: #00b4cc;
text-align: center;
color: #fff;
border-radius: 0 5px 5px 0;
cursor: pointer;
font-size: 20px;
}
/*Resize the wrap to see the search bar change!*/
.wrap {
width: 30%;
position: flex;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
I want the search bar to look like this: enter image description here
This is the link to the code that I attempted to use.
https://codepen.io/huange/pen/rbqsD
because you are using simple html you have to use jsx here. Use any online jsx convertor like "https://magic.reactjs.net/htmltojsx.htm" etc.
for this you can use :
<div className="wrap">
<div className="search">
<input type="text" className="searchTerm" id="input_text" />
<button type="submit" className="searchButton">
<i className="fa fa-search" />
</button>
</div>
</div>
This question already has answers here:
What is a clearfix?
(10 answers)
Closed 4 years ago.
I have some styling issues with my contact form and footer: I want a border-top at the top for the footer div to separate the contact form and footer. However, the border-top of the footer is pushed above the top of the contact form rather than the top of the footer
If I delete the contact form, the border-top is where it needs to be... I've attached an image (as the code snippet doesn't do my styling so far any justice)
#contact-text-title {
color: #5CDB95;
}
.left-grid, .right-grid {
width: 49%;
float: left;
margin-top: -2%;
}
.left-grid {
margin-right: 1%;
}
.right-grid {
margin-left: 1%;
}
#mobile-contact-content {
display: none;
}
form {
width: 98%;
}
textarea, input, #contact-text {
font-family: Quicksand;
font-size: 16px;
}
label {
display: block;
padding: 1rem 0 .5rem;
text-transform: uppercase;
font-size: 18px;
font-family: Karla;
}
input, textarea {
display: block;
width: 100%;
border: 1px solid black;
padding: .5rem;
font-family: Montserrat;
font-weight: 300;
}
textarea {
height: auto;
resize: none;
}
button {
font-family: Montserrat;
font-size: 18px;
border: 1px solid #379683;
padding:.5rem;
width: auto;
margin-top: 15px;
background-color: #379683;
color: #FFF;
}
button:hover {
cursor: pointer;
color: #379683;
border-color: #379683;
background-color: #FFF;
}
#contact-text {
display: table-cell;
text-align: center;
vertical-align: middle;
line-height: 48px;
height: 500px;
}
footer {
font-size: 12px !important;
height: 25px;
}
footer p {
border-top: 1px solid black;
}
footer .logo {
font-size: 18px !important;
border: 0px solid black;
text-align: left;
width: 50%;
float: left;
margin-bottom:30px;
}
footer #facebook {
font-size: 18px !important;
text-align: left;
width: 50%;
float: left;
margin-bottom:30px;
margin-top:17px;
color: #05386B;
}
footer #facebook:hover {
cursor: pointer;
}
<div class="col">
<div id="contact-block">
<div id="header">
<h4>Contact.</h4>
</div>
<div id="mobile-contact-content">
<p class="content-text">Do you have an idea for your garden or driveway?</p>
<p class="content-text"><span>We want to hear about it!</span></p>
<p class="content-text">Use the contact form to get in touch with us!</p>
</div>
<div class="left-grid">
<form action="/" id="contact-form" method="post" role="form">
<div class = "label">
<label for="name" class="formText">Name:</label>
</div>
<input id="name" name="name" type="text" placeholder="Your name" required="required">
<div class = "label">
<label for="email" class="formText">Email:</label>
</div>
<input id="email" name="email" type="text" placeholder="Your email" required="required">
<div class = "label">
<label for="message" class="formText">Message:</label>
</div>
<textarea id="message" name="message" placeholder="Enter your message here" rows="10" required="required"></textarea>
<div>
<button type="submit">Send</button>
</div>
</form>
</div>
<div class="right-grid" id="contact-box">
<div id="contact-text">
<p><span id="contact-text-title">Have a new project idea?</span>
<br>Use the contact form to tell us about it and we will get in touch with you</p>
</div>
</div>
</div>
</div>
<div class="col">
<footer>
<p><span class="logo" style="text-align:left;">Rob Moore LTD</span><span id="facebook" style="text-align:right;"><i class="fab fa-facebook-f fa-lg"></i></span>
</p>
</footer>
</div>
Set float:left to .col.
.col {
float: left;
}
And also add a width: 100%; to the last .col which contains the footer.
So here is my box:
BOX
Ok, now I want to add box near the input of the BET box.
<div id="x2"></div> <!-- HTML --->
/* CSS */
#x2{
width: 40px;
height: 40px;
background: cornflowerblue;
}
The box after I add it:
BOX-AFTER
As you can see, it messed up the thin gray line and everything underneath it. I'm really not sure why.
HTML:
<div class="gamebox">
<div id="bet-and-chance-texts">
<p id="bettext">BET</p>
<p id="profittext"><i class="fa fa-btc" aria-hidden="true"></i> PROFIT</p>
</div>
<div id="bet-and-chance-input-boxes">
<input class="default" id="userbet" onkeyup="checkBet()" value="0.00000000" placeholder="BTC" name="bet" autocomplete="off">
<div id="x2">x2</div>
<input readonly class="default" id="profitinput" onkeyup="" value="100" placeholder="BTC" name="bet" autocomplete="off">
</div>
<br>
<div class="line-separator"></div>
<div id="button-texts">
<p id="roll">ROLL UNDER</p>
<p id="payout">PAYOUT</p>
<p id="chance">CHANCE</p>
</div>
<div id="buttons">
<input class="hidden-boxed-input-roll" value = "50.00"/>
<input autocomplete="off" id="newpayout" onkeyup="calculateChance()" class="hidden-boxed-input" value = "2.000"/>
<input autocomplete="off" id="newchance" onkeyup="checkChance()" class="hidden-boxed-input" value = "50"/>
</div>
<br>
<div id="rolldice-section">
<button type="button" id="dicebutton" onclick="prepareRoll(authToken);" style="vertical-align:middle"><i class="fa fa-gamepad"></i> Roll dice</button>
</div>
</div>
CSS:
.gamebox {
height: auto;
padding: 20px;
width: 60%;
font-family: Helvetica Neue;
color: black;
margin-top: 20px;
margin-left: 20px;
background-color: white;
}
.line-separator{
height:.5px;
background: lightgray;
border-bottom:.5px solid lightgray;
}
#x2{
width: 40px;
height: 40px;
background: cornflowerblue;
float: left;
}
input[class="default"]{
padding: 12px 20px;
margin : 0 auto;
box-sizing: border-box;
text-align: center;
background-color: #E4ECF1;
display: inline-block;
}
p[id="roll"]{
display: inline-block;
float: left;
font-size: 13px;
}
p[id="payout"]{
display: inline-block;
margin-right: 25px;
font-size: 13px;
}
p[id="chance"]{
display: inline-block;
float: right;
font-size: 13px;
}
div[id=button-texts]{
text-align: center;
}
Why does everything below the thin gray line get messed up? How can I solve this?
Change this :
<div id="x2">x2</div>
to :
<span id="x2">x2</span>
since div have block display and you need to use span which is inline
then change your style, remove float and add some padding to #x2 :
#x2 {
padding: 13px;
width: 40px;
height: 40px;
background: cornflowerblue;
}
Okay, so maybe I'm not searching properly but I can't seem to find exactly what I'm looking for.
I have a form, let's say something like this:
div.some_form {}
div.some_form>span {
font-weight: bold;
position: relative;
text-align: left;
}
div.some_form>form {
text-align: center;
font-size: 16px;
width: 100%;
margin-left: auto;
margin-right: auto;
}
div.some_form>form>input.txtfield {
padding: 13px;
width: 25%;
}
.button {
background-color: #7AB55C;
border: none;
color: white;
text-align: center;
padding: 15px 32px;
}
<div class="some_form">
<form>
<span class="some_class">Some text</span>
<br>
<input type="text" class="txtfield" />
<input type="button" class="button" value="Submit" onclick="doSomething()" />
</form>
</div>
what I want it to do is pretty much keep the inputs centred (which I'm able to do), which is why everything is in a div, I used text-align: center to centre everything, but I want the span element to be stuck to the top left corner of the first input, which I can't seem to do properly.
I mean, I get it, but then once I resize the window, the span shoots off into space (i.e. the text field will expand at a lower rate than the span is, which is great because the text stays centred even with the button attached) and I can't seem to get it to just stick.
(also this seriously isn't homework, I'm just getting into CSS and this is really bothering me..)
any help is obviously very much appreciated!
Thanks in advance :)
Adding a display: block to your span will work. And remove the <br />. You have the class specification wrong. The <span> isn't a direct child there. So > doesn't work:
body {
text-align: center;
}
div.some_form span.some_class {
font-weight: bold;
position: relative;
text-align: left;
display: block;
padding: 0 4.5%;
}
div.some_form>form {
text-align: center;
font-size: 16px;
width: 100%;
margin-left: auto;
margin-right: auto;
}
div.some_form>form>input.txtfield {
padding: 13px;
width: 45%;
}
.button {
background-color: #7AB55C;
border: none;
color: white;
text-align: center;
padding: 15px 32px;
}
div.some_form {
display: inline-block;
}
<div class="some_form">
<form>
<span class="some_class">Some text</span>
<input type="text" class="txtfield" />
<input type="button" class="button" value="Submit" onclick="doSomething()" />
</form>
</div>
Preview
Here the answer hope it can help you
.container{
width: 300px;
height: 200px;
position: absolute;
left: 50%;
top: 50%;
margin-top: -100px;
margin-left: -150px;
}
.txtfield {
padding: 13px;
width: 25%;
}
.button {
background-color: #7AB55C;
border: none;
color: white;
text-align: center;
padding: 15px 32px;
}
<div class="some_form">
<form>
<div class="container">
<span class="some_class">Some text</span>
<div class="input_container">
<input type="text" class="txtfield" />
<input type="submit" class="button" value="Submit" onclick="doSomething()" />
</div>
</div>
</form>
</div>