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;
}
Related
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.)
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>
I'm using jQueryUI Tabs and have a requirement to add UI elements to each tab that allow a user to Edit information about the tab, or remove the tab.
The markup I use on the <li> for a given tab looks like this:
<li>
<div style="background-color:Red;"> <-- Red to see what's happening -->
<span>Tab One</span>
<div style="text-align:right; margin-right:3px;">
<div><span id="editTab-1">edit</span></div>
<div><span id="delTab-1">X</span></div>
</div>
</div>
</li>
This renders just as I would hope in IE
______________________________
| Edit|
| Tab One |
|___________________________X__|
but it does not render properly in Chrome or FireFox (the tab is only wide enough for the "Tab One" text, and "Edit" / "X" are mostly "under" the tab (lower Z-Index apparently).
What is a compatible way to achieve my goal?
I'm not sure if this is what you were intending or not, as I haven't tested in IE, but this works in Chrome and FF:
<div id="tabs">
<ul style="cursor:pointer">
<li>
<a href="#tabs-1">
<div style="float: left; margin-right: 20px;">Tab One</div>
<div style="float: right; text-align:right;">
<div id="editTab-1">edit</div>
<div id="delTab-1">X</div>
</div>
</a>
</li>
<li>
<a href="#tabs-2">
<div style="float: left; margin-right: 20px;">Tab Two</div>
<div style="float: right; text-align:right;">
<div id="editTab-2">edit</div>
<div id="delTab-2">X</div>
</div>
</a>
</li>
</ul>
<div id="tabs-1" class="tabPane">Tab One Content</div>
<div id="tabs-2" class="tabPane">Tab Two Content</div>
</div>
See the working jsFiddle
If you want to handle the clicks dynamically, you could use:
var $tabs = $("#tabs").tabs();
$tabs.find("a div[id]").on("click", function() {
var id = $(this).attr("id"),
idTab = parseInt(id.substring(id.length - 1)),
isEdit = id.indexOf("edit") > -1,
isDelete = id.indexOf("del") > -1,
index = $tabs.tabs('option', 'selected');
if (index + 1 === idTab) {
if (isEdit) {
console.log("Edit Tab " + (index+1));
//however you want to edit here
}
if (isDelete) {
console.log("Delete Tab " + (index+1));
$tabs.tabs("remove", index);
}
}
}).css("cursor", "pointer");
See the working jsFiddle
The problem, I think, stems from the fact that the tab <li> and then the <a> inside are floating elements, as designed in the jQueryUI CSS.
The technical part can best be summed up with this quote (from http://css.maxdesign.com.au/floatutorial/introduction.htm)
If no width is set, the results can be unpredictable. Theoretically, a floated element with an undefined width should shrink to the widest element within it. This could be a word, a sentence or even a single character - and results can vary from browser to browser.
So the red <div> is shrinking to the widest element - the <a>. IE and Firefox/Chrome are simply behaving differently, just their interpretation of the specifications. To be honest, that fact that Firefox and Chrome are similar and IE has had a long history of float bugs I'd side with Mozilla/Google here although can appreciate that IE seems to be behaving nicer in this instance.
You can solve the problem by simply setting a width on the red <div>. However the markup could also be a bit cleaner, for example:
<li style="background-color:red;width:150px">
Tab One
<div id="editTab-1" style="text-align:right;margin-right:3px">edit
<p id="delTab-1">X</p>
</div>
</li>
gives the same result.
I am using a jquery accordion with just one content panel like so:
<ul id="myaccordion">
<li>
Header Title
<div>
Content in here.
</div>
</li>
</ul>
and then calling:
$('#myaccordion').accordion();
The problem I'm having is that the content part of the accrodion id the correct width, but the header is merely the width of the text that says 'Header Title' and this text is overlapping the arrow icon.
Can anyone see why the header wouldn't be the same width as my content? I have tried setting a specific with to the ul, the li and the a tags, but to no effect.
Many thanks in advance.
The accordion code expects a header around that anchor for styling (or any wrapper element really), since this styling here needs it:
.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
Just add a wrapper in there, like this:
<ul id="myaccordion">
<li>
<h3>Header Title</h3>
<div>
Content in here.
</div>
</li>
</ul>
Here's a demo showing both with and without the <h3>, so you can see the effect.
Okay so I am working on making a site for my previous boss who runs an animal control business. My index.html.erb consists of code like this:
<div id="bats"><img alt="Big brown bat" src="/images/bigbrown.png" style="position: relative; border: 0.25em outset;" />
<p class="text_center"><%= link_to #animals[0].name, animal_path(#animals[0]) %></p></div>
<div id="squirrel"><img alt="Grey Squirrel" src="/images/grey_squirrel.png" style="position: relative; border: 0.25em outset;" />
<p class="text_center"><%= link_to #animals[1].name, animal_path(#animals[1]) %></p></div>
<div id="flying"><img alt="Flying Squirrel" src="/images/flying-squirrel.png" style="position: relative; border: 0.25em outset;"/>
<p class="text_center"><%= link_to #animals[2].name, animal_path(#animals[2]) %></p></div>
<div id ="groundhog"><img alt="Groundhog" src="/images/groundhog.png" style="position: relative; border: 0.25em outset;" />
<p class="text_center"><%= link_to #animals[3].name, animal_path(#animals[3]) %></p></div>
The pages are mostly static with a lot of text, so I guess my two questions are, should I even have the animals in a database (which just consists of their name)?
And if I do keep them in a database, how should I format my show.html.erb which is going to go into greater detail about the animal selected from my index.html.erb page? Use if, else if, etc... or make a page specific to each animal and just redirect there when the animal is selected?
Thanks in advance!
If I were to redo your example page, I'd add a short_description, long_description, and image_url for each animal in the database and do something like this:
<% #animals.each do |animal| %>
<div id="animal_<%= animal.id %>"><img alt="<%= animal.short_description %>" src="<%= animal.image_url %>" style="position: relative; border: 0.25em outset;" />
<p class="text_center"><%= link_to animal.name, animal_path(animal) %></p></div>
<% end %>
to generate it.
The long_description would be to give more detail. If there is enough information to fill a page about each animal, I would use a separate show page.