Bootstrap Carousel Disables Navigation Bar After Transition - ruby-on-rails

I'm using the bootstrap 4 carousel in rails 5 as a background of my site. I have a navigation bar with pills, which links to different parts of the page. Everything works when the page loads until the first image transitions to the next one. Then the pills on the navigation bar disappear and when I click the links they don't navigate to the specific part of the page that it should.
I think this might be due to the fact that when the image transitions it transitions not just the background image, but the whole content too (even though the content remains the same), and it's still linking to the initial page's content. (And so it can't seem to re-link to the "new" content.)
Here is my code:
index.html.erb
<% image_array = [] %> <!--Array of image paths, i.e. [image_path(''), image_path('')]-->
<% #images.each do |image| %>
<% image.slice! 'app/assets/images/' %>
<% image_array.push(image_path(image)) %>
<% end %>
<div id="carousel-images" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active" style="background: url(<%= image_path image_array[0] %>)
no-repeat center center fixed;
background-position: 50% 0;
height: 100%;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;">
<div class="transparent"></div>
<%= render 'content' %>
</div>
<% image_array.delete_at(0) %>
<% image_array.each do |image| %>
<div class="carousel-item" style="background: url(<%= image_path image %>)
no-repeat center center fixed;
background-position: 50% 0;
height: 100%;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;">
<div class="transparent"></div>
<%= render 'content' %>
</div>
<% end %>
</div>
</div>
welcome_controller.rb
class WelcomeController < ApplicationController
def index
#images = Dir.glob("app/assets/images/*")
end
end
_navigationbar.html.erb (rendered from application.html.erb, not shown)
<nav class="navbar navbar-fixed-top navbar-dark bg-inverse">
<!-- Brand -->
<!-- <a class="navbar-brand" href="#">League Builders</a>-->
<!-- Links -->
<div id="myNavbar">
<button class="navbar-toggler hidden-lg-up" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"></button>
<div class="collapse navbar-toggleable-md" id="navbarResponsive">
<ul class="nav nav-pills navbar-nav" id="nav-colors">
<li class="nav-item"><a class="nav-link" href="#home"><b>League</b><i>Builders</i></a></li>
<li class="nav-item"><a class="nav-link" href="#about">About</a></li>
<li class="nav-item"><a class="nav-link" href="#features">Features</a></li>
<li class="nav-item"><a class="nav-link" href="#contact">Contact Us</a></li>
</ul>
</div>
</div>
</nav>

I figured out that it was because I had the content inside of the carousel part, such that it was rendering the content every time. I took out the content, but when I did that the background didn't show up. It seems that the 100% cover of the background applies to the content that it would contain, so I just adjusted the background image to a specific pixel height so that it would fill the whole screen. (This was a tedious method and I'm not sure if there is a better way, but this worked after playing around with it.)

Related

How to left -align navbar-text?

I am attempting to build a small page with BS4 (beta2).
<nav id="TOP" class="navbar navbar-light">
<span id="banner-logo" class="navbar-brand">
<span class="fa fa-bath fa-5x"></span>
</span>
<span id="banner-heading" class="navbar-text"><h1>
Wonderful page-title
</h1>
</span>
</nav>
(There also is a fiddle here)
Somehow I am missing something in the construction of the nav: I'd like to the #banner-heading-element to be left-aligned, next to the icon. Why is that not working?
EDIT: I noticed that it works if I put the nav into a - but the BS-Examples all do not do that, so something else must be wrong...
I haven't work much with bootstrap 4 beta before but I don't believe you are doing it right, just took a quick look at the documentation here,
Navbar are formatted like:
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">
<span class="fa fa-bath fa-3x"></span>
Wonderful page-title
</a>
</nav>
And you can but your menu and content in a container.
<div class="container">
<div class="row">
<div class="col-md-3">
My little menu
</div>
<div class="col-md-9">
Main content area, 9 cols wide
</div>
</div>
</div>
See fiddle
EDIT
To #Mbaas's comment, if you want the icon to be the link and not the text, use li and put the anchor tags around the icon.
<nav class="navbar navbar-light bg-light">
<li class="navbar-brand">
<a href="#">
<span class="fa fa-bath fa-3x"></span>
</a>
Wonderful page-title
</li>
</nav>
You can remove the underline hover of the link by applying css like:
.navbar-brand a{
text-decoration: none;
}
To make the text large as a h1 tag you can put it in a span with a class and apply css to it like:
<span class="bold-text">
Wonderful page-title
</span>
And the css for bold-text could be something like:
.bold-text{
font-weight:bold;
font-size: 40px;
}
fiddle

Materializecss - Always show tooltips with action button

I am using Materializecss for my website and I'd like to display tooltips on the smaller action buttons whenever the user presses the big action button. Materializecss shows tooltips only on hover by default.
Is there a way to change this?
Thank you
<li> <!-- Small button -->
<a class="btn-floating green tooltipped" data-position="left" data-delay="50" data-tooltip="Add friends">
<i class="material-icons">add</i>
</a>
</li>
Check out this github issue
Github user philipraets created a nice codepen to demonstrate his soluton.
Edit (For the Lazy):
philipraets created a simple css style:
.mobile-fab-tip {
position: fixed;
right: 85px;
padding:0px 0.5rem;
text-align: right;
background-color: #323232;
border-radius: 2px;
color: #FFF;
width:auto;
}
then wrapped the tooltip within another link element using that style:
<div class="fixed-action-btn click-to-toggle" style="bottom:24px; right:24px;">
<a class="btn-floating btn-large red"><i class="large material-icons">settings</i></a>
<ul>
<li>
<i class="material-icons">create</i>
Edit <!--tooltip-->
</li>
<li>
<i class="material-icons">event</i>
Save to calendar <!--tooltip-->
</li>
<li>
<i class="material-icons">supervisor_account</i>
Switch responsible <!--tooltip-->
</li>
</ul>
</div>

Put small icon inside listview JQuery Mobile

Seems I can't put the icon correctly, can someone help me out?
JQuery Mobile version: 1.4.2
<div data-role="page" id="pageone">
<div data-role="main" class="ui-content">
<h2>List With Thumbnails and Text</h2>
<ul data-role="listview" data-inset="true">
<li>
<a href="#">
<img src="chrome.png">
<h2>Google Chrome</h2>
<p><img class='ui-icon-home ui-btn-icon-notext ui-btn-icon-left'/> Google Chrome is a free, open-source web browser. Released in 2008.</p>
</a>
</li>
<li>
<a href="#">
<img src="firefox.png">
<h2>Mozilla Firefox</h2>
<p>Firefox is a web browser from Mozilla. Released in 2004.</p>
</a>
</li>
</ul>
</div>
</div>
Result:
I try to use this but doesn't work.
<span><i class='ui-icon-home ui-btn-icon-notext ui-btn-icon-left'>Text</i></span>
If you want the icon inline with the text and not a button, you can accomplish it like this.
First add a span for the icon with class="ui-icon-home ui-btn-icon-notext inlineIcon":
<p>
<span class="ui-icon-home ui-btn-icon-notext inlineIcon"></span>
Google Chrome is a free, open-source web browser. Released in 2008.
</p>
Then we add the folowing CSS:
li p {
line-height: 24px;
}
.inlineIcon {
display: inline-block;
position: relative;
vertical-align: middle;
margin-right: 6px;
}
The P line-height makes room vertically for the icon, while the inlineIcon class places the icon correctly.
If you do not want the gray disk and would prefer a plain black version of the icon, you would add the ui-alt-icon class to the span to make it black, and the CSS would be:
.inlineIconNoDisk {
display: inline-block;
position: relative;
vertical-align: middle;
margin-right: 6px;
}
.inlineIconNoDisk:after {
background-color: transparent;
}
Here is a DEMO
And a screenshot:
Try this code it will work
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<div data-role="page" id="pageone">
<div data-role="main" class="ui-content">
<h2>List With Thumbnails and Text</h2>
<ul data-role="listview" data-inset="true">
<li>
<a href="#">
<img src="chrome.png"/>
<h2>Google Chrome</h2>
<div class="ui-grid-a">
<div class="ui-block-a" style="width:30%;"><button data-icon='home' data-iconpos="notext"></button></div>
<div class="ui-block-b" style="width:70%;"> <p>Google Chrome is a free, open-source web browser. Released in 2008.</p></div></div>
</a>
</li>
<li>
<a href="#">
<img src="firefox.png"/>
<h2>Mozilla Firefox</h2>
<div class="ui-grid-a">
<div class="ui-block-a" style="width:30%"><button data-icon='home' data-iconpos="notext"></button></div>
<div class="ui-block-b" style="width:70%;padding-bottom:5%;"> <p>Firefox is a web browser from Mozilla. Released in 2004.</p></div>
</div>
</a>
</li>
</ul>
</div>
</div>
Refer this Fiddle Demo

Foundation Navigation Bar blocking form fields

So this seems like a dumb problem to have. I may be going about it wrong so if anyone could suggest another way of doing this i would love to try it out.
I have a FIXED Navigation bar built with Zurb Foundation 4
<div class="fixed">
<nav class= "top-bar">
<ul class="title-area">
<li>
<h2><%= link_to image_tag("officialLogo-100x197.png", :size => "100x197", :class => "logo" ) + "AppDomum", root_path, :class => "textlogo" %></h2>
</li>
<li class="toggle-topbar menu-icon"><span>Menu</span></li>
</ul>
<section class="top-bar-section">
<ul class="right">
#links .....
</ul>
The image that is displayed for the title is larger than the navigation bar. I actually like it hanging down from the nav bar and i have a media query setup to remove it on smaller screens so it is not hanging over content.
Problem: The <div class= "fixed"> wraps the navigation bar and the image all the way across the page. Because the image hangs below the nav bar anything behind it is not clickable. the entire top part of the page is unclickable. For a form i am unable to select a text box to edit. Because the navbar is fixed it affects the entire page depending on how far you have scrolled. Is there a way to have them fixed but without having the fixed tag grab all the empty space? Is there another way to do this?
Try adding position: relative; to your image.
I did Solve this after much research.
here is the code to solve the issue or at least what i hacked together to get what i want.
This is the navigation bar.
<div class="fixed">
<nav class= "top-bar">
<ul class="title-area">
<li>
<h2><%= link_to "AppDomum", root_path, :class => "textlogo" %></h2>
</li>
<li class="toggle-topbar menu-icon"><span>Menu</span></li>
</ul>
<section class="top-bar-section">
<ul class="right">
#links .....
</ul>
</section
</nav>
</div>
<div class= "fixed-icon">
<%=link_to image_tag("officialLogo-100x197.png", :size => "100x197", :class => "logo" ), root_path %>
</div>
I separated the icon and the Text but kept both of them as links to the home page. Giving the illusion that they are both part of the title. There is a media query that hides the image and removes the margin on the title.
And Here is the CSS. I basically searched around the html and css files of the site until i found the "fixed" class and stole the css modification and then changed the width to be small so it does not mask everything else.
#media only screen and (min-width: 768px) {
.title-area {
margin-left: 6em;
}
}
.fixed-icon {
#extend .hide-for-small;
width: 10%;
left: 0;
position: fixed;
top: 0;
z-index: 99;
}
.title-area {
padding: 5px 5px;
font-weight: bold;
letter-spacing: -1px;
}

JQM horizontal height auto-adjust (listview and buttons)

I'm using:
jquery-1.8.2 and jquery-mobile-1.2.0 (generated with all options checked)
Targeted devices are iPhone 4/4s/5 and iPad.
The current data-role="listview":
Test link
The current code:
<div data-role="page">
<div data-role="header" data-position="fixed">
<h1>Test</h1>
</div>
<div data-role="content">
<div class="content-primary">
<ul data-role="listview" data-split-icon="gear" data-split-theme="d">
<li><a href="index.html">
<img src="pics/paul_jones.jpg" />
<h3>First Element</h3>
<p>First</p>
</a></a>Test
</li>
<li><a href="index.html">
<img src="pics/ray_moore.jpg" />
<h3>Second Element</h3>
<p>Second</p>
</a>Test
</li>
<li><a href="index.html">
<img src="pics/lisa_wong.jpg" />
<h3>Third Element</h3>
<p>Third</p>
</a>Test
</li>
</ul>
</div>
</div>
</div>
</body>
</html>
</pre>
What is the best way to make each item auto-adjust its height to stretch to full screen vertically (I see that the framework handles very well horizontal stretching), so that each row is 33% of the screen in this case, and have the images resize accordingly? Obviously this would have to work when there are four or more items.
In my site main page I would instead like to have three or four "image buttons" that I styled this way.
<b>#button_id .ui-btn-inner</b>
background: url("../img/button_image.png") no-repeat rgba(0, 0, 0, 0.4);
background-size: 100% 100%;
fill the screen vertically autoresizing themselves.

Resources