Scss: text-align not working - html

Well, I tried solving this on my own but it seems like that many people have the same problem for all sort of different reasons, so here is my situation:
<div class="col-md-4">
<ol class="albums">
<%= render #albums %>
</ol>
<%= will_paginate #albums %>
</div>
#album:
<li id="album-<%= album.id %>" class="listed_album">
<div class=row>
<aside class="col-md-6" id="album_cover">
<% if album.clips.any? %>
<%= link_to album do %>
<img src="http://img.youtube.com/vi/<%= album.clips.first.adress %>/mqdefault.jpg" height="110" width="178">
<% end %>
<% else %>
<%= link_to album do %>
<img src="http://img.youtube.com/vi/ksjfhskd4/0.jpg" height="110" width="178">
<% end %>
<% end %>
</aside>
<div class="col-md-6" id="album_info">
<p><span class="title"><%= album.title %></span></p>
<span class="likes">
<%= pluralize(Album.find(album_to_display).relationships.where(value: 1).count, "like") %> |
<%= pluralize(Album.find(album_to_display).relationships.where(value: -1).count, "dislike") %>
</span>
</div>
</div>
</li>
I would like to have the title in the top-center of its col and span.likes in the bottom-left (top and bottom relative to the height of the picture in the col to the left) but until now I was only able to move it with something like padding-right: 15px; for example. How do I need to adjust it, in order to make things like text-align: center; or float: bottom; work?
li.listed_album {
#album_info {
span.title {
text-align: center;
}
span.likes {
float: bottom;
}
}
}

Hard to tell without being able to see it on jsfiddle or codepen.. Have you tried this:
li.listed_album {
#album_info {
text-align: center;
}
span.likes {
float: bottom;
}
}
or just make #album_info a flexbox:
#album_info {
display:flex;
justify-content: center;
}

Related

How to either separate text and button for skew, or combine text and button?

So I have this following code that works, but I can't separate the text from the button. For instance, when skewed, the text skews. Any way to separate them?
<div class="row">
<div class="left">
<h2>Categories</h2>
<div class="categories-">
<% #categories.each do |cat| %>
<%= link_to cat.name, listings_path(:category => cat), class: "btn btn-primary-2" %>
<% end %>
</div>
Here's the CSS:
.categories- {
padding-top: 30px;
font-size: 30px;
-webkit-font-smoothing: antialiased;
}
I then attempted doing this, which works, but the button itself when clicked, doesn't click to anything as it's not attached to the link. Any way to attach it?
<div class="categories-">
<% #categories.each do |cat| %>
<div id="btn-text"><div id="btn-cat"><%= link_to cat.name, listings_path(:category => cat) %></div></div>
<% end %>
</div>
I was told you add but that didn't work.
Here's the CSS:
#btn-cat {
transform: skew(-15deg);
background: linear-gradient(to right, yellow, red) !important;
border: none;
color: white;
padding: 20px;
display: inline-block;
margin: 4px 2px;
cursor: pointer;
border-radius: 16px !important;
box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.3);
}
#btn-text {
transform: skew(15deg);
background: transparent;
border: none;
color: white !important;
text-decoration: none !important;
How can I accomplish either one of those methods? The top one the text and button won't detach. The bottom one, the button and text won't attach.
without seeing your controllers or routes I would have to guess it would have to be:
<% #categories.each do |cat| %>
<%= link_to cat.name, category_path(cat), class: "btn btn-primary-2" %>
<% end %>
But if you're not using the conventional restful routes, and your passing a model that doesn't correlate to the controller with same name type as class of your instance variable, you'll need to be more verbose.
<% #categories.each do |cat| %>
<%= link_to cat.name, controller: 'listings', action: 'show', id: cat.id, class: 'btn btn-primary-2' %>
<% end %>
The above should try to produce:
Category Name
# where 23 and Category name are repspective from the cat object.
See documentation for the variations on how to use link_to helper
If you want separate the text from the button and use #btn-cat and #btn-text separately.
You can use:
<div class="categories-">
<% #categories.each do |cat| %>
<div id="btn-cat">
<%= link_to listings_path(:category => cat) do %>
<div id="btn-text"><%= cat.name %></div>
<% end %>
</div>
<% end %>
</div>
Now, all the button it's a link :)

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.

why does height: auto not provide content area large enough to fit my content?

When a user is logged out, the header shows a logo and a log-in form, which the header needs to be large enough to accommodate. When a user logs in, they see the full navigation on a header that no longer needs to be quite so large. I'd think that setting height:auto to "site-header" would accomplish this, but this just makes the form float over the header's bottom border.
html:
<header>
<div class="site-header">
<%= link_to full_title(yield(:title)), root_path, class: "logo" %>
<nav>
<% if user_signed_in? %>
<%= link_to "Sell", new_item_path %>
<%= link_to "FAQ", pages_faq_path %>
<%= link_to "Settings", edit_user_registration_path %>
<%= link_to "Log out", destroy_user_session_path %>
<% end %>
</nav>
<div class="log-in">
<% if !user_signed_in? %>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="form">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, class: 'peach' %>
</div>
<div class="form">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off", class: 'peach' %>
<%= f.submit "LOG IN", class: 'button-functional' %><br>
<%= render "devise/shared/forgotpass" %>
</div>
<% end %>
<% end %>
</div>
</div>
</header>
css:
header {
background-color: white;
top: 0;
left: 0;
right: 0;
z-index: 0;
border-bottom: 1px dashed black;
.site-header {
margin: 0 2em;
padding: 1em 0;
height: auto;
nav {
float: right;
a {
margin-right: 2em;
}
a:last-child {
margin-right: 0;
}
}
.log-in {
float: right;
.form {
float: left;
}
input {
margin-right: 1em;
}
}
}
}
I made a Plunker with your example and it does fill the space.
https://plnkr.co/edit/QMiHzA89NZrDkpsrCefF
HTML
<header>
<div class="site-header">
<%= link_to full_title(yield(:title)), root_path, class: "logo" %>
<nav>
<% if user_signed_in? %>
<%= link_to "Sell", new_item_path %>
<%= link_to "FAQ", pages_faq_path %>
<%= link_to "Settings", edit_user_registration_path %>
<%= link_to "Log out", destroy_user_session_path %>
<% end %>
</nav>
<div class="log-in">
<% if !user_signed_in? %>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="form">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, class: 'peach' %>
</div>
<div class="form">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off", class: 'peach' %>
<%= f.submit "LOG IN", class: 'button-functional' %><br>
<%= render "devise/shared/forgotpass" %>
</div>
<% end %>
<% end %>
</div>
</div>
</header>
CSS
header {
background-color: white;
top: 0;
left: 0;
right: 0;
z-index: 0;
border-bottom: 1px dashed black;
.site-header {
margin: 0 2em;
padding: 1em 0;
height: auto;
nav {
float: right;
a {
margin-right: 2em;
}
a:last-child {
margin-right: 0;
}
}
.log-in {
float: right;
.form {
float: left;
}
input {
margin-right: 1em;
}
}
}
}
Maybe you have some other CSS messing around.

CSS changes when logging out Rails

I'm working on a simple image gallery, and I suddenly noticed
a weird bug I can't figure out.
The page looks the way its supposed to when a user is logged in, however
once the user logs out, the image-specific CSS gets destroyed.
I'm using Rails 4 with Twitter Bootstrap gem
ERB/HTML
<div class="container">
<div class="row">
<% #projects.each do |project| %>
<div class="col-lg-4 col-md-3 col-sm-3 col-xs-12 prosjekt_ramme">
<div class="prosjekt">
<p class="prosjekt_content">
<%= project.content %>
<% if user_signed_in? %>
<%= link_to 'Slett', project, method: :delete, data: { confirm: 'Er du sikker?' } %> </p>
<% end %>
<%= image_tag(project.picture.url, class: "img-responsive project_image") %>
</div>
<hr>
</div>
<% end %>
</div>
</div>
CSS
.prosjekt {
background-color: #eee;
padding: 0;
text-align: center;
margin-bottom: 5%;
height: 350px;
img {
max-width: 100%;
max-height: 80%;
display: block;
margin: auto;
}
}
If I remove
<% if user_signed_in? %>
<%= link_to 'Slett', project, method: :delete, data: { confirm: 'Er du sikker?' } %></p>
<% end %>
The image-specific CSS stays destroyed, whether I'm logged in or not.
Got any idea what's going on?
You are closing your p tag within the if conditional. As a result, it never closes if the user is not signed in. This is probably what is messing up the styling. Try this:
<div class="prosjekt">
<p class="prosjekt_content">
<%= project.content %>
<% if user_signed_in? %>
<%= link_to 'Slett', project, method: :delete, data: { confirm: 'Er du sikker?' } %>
<% end %>
</p>
<%= image_tag(project.picture.url, class: "img-responsive project_image") %>
</div>
Or, if you don't want the link to be part of the paragraph:
<div class="prosjekt">
<p class="prosjekt_content">
<%= project.content %>
</p>
<% if user_signed_in? %>
<%= link_to 'Slett', project, method: :delete, data: { confirm: 'Er du sikker?' } %>
<% end %>
<%= image_tag(project.picture.url, class: "img-responsive project_image") %>
</div>

How to place a text to the right

I'd like to place the text "även uppfinnare" to the right like in this mockup:
I can display everything except the text farthest to the right when this is the actual result with dynamic data:
The HTML and JSP that does this is:
<div class="clear"></div>
<div class="fl10"><h3>Sökande</h3></div>
<% if(apc.hasSokande()) {
if(sokandeList != null && sokandeList.size() > 0) { %>
<% for(PersonInfo person : sokandeList) { %>
<div class="data-box">
<table border="0">
<tr><td colspan=3><strong> <% if (person.getNamn() != null) { %>
<%= person.getNamn() %>
<% } %> </strong></td></tr>
<tr><td></td><td>Telefon</td><td><%= person.getTelefon() %></td></tr>
<tr><td></td><td>Fax</td><td><%= person.getFax() %></td></tr>
<tr><td></td><td>E-post</td><td><%= person.getEpost() %></td></tr>
<tr><td><%= person.getLandKod() %></td><td>Referens</td><td></td></tr>
</table>
</div>
</div>
<div class="clear"></div>
<div class="fl10"></div>
<% } %>
<% } %>
<% } else { %>
<%= apc.getNyregPerson().getNamn() %>
<% } %>
</div>
Can you please tell me how I can achieve the text on the right? I tried with a div and float:right but it didn't work. Please help. Thank you.
Using HTML div tag would be more suitable for such design. Create two divs for columns.
<div id="personName">
......
</div>
<div id="otherDetails">
.....
</div>
<br style="clear:both;"/>
CSS:
#personName {
float:left;
width:300px;
background:#9c9;
}
#otherDetails {
float:right;
width:450px;
background:#c9c;
}
Check : example
You can use absolute positioning like this one.
<span style='position:absolute; top:10px; right:0px;'>även uppfinnare</span>