vertical align across bootstrap div span - html

I am using bootstrap on my application and having a hard-time to vertically align some items using bootstrap. It consist of one bootstrap row and 3 span4 with a search bar, a title and navigation links.
This is the skeleton:
<div class="row">
<div class="span4">
form code, as generated by rails form_for
<div class="span4">
Page title
<div class="span4">
pagination links, as generated by rails will_paginate
This is the rails code:
<div class="row">
<div class="span4">
<%= form_tag mybooks_path, class: "form-search", :method => 'get', :id => "mybooks_search" do %>
<div class="input-append">
<%= text_field_tag :search, params[:search], class: "search-query" %>
<%= submit_tag "Search", :name => nil, class: "btn" %>
</div>
<% end %>
</div>
<div class="span4">
<h2>My book library</h2>
</div>
<div class="span4">
<%= will_paginate #mybooks, class: "pagination pagination-right" %>
</div>
</div>
And here is the JSFiddle:
http://jsfiddle.net/V7CVE/2/
I am using the standard uncustomized bootstrap 2, and I need the search-box, the page title and the pagination links to be vertically aligned to each other.

I'm not familiar with ruby syntax, but conceptually this should not make a difference. The reason they are not aligned is that bootstrap has its own default css for different elements. You just need to fine tune each element by overriding these bootstrap styles.
apply the following styles:
.form-search {
margin: 15px 0 0 0;
}
.pagination {
margin: 15px 0;
}

Related

How to properly display bootstrap columns on Safari?

I have a landing page that contains six hero images. I have it set up to display three images per row, in two rows. This works fine on Chrome, Firefox, IE, Opera, but not on Safari (10.1). Instead of the neat rows, the first row has two images, the second three, and the third one. Here is my erb file:
<section class="grouping">
<div class="wrapper grouping">
<div class="intro-content grouping row">
<% flash.each do |key, value| %>
<div class="alert alert-<%= key %>" role="alert">
<%= value %>
</div>
<% end %>
<div class="landing-image-container col-xs-12 col-sm-4">
<%= link_to image_tag("news.jpg"), articles_path, class: 'image-link' %>
<h4 class="landing-headings text-centered"><%= link_to "News", articles_path, class: 'landing-link' %></h4>
</div>
<div class="landing-image-container col-xs-12 col-sm-4">
<%= link_to image_tag("Our People.JPG"), support_path, class: 'image-link' %>
<h4 class="landing-headings text-centered"><%= link_to "Peer Support", support_path, class: 'landing-link' %></h4>
</div>
<div class="landing-image-container col-xs-12 col-sm-4">
<%= link_to image_tag("training.jpg"), training_path, class: 'image-link' %>
<h4 class="landing-headings text-centered"><%= link_to "Training", training_path, class: 'landing-link' %></h4>
</div>
<div class="landing-image-container col-xs-12 col-sm-4">
<%= link_to image_tag("calendar.jpg"), calendar_path, class: 'image-link' %>
<h4 class="landing-headings text-centered"><%= link_to "Calendar", calendar_path, class: 'landing-link' %></h4>
</div>
<div class="landing-image-container col-xs-12 col-sm-4">
<%= link_to image_tag("about.jpg"), resources_path, class: 'image-link' %>
<h4 class="landing-headings text-centered"><%= link_to "Trans Resources", resources_path, class: 'landing-link' %></h4>
</div>
<div class="landing-image-container col-xs-12 col-sm-4">
<%= link_to image_tag("Get Involved.JPG", id: 'involved-image'), involved_path, class: 'image-link' %>
<h4 class="landing-headings text-centered"><%= link_to "Get Involved", involved_path, class: 'landing-link' %></h4>
</div>
</div>
</div>
</section>
I know that the specification for Bootstrap says that you should wrap a row in a .container, I've tried this setup with .container and .container-fluid, nothing changes except some slight padding on the left and right. The .grouping class is a clearfix hack:
.grouping:before,
.grouping:after {
content: " ";
display: table;
}
.grouping:after {
clear: both;
}
Here's the css for .wrapper and .intro-content:
.wrapper {
width:100%;
margin: 9em auto 0;
padding-bottom: 9em;
box-shadow: 0 8px 1em rgba(0, 0, 0, 0.1);
}
.intro-content {
margin: 4em auto;
max-width: 1100px;
width: 90%;
}
I've messed with these settings quite a bit, reducing all padding and margin to 0 and things like that, but the problem remains. Googling this has provided a few hacky solutions, none of which worked.
Found this on one of GitHub forums:
.row:before, .row:after {
display: inline-block;
}
Helped me a lot.
It does not affect bootstrap columns behaviour on edge, chrome and Firefox.

Move pagination to footer

I trying to move pagination to footer on my website.
I don't want to ready solution, I would like to make this alone, but I do not know where to start, how can a real programmer handle this?
*I finished this site lately from book, and now i trying to do something alone.
code:
<div id="pins" class="transitions-enabled">
<% #pins.each do |pin| %>
<div class="box">
<div class="panel panel-default">
<%= link_to image_tag(pin.image.url(:medium)), pin %><br/>
<div class="panel-body">
<%= pin.description %><br/>
<br/>
<strong><%= pin.user.name if pin.user %></strong><br/>
</div>
<% if pin.user == current_user %>
<div class="panel-footer">
<%= link_to 'Edit', edit_pin_path(pin) %><br/>
<%= link_to 'Delete', pin, method: :delete, data: { confirm: 'Are you sure?' } %>
</div>
<% end %>
</div>
</div>
<% end %>
</div>
<br/>
<div class="center">
<%= will_paginate #posts, renderer: BootstrapPagination::Rails %>
</div>
screen:
You havent showed your containers. If you pass all content in order and into containers:
<div class="container">
<div class="row">
<div class="col-md-12">
Stff..
</end>
</end>
</end>
All should be fine. As a fast fix try to:
<div class="center col-md-12">
<%= will_paginate #posts, renderer: BootstrapPagination::Rails %>
</div>
But this just a fast fix, not solution...
And your code is a bit messy, and you have one closing div, but havent showed where it was opened

Link does not work after resize of window

I have a page with bootstrap div's and 2 images and buttons on the page. In full screen, the page works fine. But when I resize the page only one of the images and 1 of the 2 buttons work. The images are side by side in full screen but when they resize one is on top of the other ant the top button and image cannot be pressed. Here is the view.
<div class="jumbotron">
<div class="center-block">
<img src="https://s3.amazonaws.../Frontpage_logo.png" class="img-responsive" alt="...">
</div>
<div class="text-center">
<br/>
<br/>
<% if user_signed_in? %>
<%= link_to 'Your Dashboard', users_dashboard_url, class: 'btn btn-primary' %>
<% elsif manager_signed_in? %>
<%= link_to "Your Dashboard", managers_dashboard_url, class: 'btn btn-primary' %>
<% elsif admin_signed_in? %>
<%= link_to "3rd Party/Supplier Dashboard", admins_dashboard_url, class: 'btn btn-primary' %>
<br/>
<br/>
<%= link_to 'Monitoring', sidekiq_web_path %>
<% else %>
<div class="container-fluid">
<div class="col-md-5">
<div class= "pull-left">
<h3><strong>See how we ...!</strong></h3>
<img src="https://s3.amazonaws.../manager_video.jpg" class="img-responsive">
<br>
<%= link_to "Manager", managers_why_url, class: 'btn btn-primary' %>
</div>
</div>
<div class="col-md-2">
<div class="text-center">
<h2>or</h2>
</div>
</div>
<div class="col-md-5">
<div class= "pull-right">
<h3><strong>See how we are helping ...!</strong></h3>
<img src="https://s3.amazonaws.../user_video.jpg" class="img-responsive">
<br>
<%= link_to "Tenant", users_why_url, class: 'btn btn-primary' %>
</div>
</div>
</div>
</h2>
</div>
<% end %>
</div>
If you wish to have the images side by side without overlapping when resized, change col-md-* to col-xs-*. Do so with rest.
I hope this helps.
I hope this should work for you.
Please try this code instead of yours. i made some small changes.
See how we ...!
or
See how we are helping ...!
When we create table using Bootstrap then it should go in side the "row" class. and when you re-size the window some other element is coming above of all the screen. that's way you was not able to click images. and on the End of your code 4th line from the bottom. there is no stating tag for closing "h2" tag.

Simple Form check box left alignment

I have a rails 4 app with simple form.
There is a check box element in the app where the box is to the left of the label.
<div class="row">
<div class="col-md-3 col-md-offset-1">
<%= f.label :'How will you share the project results?', :class => 'question-project' %>
</div>
<div class="col-md-7">
<div class= "response-project">
<%= f.input :report, as: :boolean, inline_label: 'A report on project outcomes', label: false, :item_wrapper_class => 'inline' %>
<%= f.input :other_outcome, :as => :boolean, :label => false, :inline_label => true %>
</div>
</div>
</div>
The css for response-project is:
.response-project {
font-weight: normal;
font-family: 'Roboto', sans-serif;
color: light-grey;
font-size: 16px;
line-height: 2;
}
The check box is aligned further to the left than all of the remaining form elements. That seems to come from simple form. Does anyone know how to turn that alignment off so that the check box is aligned to the left of the form, in a uniform line with all other elements of the form?
Thank you
There was a Stack post very similar like this here: simple_form with Bootstrap check box
What you need to do is create a custom wrapper in config/initializers/simple_form.rb. Read more here https://github.com/plataformatec/simple_form/wiki/Custom-Wrappers
According to bootstrap, you need to layout the checkbox style and class to be something like this
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label>
<input type="checkbox"> Remember me
</label>
</div>
</div>
</div>
add :item_wrapper_class => 'inline' to your code.

Carrierwave/Rails/CSS - HTML style attribute being generated seemingly automatically

I'm using carrierwave with rails 4. I need image upload functionality on a few models in my app and it's working great on all of them except one. On the adverts model, all the uploaded images seem to have the following HTML style attributes being generated automatically (or seemingly so):
<img alt="Advert" src="..image_path_is_correct..." width="0" height="0" style="display: none !important; visibility: hidden !important; opacity: 0 !important; background-position: 1px 1px;">
My form is declared like so:
<%= form_for [#user, #advert] do |f| %>
<div class="form-field-area-centered">
<p class="form-label"><%= f.label :advert_image, "New Advert" %></p>
<p class="form-field"><%= f.file_field :advert_image %></p>
</div>
<%= f.submit "SAVE", :class => "button button-green button-login" %>
<% end %>
and in my view I have:
<div class="advert-area">
<%= image_tag #first_post.user.adverts.last.advert_image_url %>
</div>
I'm kind of at a loss as to what could be causing this so any help would be much appreciated.