Having problems with responsive widths - html

I tried to make a search block that need to be looking like this:
Now i want when someone will resize the window, the search button will still be in the same line, so i did:
CSS:
.search {
background-color: #23507c;
border: none;
outline: none;
font-size: 18px;
width: 92%
}
#searchButton {
width: 8%;
color: #555555;
font-size: 16px;
}
HTML:
<div id="search">
<form action="search.php" method="POST">
<span class="glyphicon glyphicon-search" style="font-size: 20px;"></span>
<span style="width: 100%;padding:0;margin:0;">
<input type="text" class="search" name="search" placeholder="search for diamonds" />
<button type="submit" id="searchButton"><span class="glyphicon glyphicon-search"></span>
Search</button>
</form>
</span>
</div>
https://jsfiddle.net/kL1m9a8x/15/
What i try to do, is to insert the input and the button to a span that take the width of the blue block execept the glypicon, and than give to the input 80% from the parent element and the button have 20%, but its not working. The line break and the button found in the next line... even when the window is big...

*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
#search{
position: relative;
margin: 5%;
}
.search-inner{
display: table;
width: 100%;
background-color: #23507c;
border: none;
outline: none;
font-size: 18px;
}
.search-item{
display: table-cell;
vertical-align: middle;
}
.search-item-1{
width: 82%;
color: #fff;
}
.search-item-1 .glyphicon{
position: absolute; top: 50%; left: 10px;
-webkit-transform: translate(0,-50%);
-ms-transform: translate(0,-50%);
transform: translate(0,-50%);
}
.search-item-2{
text-align: right;
}
input,
button{
border: none;
outline: none;
font-size: 18px;
padding: 10px;
display: inline-block;
}
input{
background-color: #23507c;
color: #fff;
padding-left: 35px;
width: 100%;
}
button{
width: 110px;
}
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
<div id="search">
<form action="search.php" method="POST">
<div class="search-inner">
<div class="search-item search-item-1">
<span class="glyphicon glyphicon-search"></span>
<input type="text" class="search" name="search" placeholder="search for diamonds" required />
</div>
<div class="search-item search-item-2">
<button type="submit" id="searchButton"><span class="glyphicon glyphicon-search"></span> Search
</button>
</div>
</div>
</form>
</div>

Here is how i would do it:
Basically making the input transparent, giving color to the form element and positioning the button absolutely over it. Note the position:relative on the form element, as position:absolute is always relative to the closest explicitly relative positioned parent.
*, *:before, *:after {
padding:0;
margin:0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
}
form {
background-color: #23507c;
display: block;
padding: 10px 15px;
width: 100%;
color: #fff;
font-size: 16px;
line-height: 24px;
position: relative;
}
form input {
background: transparent;
border: none;
outline: none;
color: #fff;
font-size: 16px;
line-height: 24px;
padding-left: 10px;
}
form button {
display: block;
position: absolute;
top: 10px;
right: 10px;
border: none;
outline: none;
height: 24px;
}
<!-- FontAwesome for icons -->
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"/>
<!-- relevant code -->
<form action="search.php" method="POST">
<i class="fa fa-search"></i>
<input type="text" class="search" name="search" placeholder="search for diamonds" />
<button type="submit" id="searchButton"><i class="fa fa-search"></i> Search
</button>
</form>

Related

Icons inside input text field

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.

Place button inside input

I need to place a button, with an icon, an input so I tried the HTML:
(JSFiddle Example: https://jsfiddle.net/mdmoura/zup3b24e/12/):
<form>
<div class="wrapper">
<input type="text">
<button type="submit">
<i class="fa fa-search"></i>
</button>
</div>
</form>
With the following CSS:
form {
width: 400px;
}
.wrapper {
position: relative;
}
input {
font-size: 18px;
padding: 10px;
width: 100%;
}
button {
background-color: white;
border: none;
font-size: 24px;
position: absolute;
right: 0;
}
But this does not place the button inside the input.
How can this be done?
All you need to do is to add bottom: 8px; to the button so it is moved up by 8px, visually into the input box.
button {
background-color: white;
border: none;
font-size: 24px;
position: absolute;
right: 0;
bottom: 8px;
}
form {
width: 400px;
}
.wrapper {
position: relative;
}
input {
font-size: 18px;
padding: 10px;
width: 100%;
}
button {
background-color: white;
border: none;
font-size: 24px;
position: absolute;
right: 0;
bottom: 8px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<form>
<div class="wrapper">
<input type="text">
<button type="submit">
<i class="fa fa-search"></i>
</button>
</div>
</form>
Updated JSFiddle: https://jsfiddle.net/zup3b24e/14/
A simpler way to build an input form with font awesome inside if you want to go with this direction
input[type="text"] {
width: 400px;
height: 20px;
padding: 10px;
}
input[type="submit"] {
font-family: FontAwesome;
font-size: 24px;
margin-left: -50px;
background-color: white;
border: none;
-webkit-appearance: none;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<input type="text"><input type="submit" value="">

Why are my elements losing position?

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;
}

html search form - align submit button

I have html search form - input and button.
Also I have Search title - h2 . But if I remove h2 title I have problem with button vertical-align.
html:
<h2 class="widget-title">Search</h2>
<form role="search" method="get" id="searchform" action="#">
<input type="text" placeholder="Search..." value="" >
<button type="submit" id="searchsubmit" value="">
<i class="fa fa-search"></i>
</button>
</form>
Css:
.widget-title {
margin-bottom: 40px;
font-size: 22px;
line-height: 18px;
}
#searchform input {
display: block;
max-width: 100%;
padding: 5px 10px;
border: 1px solid #ccc;
}
#searchsubmit {
position: absolute;
top: 59px;
right: 15px;
display: inline-block;
width: 50px !important;
height: 43px;
padding: 0;
border: none;
margin-bottom: 0;
vertical-align: middle;
background-color: transparent;
}
Is it possible to align button with and without search title (h2) ?
You don't need to use absolute positioning here, relative will be OK. position: relative and display: inline will solve the problem. And here is the working
js fiddle.
The markup is OK with <h2 class="widget-title">Search</h2> and without.

2 inputs divided by a slash

can someone help me achieve that 2 ínputs look like one divided by a slash
Also doing it with twitter-bootstrap
Idea : http://postimg.org/image/pcgbzj4s1/
What I got so far but there is divided also I think they should overlap(slash with inputs)
<input class="form-control" type="text" name="kerkim" id="input_main">
<i id="slash">/</i>
<div class="input-group">
<input id="address" class="form-control" type="text" >
<div class="input-group-btn">
<button type="submit" class="btn btn-ẃarning"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
http://codepen.io/oroborus357/pen/doVKEP Here's the quick codepen I made for you, it shoud do what you need :)
<span class="first"><input type="text" /></span><input class="second" type="text" />
body {
padding: 50px;
background: #333;
}
* {
box-sizing: border-box;
}
input {
background: white;
border: none;
padding-left: 15px;
}
.first {
position: relative;
}
.first:before {
content: "/";
position: absolute;
left: 100%;
top: 0;
height: 100%;
transform: translateX(-50%);
font-size: 18px;
}
Many ways to it... here's two.
Given this html:
<div class="container">
<input type="text">
<span class="slash"></span>
<input type="text">
</div>
With this CSS:
.container{
border: 1px solid #999;
display: inline-block;
border-radius: 3px;
background: #fff;
margin-top: 50px;
position: relative;
}
.container input{
border: none;
background: none;
}
.slash{
transform: scale(3);
position: absolute;
}
/* or.... */
.slash{
width: 2px;
height: 28px;
background: #999;
transform: rotate(20deg);
position: relative;
display: inline-block;
position: absolute;
top: -5px;
}
A demo here