How to place two input next to each other in bootstrap 4 - html

I want to place the text input and the button next to each other, with about 10px margin between them.
Whit this code, i get the result what you can see on the uploaded photo.
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="float-left">
<input type="number" class="form-control item_page_item_db w-50" id="quantity<?php echo intval($kat['termek_id']); ?>" value="1">
</div>
<div class="float-left">
<button class="btn btn-outline-secondary add_to_cart_button" data-product-id="<?php echo intval($kat['termek_id']); ?>" type="button"><i class="fa fa-shopping-basket" aria-hidden="true"></i> Kosárba helyezem
</button>
</div>
<div class="clearfix"></div>
</div>
I want them closer to each other, and vertically centered the right way. Now, they dont have any css for size, only just colors and font size...

The bootstrap way: Use col classes to create a width (Shown below)
.row {
background: #f8f9fa;
margin-top: 20px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-sm-2">
<input type="number" class="form-control" value="1">
</div>
<div class="col-sm-10">
<button class="btn btn-outline-secondary" type="button">
<i class="fa fa-shopping-basket"></i>
Kosárba helyezem
</button>
</div>
</div>
</div>
Pure CSS way:
.cont {
display: flex;
}
input {
width: 100px !important; /**use specific width**/
margin-right: 10px !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="cont">
<input type="number" class="form-control" value="1">
<button class="btn btn-outline-secondary" type="button">
<i class="fa fa-shopping-basket"></i>
Kosárba helyezem
</button>
</div>

See the below structure and css. Hope it helps.
.col-sm-6 input[type="number"]{width:100%}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-sm-6">
<input type="number" class="form-control item_page_item_db" id="quantity<?php echo intval($kat['termek_id']); ?>" value="1">
</div>
<div class="col-sm-6">
<button class="btn btn-outline-secondary add_to_cart_button" data-product-id="<?php echo intval($kat['termek_id']); ?>" type="button"><i class="fa fa-shopping-basket" aria-hidden="true"></i> Kosárba helyezem
</button>
</div>
<div class="clearfix"></div>
</div>
</div>

You can use col-md-6 class instead of float-left or right.

Related

How to center divs on mobile in bootstrap 3?

I gived the .fejlec div this css code:
#media only screen and (max-width: 768px) {
.fejlec
{
text-align: center;
}
}
But it doent align my divs center on mobile. I want to align center these divs:
- .fejlec_logo
- .fejlec_kereses
- .fejlec_kedvencek
- .fejlec_kosar
On the uploaded photo, you can see that how it looks now.
https://imgur.com/a/vh7AGY4
<div class="container fejlec">
<div class="row">
<div class="col-md-3 col-xs-12 fejlec_logo">
<a title="<?php echo html($site_config['logo_text']); ?>" class="navbar-brand logo clearfix" href="<?php echo $host; ?>">
<span class="logo_text_1"><?php echo html($site_config['logo_text']); ?></span><span class="logo_text_2"><?php echo html($site_config['logo_slogen']); ?></span>
</a>
</div>
<div class="col-md-5 col-xs-12 fejlec_kereses">
<form role="search" name="header_search_form" id="header_search_form" method="post" onsubmit="search_k();return false;">
<div class="input-group stylish-input-group bc-wrapper">
<input type="text" class="form-control header_search_input" autocomplete="off" placeholder="Termékek keresése..." name="country_id" id="country_id" onkeyup="autocomplet();" >
<span class="input-group-addon">
<i class="fa fa-spinner fa-spin" id="search_progress"></i>
<input type="hidden" name="search_date" id="search_date" value="" />
<button type="submit" class="header_search_button"><i class="fa fa-search header_search_icon" aria-hidden="true"></i></button>
</span>
</div>
<div class="bc-menu list-group" id="country_list_id"></div>
</form>
</div>
<div class="col-md-2 col-xs-12 fejlec_kedvencek">
<i class="fa fa-heart" aria-hidden="true"></i> Kedvenc termékeim
</div>
<div class="col-md-2 col-xs-12 fejlec_kosar">
<a href="<?php echo $host; ?>/ajanlatkeres" title="Kosár">
<span class="header_kosar_text"><i class="fa fa-shopping-basket fejlec_kosar_ikon" aria-hidden="true"></i> Ajánlatkérés</span>
<span id="header_kosar_text"></span>
<div class="clearfix"></div>
</a>
</div>
</div>
</div>
Try old fashioned margin: 0 auto;:
.fejlec
{
float: none;
margin: 0 auto;
}
Just use class of bootstrap
text-center
moreover
you are using text-center alignment in the container itself so it won't work that way,
you have to provide fejlec class in the col divs like below
<div class="col-md-5 col-xs-12 fejlec_kereses fejlec">
<form role="search" name="header_search_form" id="header_search_form" method="post" onsubmit="search_k();return false;">
<div class="input-group stylish-input-group bc-wrapper">
<input type="text" class="form-control header_search_input" autocomplete="off" placeholder="Termékek keresése..." name="country_id" id="country_id" onkeyup="autocomplet();" >
<span class="input-group-addon">
<i class="fa fa-spinner fa-spin" id="search_progress"></i>
<input type="hidden" name="search_date" id="search_date" value="" />
<button type="submit" class="header_search_button"><i class="fa fa-search header_search_icon" aria-hidden="true"></i></button>
</span>
</div>
<div class="bc-menu list-group" id="country_list_id"></div>
</form>
</div>

Vertical center align for a button in panel header with Bootstrap

I'm working on a Bootstrap 4 HTML page. I put a button in a panel header:
I need to put the button (and the title) in the middle of the panel header. How can I achieve this goal?
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container p-4 ">
<div class="card">
<div class="card-header">
<p class="float-left display-4">Administrator</p>
<a href="#" class="btn btn-primary float-right" style="align-items: center" routerLink="../list" role="button">
<i class="fa fa-arrow-left"></i> Indietro</a>
</div>
<div class="card-body">
<form>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd">
</div>
<div class="form-group">
<label for="displayName">Display name:</label>
<input type="displayName" class="form-control" id="displayName">
</div>
<button type="submit" class="btn btn-primary float-right">Salva</button>
</form>
</div>
</div>
</div>
Thanks
Try using display: flex; for your card header which is available in bootstrap and also instead of using float-right you can use ml-auto to move the button to the right (With the use of flex there is no need to use float properties). Hope this code helps
<!--
Bootstrap docs: https://getbootstrap.com/docs
-->
<div class="container p-4 ">
<div class="card">
<div class="card-header d-flex flex-row align-items-center">
<p class="float-left display-4">Administrator</p>
<a href="#" class="btn btn-primary ml-auto" style="align-items: center" routerLink="../list" role="button">
<i class="fa fa-arrow-left"></i> Indietro</a></div>
<div class="card-body">
<form>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd">
</div>
<div class="form-group">
<label for="displayName">Display name:</label>
<input type="displayName" class="form-control" id="displayName">
</div>
<button type="submit" class="btn btn-primary float-right">Salva</button>
</form>
</div>
</div>
</div>
Just add display flex to your card-header class, then align-items: center
.card-header {
padding: .75rem 1.25rem;
margin-bottom: 0;
background-color: rgba(0,0,0,.03);
border-bottom: 1px solid rgba(0,0,0,.125);
display: flex;
justify-content: space-between;
align-items: center;
}

Bootstrap4 move login form towards to the center

I have the following login page:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title> Log in </title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
</head>
<body>
<header>
<nav class="navbar navbar-dark bg-primary">
<a class="navbar-brand" href="/">
<img src="https://loremimage.com/default/32/32/1" />
Διαχείρηση Μελών ΕΛΛΑΚ Κύπρου
</a>
</nav>
</header>
<div class="container-fluid d-flex align-items-center justify-content-center">
<div class="row bg-light border border-primary">
<div class="col mt-5 col-xs-12 col-md-12 col-lg-12">
<h1 style="text-align:center">Log in</h1>
<form action="/login_check" method="post">
<div class="form-group">
<input type="text" class="form-control" id="username" name="_username" value="" placeholder="Username" required="required" />
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="form-group">
<input type="password" class="form-control" id="password" name="_password" placeholder="Password" required="required" />
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="form-group">
<div class="form-check">
<input type="checkbox" id="remember_me" name="_remember_me" class="form-check-input" />
<label class="form-check-label" for="remember_me" >Remember me</label>
</div>
</div>
<div class="form-row">
<div class="col">
<input type="submit" class="btn btn-primary btn-block" id="_submit" name="_submit" value="Log in" />
</div>
<div class="col">
<a class="btn btn-warning btn-block" href="/resetting/request">I forgot my password</a>
</div>
</div>
</form>
</div>
<div class="col col-xs-12 col-md-12 col-lg-12 mt-1 mb-5">
<a class="btn btn-primary btn-block" href="/register/">I do not have an account</a>
</div>
</div>
</div>
</body>
</html>
And my problem is that the login form is not too center as I want to as this image shows.
What I want to do is to display like that:
So do you know how to move the whole login form towards the center I tried the bootstrap's d-flex align-items-center justify-content-center class combination and somehow it does center but the flexbox is as height as my login form.
So my guess is on how I can make the flexbox take over the whole remaining height. DO you know how to do that?
You should give height to your container-fluid div in view-port
height: calc(100vh - 60px);
60px is your header height (View in full-screen mode of snippet)
.custom {
height: calc(100vh - 60px);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title> Log in </title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
</head>
<body>
<header>
<nav class="navbar navbar-dark bg-primary">
<a class="navbar-brand" href="/">
<img src="https://loremimage.com/default/32/32/1" />
Διαχείρηση Μελών ΕΛΛΑΚ Κύπρου
</a>
</nav>
</header>
<div class="custom container-fluid d-flex align-items-center justify-content-center">
<div class="row bg-light border border-primary">
<div class="col mt-5 col-xs-12 col-md-12 col-lg-12">
<h1 style="text-align:center">Log in</h1>
<form action="/login_check" method="post">
<div class="form-group">
<input type="text" class="form-control" id="username" name="_username" value="" placeholder="Username" required="required" />
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="form-group">
<input type="password" class="form-control" id="password" name="_password" placeholder="Password" required="required" />
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="form-group">
<div class="form-check">
<input type="checkbox" id="remember_me" name="_remember_me" class="form-check-input" />
<label class="form-check-label" for="remember_me" >Remember me</label>
</div>
</div>
<div class="form-row">
<div class="col">
<input type="submit" class="btn btn-primary btn-block" id="_submit" name="_submit" value="Log in" />
</div>
<div class="col">
<a class="btn btn-warning btn-block" href="/resetting/request">I forgot my password</a>
</div>
</div>
</form>
</div>
<div class="col col-xs-12 col-md-12 col-lg-12 mt-1 mb-5">
<a class="btn btn-primary btn-block" href="/register/">I do not have an account</a>
</div>
</div>
</div>
</body>
</html>

How do I move the background image to the back and the login container to the front

I am trying to move antoine-barres.jpg background image all the way to the back, then the clouds.png, then the login container all the way to the front. How do I do it, I have tried z-index but not sure how it works, I have tried but ran out of ideas, please help.
<body>
<div class="wrapper">
<div class="page-header" style="background-image: url('../assets/img/antoine-barres.jpg');">
<div class="container">
<div class="row" style="z-index:9999;">
<div class="col-lg-4 ml-auto mr-auto">
<div class="card card-register">
<h3 class="title">Welcome</h3>
<form class="register-form">
<label>Email</label>
<input type="text" class="form-control" placeholder="Email">
<label>Password</label>
<input type="password" class="form-control" placeholder="Password">
<button class="btn btn-danger btn-block btn-round">Register</button>
</form>
<div class="forgot">
Forgot password?
</div>
</div>
</div>
</div>
<div class="footer register-footer text-center">
<h6>© <script>document.write(new Date().getFullYear())</script>, made with <i class="fa fa-heart heart"></i> by Creative Tim</h6>
</div>
</div>
</div>
<div class="moving-clouds" style="background-image: url('../assets/img/clouds.png');">
</div>
</body>
You have to use the moving cloud image before the container
<div class="wrapper">
<div class="page-header" style="background-image: url('../assets/img/login-image.jpg');">
<div class="filter"></div>
<div class="moving-clouds" style="background-image: url('http://demos.creative-tim.com/paper-kit-2/assets/img/clouds.png');">
</div>
<div class="container">
<div class="row">
<div class="col-lg-4 ml-auto mr-auto">
<div class="card card-register">
<h3 class="title">Welcome</h3>
<div class="social-line text-center">
<a href="#pablo" class="btn btn-neutral btn-facebook btn-just-icon">
<i class="fa fa-facebook-square"></i>
</a>
<a href="#pablo" class="btn btn-neutral btn-google btn-just-icon">
<i class="fa fa-google-plus"></i>
</a>
<a href="#pablo" class="btn btn-neutral btn-twitter btn-just-icon">
<i class="fa fa-twitter"></i>
</a>
</div>
<form class="register-form">
<label>Email</label>
<input type="text" class="form-control" placeholder="Email">
<label>Password</label>
<input type="password" class="form-control" placeholder="Password">
<button class="btn btn-danger btn-block btn-round">Register</button>
</form>
<div class="forgot">
Forgot password?
</div>
</div>
</div>
</div>
<div class="footer register-footer text-center">
<h6>© <script type="text/javascript" async="" src="http://www.google-analytics.com/ga.js"></script><script>document.write(new Date().getFullYear())</script>2018, made with <i class="fa fa-heart heart"></i> by Creative Tim</h6>
</div>
</div>
</div>
</div>
Try this:
.page-header {
background: url(../assets/img/clouds.png);
}
or
.wrapper {
background: url(../assets/img/clouds.png);
}
I'm not really understand your problem, can you explain it more?
.wrapper {
background: url('https://upload.wikimedia.org/wikipedia/commons/4/46/WP_SOPA_asset_Radial_Gradient.jpg'); // i change url
}
.row {
z-index: 999;
}
.moving-clouds {
background: url('http://eskipaper.com/images/simple-cloud-wallpaper-1.jpg');
}
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="wrapper">
<div class="page-header">
<div class="container">
<div class="row">
<div class="col-lg-4 ml-auto mr-auto">
<div class="card card-register">
<h3 class="title">Welcome</h3>
<form class="register-form">
<label>Email</label>
<input type="text" class="form-control" placeholder="Email">
<label>Password</label>
<input type="password" class="form-control" placeholder="Password">
<button class="btn btn-danger btn-block btn-round">Register</button>
</form>
<div class="forgot">
Forgot password?
<div class="footer register-footer text-center">
<h6>© <script>document.write(new Date().getFullYear())</script>, made with <i class="fa fa-heart heart"></i> by Creative Tim</h6>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="moving-clouds"></div>
</div>
JSFiddle Demo

Prevent control go ahead with form-inline

I'm using form-inline class that put all the controls on the same line, but I noticed that when I resize the window the button near the textbox go to the next line. I want to prevent this. Take a look at the image:
and this is the code:
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<div class="container">
<div class="row">
<div class="col-xs-2 hideable-sidebar">
<div class="well">
<span><b>Resources</b></span>
<form class="form-inline">
<input type="text" placeholder="type text here"
class="form-control" id="resource_filter" />
<button class="clear btn btn-default btn-sm" type="button"
title="clean">
<span class="glyphicon glyphicon-repeat"></span>
</button>
</form>
</div>
</div>
</div>
</div>
You'll want to use the Bootstrap Button Addons under input groups. This way it will stay proportional during a window resize. Be sure that your input and button are using the same size:
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<div class="container">
<div class="row">
<div class="col-xs-12 hideable-sidebar">
<div class="well">
<span><b>Resources</b></span>
<form class="form-inline">
<div class="input-group">
<input type="text" placeholder="type text here" class="form-control" id="resource_filter" />
<span class="input-group-btn">
<button class="clear btn btn-default" type="button" title="clean">
<span class="glyphicon glyphicon-repeat"></span>
</button>
</span>
</div>
</form>
</div>
</div>
</div>
</div>