Simple spacer in buttons and search bar in Bootstrap 3 - ruby-on-rails

I am trying to insert a Label, Search bar, Button group in a Panel Heading.
I have the following code
<div class="panel panel-default">
<div class="panel-heading">
<span class="label label-default">
<%= yield(:title) %>
</span>
<div class="btn-group pull-right" role="group" >
<button type="button" class="btn btn-default">
<% if can? :create, Client %>
<%= link_to 'New', new_client_path %>
<% end %>
</button>
<button type="button" class="btn btn-default">Middle</button>
<button type="button" class="btn btn-default">Right</button>
</div>
<div class="input-group col-lg-3 pull-right">
<input type="text" class="form-control" placeholder="Search">
<div class="input-group-btn">
<button class="btn btn-primary"><i class="glyphicon glyphicon-search"></i></button>
<button class="btn btn-primary"><i class="glyphicon glyphicon-wrench"></i></button>
</div>
</div>
</div>
<div id="clients"><%= render 'clients' %></div>
<p class="small"><%= will_paginate #clients %></p>
</div>
As of now it works, but search bar and button group have no space between them. I would like to have ateast 5px space between them so like this:
-----------------------------------------------------------------
Label Search -space- btn group
-----------------------------------------------------------------
How to achieve this?
I am using Rails 4 with Sass

To answer the question better we would need to know what CSS you are using. Guessing I suggest adding a DIV around your search input and add a class with a display: inline-block and then add a right padding.
<div class="mycustclass">
<input type="text" class="form-control" placeholder="Search">
</div>
.mycustclass {
display: inline-block;
padding-right: 5px;
}
You would also need your .input-group-btn class to use a display:inline-block as well.
If that doesn't work there are plenty of other options.

Just write margin-right:5px in first btn-primary inline than it will be work
not write padding-right
<div class="input-group-btn">
<button class="btn btn-primary" style="margin-right:5px;"><i class="glyphicon glyphicon-search"></i></button>
<button class="btn btn-primary"><i class="glyphicon glyphicon-wrench"></i></button>
</div>

Related

Trigger all bootstrap collapses with jquery at once

Hello I am using bootstrap-5 collapses. I have multiple collapses an I need to trigger them all using jquery(not bootstrap button).Here are my collapses.Here is my code
<p>
<a class="btn btn-primary" data-bs-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a>
<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Toggle second element</button>
<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button>
</p>
<div class="row">
<div class="col">
<div class="collapse multi-collapse" id="multiCollapseExample1">
<div class="card card-body">
Some placeholder content for the first collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
</div>
</div>
</div>
<div class="col">
<div class="collapse multi-collapse" id="multiCollapseExample2">
<div class="card card-body">
Some placeholder content for the second collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
</div>
</div>
</div>
</div>

How to place objects in one line [Bootstrap 5]

I need it in one line, how to fix this?
Use the Bootstrap 5 grid system (ensure you are including the Bootstrap 5 css url)
Example:
<div class="container">
<div class="row">
<div class="col">
Column
</div>
<div class="col">
Column
</div>
<div class="col">
Column
</div>
</div>
</div>
https://getbootstrap.com/docs/5.0/layout/grid/
Your code would look, something like this:
<div class="d-none d-lg-block d-xl-block">
<div class="nav-item">
<div class="row">
<div class="col">
<form class="d-flex" action="search.php" method="get">
<input class="form-control me-2 px-3" type="search" placeholder="Search" name="search" aria-label="Search">
</form>
</div>
<div class="col">
<button class="btn btn-outline-success" data-bs-toggle="modal" data-bs-target="#loginmodal">Login</button>
<button class="btn btn-outline-success" data-bs-toggle="modal" data-bs-target="#signupmodal">Sign Up</button>
</div>
</div>
</div>
</div>
You could also put the signup button into a column on its own.
Add your buttons inside the form, or add d-flex to your nav-item class
Like this:
<div class="nav-item d-flex">

bootstrap5 way of right aligning two buttons

I am using Bootstrap5 and wondering how to align two buttons to the right in the same column as the "Delete" button. Another problem is no matter which "breakpoint" (md, sm) I use it's not possible to right align these two buttons properly. I am wondering what is the bootstrap way of doing it.
Snippet
<form>
<div class="hx-form-group position-relative">
<label for="el62ba8cb87eb84be2bebc9c2970de0552" class="form-label">Goal #1</label><span class="input-group"><input id="el62ba8cb87eb84be2bebc9c2970de0552" type="text" class="form-control" placeholder="Enter goal #1 text here." _bl_6="">
<button type="button" class="hx-button btn btn-danger" _bl_7="">
Delete
</button>
</span>
<div class="form-text">Hint: enter short, precise description what you want to do today</div>
</div>
<div class="hx-form-group position-relative">
<label for="el28a7e89fc62249dd80048d65487a2354" class="form-label">Goal #2</label><span class="input-group"><input id="el28a7e89fc62249dd80048d65487a2354" type="text" class="form-control" placeholder="Enter goal #2 text here." _bl_8="">
<button type="button" class="hx-button btn btn-danger" _bl_9="">
Delete
</button>
</span>
<div class="form-text">Hint: enter short, precise description what you want to do today</div>
</div>
<div class="hx-form-group position-relative">
<label for="ele59dd34cf9ed4db2a92de894f47b5946" class="form-label">Goal #3</label><span class="input-group"><input id="ele59dd34cf9ed4db2a92de894f47b5946" type="text" class="form-control" placeholder="Enter goal #3 text here." _bl_10="">
<button type="button" class="hx-button btn btn-danger" _bl_11="">
Delete
</button>
</span>
<div class="form-text">Hint: enter short, precise description what you want to do today</div>
</div>
<div class="container text-center">
<div class="row justify-content-end">
<div class="col-4">
<button type="button" class="hx-button btn btn-secondary" _bl_4="" disabled="">
New Goal
</button>
</div>
<div class="col-4">
<button type="submit" class="hx-button btn btn-primary">
Save
</button>
</div>
</div>
</div>
</form>
First of all, you don't need to use row and col as a wrapper of buttons as row cols have different purposes so you can do it like this
[https://codepen.io/kukrati/pen/YzaYEXy]
and make sure you have removed its parent .container class
if you don't want to change your existing layout due to some limitations then you just need to replace .col-lg-4 with .col-auto and then remove the parent .container class

Bootstrap Carousel Button Position

I need to change the position of some element in a bootstrap carousel.
I have this example slide and i want to change position for the primary button but i don't find any type of suggest online.
<div class="carousel-inner">
<div class="item active">
<img id="sliderImage" src="~/Content/images/SfondoF&VHomeSlide.png">
<div class="container">
<div class="carousel-caption" >
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="Slide" align="center" style="margin-top:30px">
<a class="btn btn-lg btn-primary" href="http://getbootstrap.com">Learn More</a>
</div>
</div>
</div>
</div>
Please, can you help me?
Thanks to all
you change carousel-caption class.
try this:
<div class='item active'>
<img class='sliderImage' src='images/man2.jpg' alt=''>
<div class='container'>
<div class='col-sm-8'>
<div class='carousel-content'>
<a class='btn btn-lg btn-primary' href="http://getbootstrap.com">Learn More</a>
</div>
</div>
</div></div>
Add an id to your button and change the position in CSS, hope that help
Something like this ...
HTML :
<a class="btn btn-lg btn-primary" href="http://getbootstrap.com" id="test">Learn More</a>
CSS :
#test{padding-top:80px;}

Bootstrap button group and form_for

In my Rails app I'd like to use a Bootstrap button group. There is a single field, and each button represents a different state .. ie like radio buttons.
Even better if I can do it with simple_form but can't find a solution by Googling.
<%= simple_form_for #user_word, url: user_words_path, remote: true, wrapper: :inline_form, html: { class: 'form-inline' } do |f| %>
<div class="row">
<div class="col-sm-12">
<div id="selector" class="btn-group btn-group-sm" >
<button class="btn level-unknown" id='unknown' type="button">Unknown</button>
<button class="btn level-low" id='low' type="button">Low</button>
<button class="btn level-medium active" id='medium' type="button">Medium</button>
<button class="btn level-high" id='high' type="button">High</button>
<button class="btn level-known" id='known' type="button">Known</button>
</div>
</div>
</div>
<% end %>
Not sure exactly what you're asking. If your issue is that the active class is not switching to your clicked button, it's because you need javascript to do so.
$('#selector button').on('click',
function(e){
var $obj=$(e.target);
$('#selector .active').removeClass('active'); //remove active class from buttons
$obj.addClass('active'); //add active class to clicked button
});
See a working example here https://jsfiddle.net/DTcHh/14519/
Edit:
I just learned that this functionality is built in to the bootstrap javascript library. Your markup just needs to be modified to match this syntax
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary active">
<input type="radio" name="options" id="option1" autocomplete="off" checked> Radio 1 (preselected)
</label>
<label class="btn btn-primary">
<input type="radio" name="options" id="option2" autocomplete="off"> Radio 2
</label>
<label class="btn btn-primary">
<input type="radio" name="options" id="option3" autocomplete="off"> Radio 3
</label>
</div>
See example at http://getbootstrap.com/javascript/#buttons-checkbox-radio

Resources