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%);
}
Related
I have this template from angular 10. The problem is the scrollbar doesn´t work even if I add the css style on the main container overflow: auto;
The HTML and scss codes are as following, as you can see I include the overflow property to the main container "cont", but is not working:
Anyone can help with this? Thank you!
.cont{
overflow: auto;
}
<div class="cont">
<div class="card-body">
<form name="formEmpresa">
<div class="container-background">
<div class="container-fluid">
<div class="form-group">
<div class="row">
<div class="col-sm-6">
<div class="input-group flex-nowrap">
<div class="input-group-prepend">
<span class="input-group-text" id="addon-wrapping"><i class="fa fa-building"></i></span>
</div>
<input type="text" class="form-control" placeholder="J123456789" name="Rif" required>
</div>
</div>
<div class="col-sm-6"></div>
<div class="col-sm-12">
<hr style="border: none">
<div class="input-group flex-nowrap">
<span class="input-group-text" id="addon-wrapping"><i class="fa fa-institution"></i></span>
<input type="text" class="form-control" placeholder="Razón Social" name="Razosoci" required ng-maxlength="150">
</div>
</div>
<div class="col-sm-12">
<hr style="border: none">
<label>Dirección fiscal</label>
<textarea class="form-control" rows="3" placeholder="Entre ..." name="Dir" ng-maxlength="200" required></textarea>
</div>
<div class="col-sm-12">
<hr style="border: none">
<div class="row justify-content-center">
<button class="btn btn-warning" style="width: 20%;">
<i class="fa fa-plus-circle" style="color: white;"></i> <h5 style="color: white;"><strong>Añadir sucursal</strong></h5>
</button>
</div>
</div>
<div class="col-sm-12">
<hr style="border: none">
<div class="card">
<div class="card-header" style="background-color: #ffc107; color: white;">
<strong>Nueva surcursal</strong>
</div>
<div class="card-body">
<div class="row">
<div class="col-sm-12">
<div class="input-group flex-nowrap">
<div class="input-group-prepend">
<span class="input-group-text" id="addon-wrapping"><i class="fa fa-building"></i></span>
</div>
<input type="text" class="form-control" placeholder="Nombre Sucursal" name="sucursal" required>
</div>
</div>
<div class="col-sm-6">
<hr style="border: none">
<div class="input-group flex-nowrap">
<div class="input-group-prepend">
<span class="input-group-text" id="addon-wrapping"><i class="fa fa-phone"></i></span>
</div>
<input type="text" class="form-control" placeholder="Teléfono" name="phone" required>
</div>
</div>
<div class="col-sm-6">
<hr style="border: none">
<div class="input-group flex-nowrap">
<div class="input-group-prepend">
<span class="input-group-text" id="addon-wrapping"><i class="fa fa-qrcode"></i></span>
</div>
<input type="text" class="form-control" placeholder="Código Postal" name="postal_code" required>
</div>
</div>
<div class="col-sm-12">
<hr style="border: none">
<textarea class="form-control" rows="3" placeholder="Dirección" name="Dir" ng-maxlength="200" required></textarea>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
You need to give some height to .cont class to add scroll to that div.
When I select the date range option from my dropdown button, the date range options appear on top of each other (see image below). I would like for them to appear in the same row. One option I tried was playing with width, in both pixels and percentages, and when I added it, the entire card stretched to to the right. Does anybody know why this is happening?
This is how it normally looks prior to selecting "Date Range" from the dropdown menu.
When I select "Date Range", this is how it appears. Would like for it to be on one row, instead on top of each other.
When I play with the width property in CSS, the card stretches to the right, which is what I don't want.
<div class="report-card-i report-card-i-height" style="position: fixed; z-index: 10; background-color: #fff; float: unset; top: 80px; padding-left: 100px; padding-right: 85px;">
<h1>ABC Corp - Summary</h1>
<div class="col-lg-3 text-center">
#{
<select onchange="updateDates(this, null, null, null )">
<option value="0" selected></option>
#for (int i = 1; i < #Model.droplist i++)
{
var tempValue = i;
<option value="#tempValue">#Model.droplist.ElementAt(i)</option>
}
</select>
}
</div>
<div class="col-lg-8" id="dateRange" style="display: none; width:1px">
<div class="col-lg-2">
<div class="input-group date" id="divFrom">
<div class="form-line">
<input id="startDate" name="startDate" type="text" class="form-control" style="background-color: inherit; width: 85px" placeholder="dd/mm/yyyy" value="#Model.StartDate">
</div>
<span class="input-group-addon">
<i class="fa fa-orange fa-calendar"></i>
</span>
</div>
</div>
<div class="col-lg-2">
<span class="font-13 text-muted div-center">to</span>
</div>
<div class="col-lg-2">
<div class="input-group date" id="divTo">
<div class="form-line">
<input id="endDate" name="endDate" type="text" class="form-control" style="background-color: inherit; width: 85px" placeholder="dd/mm/yyyy" value="#Model.EndDate">
</div>
<span class="input-group-addon">
<i class="fa fa-orange fa-calendar"></i>
</span>
</div>
</div>
<div class="col-lg-2">
<button id="btnTest" class="btn-orange fa-orange btn-sm" onclick="updateDateRanges()" style="margin-left: 10px">Submit</button>
</div>
</div>
<br />
<br />
<div class="fa-orange m-t-10 m-b-15 m-l-80">
<div class="row col-lg-12">
<div class="col-sm-2 col-xs-2 text-left">
</div>
<div class="col-sm-2 col-xs-2 text-left">
<h4>Number of Deliveries</h4>
</div>
<div class="col-sm-2 col-xs-2 text-left">
<h4>Deliveries per day</h4>
</div>
<div class="col-sm-2 col-xs-2 text-left">
<h4>Gross Amount Due</h4>
</div>
<div class="col-sm-1 col-xs-1 text-left">
</div>
<div class="col-sm-1 col-xs-1 text-left">
<h4>Monthly Total</h4>
</div>
<div class="col-sm-1 col-xs-1 text-left">
</div>
<div class="col-sm-1 col-xs-1 text-left">
<h4>YTD Total</h4>
</div>
</div>
</div>
</div>
There was a structural issue. Try this
<div class="row">
<div class="col-lg-4 text-center">
#{
<select onchange="updateDates(this, null, null, null )">
<option value="0" selected></option>
#for (int i = 1; i < #Model.droplist i++) { var tempValue=i; <option value="#tempValue">
#Model.droplist.ElementAt(i)</option>
}
</select>
}
</div>
<div class="col-lg-8" id="dateRange">
<div class="row">
<div class="col-lg-3">
<div class="input-group date" id="divFrom">
<div class="form-line">
<input id="startDate" name="startDate" type="text" class="form-control"
style="background-color: inherit; width: 85px" placeholder="dd/mm/yyyy"
value="#Model.StartDate">
</div>
<span class="input-group-addon">
<i class="fa fa-orange fa-calendar"></i>
</span>
</div>
</div>
<div class="col-lg-3">
<span class="font-13 text-muted div-center">to</span>
</div>
<div class="col-lg-3">
<div class="input-group date" id="divTo">
<div class="form-line">
<input id="endDate" name="endDate" type="text" class="form-control"
style="background-color: inherit; width: 85px" placeholder="dd/mm/yyyy"
value="#Model.EndDate">
</div>
<span class="input-group-addon">
<i class="fa fa-orange fa-calendar"></i>
</span>
</div>
</div>
<div class="col-lg-3">
<button id="btnTest" class="btn-orange fa-orange btn-sm" onclick="updateDateRanges()"
style="margin-left: 10px">Submit</button>
</div>
</div>
</div>
</div>
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>
I have some problem on Bootstrap 4.0.0 for input field full width across the column col-md-6
Here is my code. I just try to fix full width !
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
<div class="col-md-6 col-sm-6">
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
</div>
<div class="col-md-6 col-sm-6">
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
</div>
</div>
Here is the expected output ! If any markup suggestion for following output, please help me
Thanks in advance
Basically, you have two span elements inside each col-6. one of them should have a fixed size, and the other one (containing the input) should fill the rest of the space
Basically, I used flex to do that. socialMedia was used to make the parent element use the flex box model.
kb-icon was set to not grow or shrink, while kb-input was set to grow, meaning it will take up the rest of the space for each col-6 item
I also changed the spans into divs since (at least with the input) you want the item to have a specific size that is not based on the content of the element. The same could have been achieved by adding display: inline-block or display: block.
.socialMedia {
display: flex;
padding: 2px 0;
}
.kb-icon {
flex-grow: 0;
flex-shrink: 0;
margin: 0 5px;
/* just to make the icon centered */
display: flex;
align-items: center;
justify-content: center;
}
/* this item will act as a pseudo input element
we do that because we can't put a button inside
an actual input */
.kb-input {
flex-grow: 1;
/* I use flex to make the input as
large as possible without setting sized myself */
display: flex;
margin-right: 5px;
/* just to make it look better on small screens */
border: 1px solid grey;
/* imitate the input look */
}
/* this is used to create a focus effect on the fake input. if we use focus and not focus-within, nothing will happen. I use the same method bootstrap uses here */
.kb-input:focus-within {
outline: 0;
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, .25);
}
.kb-input input {
/* remove the input style to make it "transparent" */
border: 0;
border-radius: 0;
/* this is used to make sure it takes up the entire space */
flex-grow: 1;
}
/* make sure input does not have style on focus */
.kb-input input:focus {
outline: none;
box-shadow: none;
}
/* make the button transparent */
button.kb-close {
border: 0;
background: none;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div class="row">
<div class="col-md-6 col-sm-6">
<div class="socialMedia d-flex">
<div class="kb-icon"><img src="https://i.imgur.com/tyO9m6X.png" alt=""></div>
<div class="kb-input">
<input type="text" class="form-control ">
<button class="kb-close">
<i class="material-icons">close</i>
</button>
</div>
</div>
<div class="socialMedia d-flex">
<div class="kb-icon"><img src="https://i.imgur.com/tyO9m6X.png" alt=""></div>
<div class="kb-input">
<input type="text" class="form-control ">
<button class="kb-close">
<i class="material-icons">close</i>
</button>
</div>
</div>
<div class="socialMedia d-flex">
<div class="kb-icon"><img src="https://i.imgur.com/tyO9m6X.png" alt=""></div>
<div class="kb-input">
<input type="text" class="form-control ">
<button class="kb-close">
<i class="material-icons">close</i>
</button>
</div>
</div>
<div class="socialMedia d-flex">
<div class="kb-icon"><img src="https://i.imgur.com/tyO9m6X.png" alt=""></div>
<div class="kb-input">
<input type="text" class="form-control ">
<button class="kb-close">
<i class="material-icons">close</i>
</button>
</div>
</div>
</div>
<div class="col-md-6 col-sm-6">
<div class="socialMedia d-flex">
<div class="kb-icon"><img src="https://i.imgur.com/tyO9m6X.png" alt=""></div>
<div class="kb-input">
<input type="text" class="form-control ">
<button class="kb-close">
<i class="material-icons">close</i>
</button>
</div>
</div>
<div class="socialMedia d-flex">
<div class="kb-icon"><img src="https://i.imgur.com/tyO9m6X.png" alt=""></div>
<div class="kb-input">
<input type="text" class="form-control ">
<button class="kb-close">
<i class="material-icons">close</i>
</button>
</div>
</div>
<div class="socialMedia d-flex">
<div class="kb-icon"><img src="https://i.imgur.com/tyO9m6X.png" alt=""></div>
<div class="kb-input">
<input type="text" class="form-control ">
<button class="kb-close">
<i class="material-icons">close</i>
</button>
</div>
</div>
<div class="socialMedia d-flex">
<div class="kb-icon"><img src="https://i.imgur.com/tyO9m6X.png" alt=""></div>
<div class="kb-input">
<input type="text" class="form-control ">
<button class="kb-close">
<i class="material-icons">close</i>
</button>
</div>
</div>
</div>
</div>
I also added some comments in the CSS to explain why I did what I did to add the "clean input" button
basically, .kb-input is used as a pseudo input element (containing the actual input and a button). for more info, check the css.
If you want to remove the outline completely, don't apply the focus-within pseudo class, and make sure you set the following attributes on the element you want to disable it for:
outline: 0;
box-shadow: 0;
You can use the following, using a .form-group
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
<div class="col-md-6 col-sm-6">
<div class="socialMedia form-group row">
<label for="inputEmail3" class="col-1 col-form-label">
<img src="https://i.imgur.com/tyO9m6X.png" alt="">
</label>
<div class="col-sm-10">
<input type="text" class="form-control ">
</div>
</div>
<div class="socialMedia form-group row">
<label for="inputEmail3" class="col-1 col-form-label">
<img src="https://i.imgur.com/tyO9m6X.png" alt="">
</label>
<div class="col-sm-10">
<input type="text" class="form-control ">
</div>
</div>
<div class="socialMedia form-group row">
<label for="inputEmail3" class="col-1 col-form-label">
<img src="https://i.imgur.com/tyO9m6X.png" alt="">
</label>
<div class="col-sm-10">
<input type="text" class="form-control ">
</div>
</div>
<div class="socialMedia form-group row">
<label for="inputEmail3" class="col-1 col-form-label">
<img src="https://i.imgur.com/tyO9m6X.png" alt="">
</label>
<div class="col-sm-10">
<input type="text" class="form-control ">
</div>
</div>
</div>
<div class="col-md-6 col-sm-6">
<div class="socialMedia form-group row">
<label for="inputEmail3" class="col-1 col-form-label">
<img src="https://i.imgur.com/tyO9m6X.png" alt="">
</label>
<div class="col-sm-10">
<input type="text" class="form-control ">
</div>
</div>
<div class="socialMedia form-group row">
<label for="inputEmail3" class="col-1 col-form-label">
<img src="https://i.imgur.com/tyO9m6X.png" alt="">
</label>
<div class="col-sm-10">
<input type="text" class="form-control ">
</div>
</div>
<div class="socialMedia form-group row">
<label for="inputEmail3" class="col-1 col-form-label">
<img src="https://i.imgur.com/tyO9m6X.png" alt="">
</label>
<div class="col-sm-10">
<input type="text" class="form-control ">
</div>
</div>
<div class="socialMedia form-group row">
<label for="inputEmail3" class="col-1 col-form-label">
<img src="https://i.imgur.com/tyO9m6X.png" alt="">
</label>
<div class="col-sm-10">
<input type="text" class="form-control ">
</div>
</div>
</div>
</div>
If you want to center this, read about offsetting:
https://getbootstrap.com/docs/4.0/layout/grid/#offsetting-columns
My proposition:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
<div class="col-md-3 col-sm-3 offset-sm-3 offset-md-3 col-offset-3">
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control ">
</span>
</div>
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
</div>
<div class="col-md-3 col-sm-3">
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
<div class="socialMedia d-flex">
<span><img src="https://i.imgur.com/tyO9m6X.png" alt=""></span>
<span>
<input type="text" class="form-control">
</span>
</div>
</div>
</div>
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>