Apologies)
I'm struggling to find a solution to placing two buttons in a column (or two columns?) aligned to a text box to the left of them. I've done this by creating a rect within a colunm then adding the buttons (aligned) floating to the right. Looks fine in a desktop screen but once sized down to mobile the buttons (not being in columns) fall apart. I've attached a screenshot of the page: one row has an attempt but the buttons are placed over the existing column (text box) in the row. It's quite possibly staring me in the face but I can't see it!
Here's a snippet for the row and column:
<div class="row">
<div class="col-8 col-md-6 white-rect mr-4 ">
<ul>
<li>
Book flights.
</li>
</ul>
<button type="button" class="btn my-primary btn-sm my-small-btn">COMPLETE</button>
<button type="button" class="btn my-primary2 btn-sm my-small-btn"> DELETE </button>
</div>
</div>```
And here's the code for the the row with the buttons that are aligned in desktop but are effectively floating outside a column:
```<div class="row">
<div class="col-8 col-md-6 white-rect mr-4">
<ul>
<li>
Reschdule Twitter Meeting.
</li>
</ul>
</div>
<button type=".button" class="btn my-primary btn-sm my-small-btn">COMPLETE</button>
<div class="col-sm-1 col-xs-1 col-md-1 col-lg-1"></div>
<button type=".button" class="btn my-primary2 btn-sm my-small-btn"> DELETE </button>
</div>
Many thanks.
you might need to adjust the numbers, but something like this is how I would do it:
.grid {
display: grid;
grid-gap: 12px;
grid-template-columns: 1fr max-content;
}
#media screen and (min-width: 768px) {
.grid {
grid-gap: 24px;
grid-template-columns: minmax(200px, 1fr) minmax(max-content, 1fr);
}
}
.input {
width: 100%;
}
<section class="grid">
<div class="input-container">
<input type="text" class="input">
</div>
<div class="buttons-container">
<button class="button">complete</button>
<button class="button">delete</button>
</div>
<div class="input-container">
<input type="text" class="input">
</div>
<div class="buttons-container">
<button class="button">complete</button>
<button class="button">delete</button>
</div>
<div class="input-container">
<input type="text" class="input">
</div>
<div class="buttons-container">
<button class="button">complete</button>
<button class="button">delete</button>
</div>
<div class="input-container">
<input type="text" class="input">
</div>
<div class="buttons-container">
<button class="button">complete</button>
<button class="button">delete</button>
</div>
</section>
Related
I am trying to make a simple example where I have a row and inside that row is columns. One column is for the name of the left-hand side and on the right-hand side is the three buttons that exist. However, I am having issues placing the buttons properly on the right side as well as spacing them at an appropriate distance. I tried using the max-width in my CSS but I just ended up screwing up the project even more. Below is my HTML/CSS file:
#submitGPBtn {
margin-right: 30px;
}
<div class="row">
<div>
<h4> Group Pattern Test</h4>
</div>
<div class="mx-auto">
<button class="btn btn-primary">Save</button>
</div>
<div class="mx-auto">
<button class="btn btn-primary">Close</button>
</div>
<div class="ml-auto">
<button class="btn btn-primary" id="submitGPBtn">Submit</button>
</div>
</div>
You would want to use a btn-toolbar to group your buttons in-line.
#submitGPBtn {
margin-right: 30px;
}
<div class="row">
<div class="col">
Group Pattern Test
</div>
<div class="col">
<div class="btn-toolbar">
<button class="btn btn-primary">Save</button>
<button class="btn btn-primary">Close</button>
<button class="btn btn-primary" id="submitGPBtn">Submit</button>
</div>
</div>
</div>
This question has been answered well here. But here's an example below, add float-right class to your button bar, you can put a breakpoint in the class like float-sm-right but float-right works on any viewport width.
#submitGPBtn {
margin-right: 30px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col">
Group Pattern Test
</div>
<div class="col">
<div class="btn-toolbar float-right">
<button class="btn btn-primary">Save</button>
<button class="btn btn-primary">Close</button>
<button class="btn btn-primary" id="submitGPBtn">Submit</button>
</div>
</div>
</div>
In bootstrap ml-auto is fine to align buttons to the right, but you should apply it only to the first item after the "offset".
I added ml-1 to space the other buttons and a lightyellow background just to show where the container ends.
My personal suggestion when you use bootstrap is to code inside a container, you can't set its size to what you want but it prevents stretching in wide monitors.
.container {
background-color: lightyellow;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col text-left">
<h4> Group Pattern Test</h4>
</div>
<button class="btn btn-success ml-auto">Save</button>
<button class="btn btn-success ml-1">Close</button>
<button class="btn btn-success ml-1" id="submitGPBtn">Submit</button>
</div>
</div>
I have something like this:
<div class="form-group col-sm-6">
<div id="total">$50,20</div>
<button class="btn btn-theme" data-role="button" id="purchase"><i class="fa fa-envelope-o"></i>Send</button>
</div>
I want the total to be to the left of the button, but it appears over the button. I already tried making the column bigger but it stays there so the problem is not on the size.
You want it on the left? like this?
then,
<div class="form-group col-sm-6">
<div class="col-xs-1">
<label id="total">$50,20</label>
</div>
<div class="col-xs-1">
<button class="btn btn-theme" data-role="button" id="purchase"><i class="fa fa-envelope-o"></i>Send</button>
</div>
</div>
i would do it like this
<div class="form-group col-sm-12">
<div class=" col-sm-6" id="total">$50,20</div>
<div class=" col-sm-6">
<button class="btn btn-theme" data-role="button" id="purchase"><i class="fa fa-envelope-o"></i>Send</button>
</div>
div is by default a block element and that means that it takes up the whole available space.
Try to add this css rules:
#total {
display: inline-block;
float: left;
}
Alternatively, you could make the amount a span element like
<span id="total">$50,20</span>
I want to make the Submit button's length same as the input field above it.
<div class="row">
<div class="input-field col s12">
<input id="speciality" type="text" class="validate">
<label for="speciality">Speciality</label>
</div>
</div>
<div class="row">
<button class="btn waves-effect waves-light" type="submit" name="action">Search
<i class="material-icons right">search</i>
</button>
</div>
If your column which you have your input field in is limited to a certain width (in the way how the Bootstrap columns work), you can put the .btn inside a column as well.
After that, you can use the following CSS to make the width equal to the input field:
.col.s12 > .btn {
width: 100%;
}
Of course if the button as an element does not bend to this CSS-rule, you can use <a class="btn"> instead.
Surround the button with a div with col s12 classes and add btn-block to the button:
<div class="row">
<div class="col s12">
<button class="btn btn-block waves-effect waves-light" type="submit" name="action">Search
<i class="material-icons">search</i>
</button>
</div>
</div>
And add the following CSS:
.btn-block {
width: 100%;
}
I am attempting to center the search bar in my navbar. I am using bootstrap, I tried text-center on the md-4 but it had no effect.
Here is a link to my code.
http://bootsnipp.com/snippets/50b38
Bootstrap uses a grid of 12 columns. Your code had the first column be 8 and the 2nd one be 4. This would mean that your first column would be 2/3 of the page. By making it col-md-4, it allows your middle div to be center.
<div class="row top-header">
<div class="container">
<div class="col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=30&txt=320%C3%97240&w=235&h=126" alt="logo image" />
</div>
<div class="col-md-4">
<div id="search-center">
<div class="input-group">
<input type="text" class="form-control input-lg" placeholder="Search" />
<span class="input-group-btn">
<button class="btn btn-info btn-lg" type="button">
<i class="glyphicon glyphicon-search"></i>
</button>
</span>
</div>
</div>
</div>
</div>
</div>
Here is an updated source:
http://bootsnipp.com/user/snippets/E7WgX
over your code in css tag, i put that and seems ork
.top-header {
background-color: #D9D9D9;
text-align:center;
}
Expect it help you
I have the following code
html page(part of it)
<div class="container">
<div class="right-page col-md-9">
<div class="row">
<div class="category-item col-md-4">
<form action="/settings/category/2/" method="post" class="form-inline">
<div class="container">
<div class="row input-container">
<div class="form-group">
<div class="col-md-8">
<input class="form-control input-sm col-md-3" type="text" value="KONS ">
</div>
<div class="col-md-3">
<input class="form-control input-sm col-md-3 myColorPicker">
</div>
</div>
</div>
</div>
<div class="container">
<div class="row btn-container">
<button class="btn btn-default btn-sm edit-category">Cancel</button>
<button name="delete" class="btn btn-default btn-sm">Delete</button><input type="submit" name="submit" class="btn btn-default btn-sm" value="Save">
</div>
</div>
</form>
</div>
</div>
</div>
and the css (part of it)
.diagnosis-phrase,
.treatment-phrase,
.category-item{
padding-bottom: 1em;
padding-top: 0.5em;
border: 1px solid black;
margin-bottom: 0.5em;
}
.diagnosis-phrase input[type="text"],
.treatment-phrase input[type="text"],
.category-item input[type="text"]{
margin-bottom:0.5em;
}
.category-item p{
padding-left: 0.5em;
padding-bottom:0.3em;
border-radius:0.5em;
width:50%;
}
The bootply for it. The part of html is the right column of a two column webpage. As you can see inside the div with black border I have two input boxes(For some reason the second appears outside the div with borders but in my working code appears correctly. Maybe because of me providing part of page.). My problem is that the first one is not aligned with the Cancel button. How can I do that using bootstrap classes?
if you use the following styles
.form-group .col-md-8:first-child {padding-left:0;}
It should fix your problem
Or if you just change the col-md-8 class on your div to col-md-pull-8 it should also achieve the same thing