How to center divs on mobile in bootstrap 3? - html

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>

Related

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

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.

Bootstrap input-group-prepend/addon width adjustment

I'm having issues making prepend add-ons the same width. I'm using Font Awesome icons and the prepend is sized to each specific icon. I found another thread from about a year ago describing my exact problem, but there wasn't an answer.
Bootstrap4 make all input-group-addons same width
Here's a screenshot of my issue:
I tried using various CSS tweaks with no luck, including the one provided in that aforementioned thread.
Relevant HTML:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row body-main-bg">
<div class="col-sm-4 my-3">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fa fa-user"></span>
</span>
</div>
<input type="text" class="form-control" placeholder="Name">
</div>
</div>
</div>
<div class="row body-main-bg">
<div class="col-sm-4 mb-3">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fa fa-envelope"></span>
</span>
</div>
<input type="text" class="form-control" placeholder="Email">
</div>
</div>
</div>
<div class="row body-main-bg">
<div class="col-sm-4 mb-3">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fa fa-ellipsis-v"></span>
</span>
</div>
<input type="text" class="form-control" placeholder="Subject">
</div>
</div>
</div>
<div class="row body-main-bg">
<div class="col-sm-4 mb-3">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fa fa-pencil"></span>
</span>
</div>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3" placeholder="Message"></textarea>
</div>
</div>
</div>
I tried your same code snippet, with just some css tweaks it works for me.
I just added the following css,
Please use this css, this will solve your prepend/addon width issue.
.input-group-text {
width: 40px;
}
.input-group-text span {
margin: 0 auto;
}
Here is also the url to the snippet as well,
bootstrap-input-group-prepend-addon-width-issue
I think the easiest answer with this is css grid.
.wrapper
{
display:grid;
grid-template-rows: repeat(3,1fr) 2fr;
grid-template-columns: 15% 85%;
grid-row-gap:1rem
}
Then assign icons to the first column and inputs to the second one.
Hope this answered your problem.
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="modal-body" id="m_cr_body">
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend w-25">
<span class="input-group-text w-100" id="inputGroup-sizing-sm"><i class="fas fa-camera fa-fw"></i> Photographer</span>
</div>
<input type="text" class="form-control" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
</div>
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend w-25">
<span class="input-group-text w-100" id="inputGroup-sizing-sm"><i class="fas fa-paint-brush fa-fw"></i> Edit</span>
</div>
<input type="text" class="form-control" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
</div>
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend w-25">
<span class="input-group-text w-100" id="inputGroup-sizing-sm"><i class="fas fa-ruler-vertical fa-fw"></i> Rule</span>
</div>
<input type="text" class="form-control" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
</div>
</div>
</div>

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

How to align div input tag and button on the same line

I am new in html and I have a code where I would like to align the input tag and the button on the right sign on the same line. How can I do that?
<div class="form-group input-group">
<input type="text" class="form-control" />
<span class="input-group-btn input-group-addon">
<button class="btn btn-del input-group-delete" data-tooltip="tooltip" ><i class="fa fa-trash-o"></i></button>
</span>
</div>
My jsfiddle : https://jsfiddle.net/DTcHh/17952/
You can also do it in this way...
<style>
.nopadding{
padding:0;
}
</style>
<div class="timeline-panel">
<div class="timeline-heading">
<div class="form-horizontal col-xs-12">
<div class="form-group input-group">
<input type="text" class="form-control" />
<span class="input-group-btn input-group-addon nopadding">
<button class="btn btn-del input-group-delete" data-tooltip="tooltip" ><i class="fa fa-trash-o"></i></button>
</span>
</div>
</div>
</div>
</div>
Since you are using bootstrap you can just add pull-right in the input field and button both.
For example:
<input type="text" class="form-control pull-right" />
In button as well:
<button class="btn btn-del input-group-delete pull-right" data-tooltip="tooltip" >
While using addon in bootstrap if you define any element inside the addon span it will cluttered because in bootstrap the addon class have padding in css and that is way you button will not aligned in this case you can do it like this :
<div class="timeline-panel">
<div class="timeline-heading">
<div class="form-horizontal col-xs-12">
<div class="form-group input-group">
<input type="text" class="form-control" />
<span class="input-group-btn input-group-addon btn btn-del input-group-delete"> <i class="fa fa-trash-o"></i>
</span>
</div>
</div>
Okay try this
<div class="timeline-panel">
<div class="timeline-heading">
<div class="form-horizontal col-xs-12">
<div class="form-group input-group col-xs-9">
<input type="text" class="form-control" />
</div>
<button class="btn btn-del input-group-delete col-xs-3" data-tooltip="tooltip" ><i class="fa fa-trash-o"></i></button>
</div>
</div>
</div>
</div>

Div vertically align

I have three <div> like this:
<div class="col-xs-12 col-md-4 ">
<img src="custom_images/logo3.png" />
</div>
<div class="col-xs-6 col-md-4 text-center">
<div class="input-group">
<input type="text" class="form-control header_search" placeholder="Search Here....." aria-describedby="basic-addon1">
<span class="input-group-addon search_span" id="basic-addon1" ><i class="fa fa-search "></i> </span>
</div>
<%--<div class="">
<input type="search" placeholder="Search Here...." />
<span style="background-color:#000;padding:10px;">
<img src="custom_images/search.png" /></span>
</div>--%>
</div>
<div class="col-xs-6 col-md-4 text-right">
<button class="cart_button"><span>Items in your cart</span> <span style="margin-left:25px;"><img src="custom_images/cart_item.png" /></span></button>
<span class="cart_items">15</span>
</div>
I am not able to vertically align them in a line. I want all of them to be like vertically-align: middle.
Here is how it looks right now:
Please help me into this.
I believe that the logo is of fixed height. You can use margin-top on the top <div> using this:
<div class="col-xs-6 col-md-4 text-center adjust-top-height">
<div class="input-group">
<input type="text" class="form-control header_search" placeholder="Search Here....." aria-describedby="basic-addon1">
<span class="input-group-addon search_span" id="basic-addon1" ><i class="fa fa-search "></i> </span>
</div>
<div class="">
<input type="search" placeholder="Search Here...." />
<span style="background-color:#000;padding:10px;">
<img src="custom_images/search.png" /></span>
</div>
</div>
<div class="col-xs-6 col-md-4 text-right adjust-top-height">
<button class="cart_button"><span>Items in your cart</span> <span style="margin-left:25px;"><img src="custom_images/cart_item.png" /></span></button>
<span class="cart_items">15</span>
</div>
And in the CSS
.adjust-top-height {margin-top: 15px;}
If you give the parent element the following CSS, you should be fine:
element{
display: flex;
justify-content: space-between;
align-items: center;
}
HTML:
<div class="header">
<div class="col-xs-12 col-md-4 header-element">
<img src="custom_images/logo3.png" />
</div>
<div class="col-xs-6 col-md-4 text-center header-element">
<div class="input-group">
<input type="text" class="form-control header_search" placeholder="Search Here....." aria-describedby="basic-addon1">
<span class="input-group-addon search_span" id="basic-addon1"><i class="fa fa-search "></i> </span>
</div>
</div>
<div class="col-xs-6 col-md-4 text-right">
<button class="cart_button"><span>Items in your cart</span> <span style="margin-left:25px;"><img src="custom_images/cart_item.png" /></span></button>
<span class="cart_items">15</span>
</div>
</div>
CSS:
.header-element{
position: relative;
top: 50%;
transform: translateY(-50%);
}