Gmaps4rails Map fixed to top - ruby-on-rails

Hello guys and merry Xmas to all of you :)
I am currently using gmaps4rails to display a map with all my user locations. Now I'd like to fix it to the top directly under my fixed-top navbar. I've tried a lot of css code but still don't get the output I want. ( I am using twitter bootstrap)
Any ideas or code examples how to override the gmaps4rails css to fix it? Would be even nicer if the map is responsive too.
Thanks :)

If your navbar is 50px:
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding-top: 50px }
#map { height: 100% }
</style>

Related

Why is my position:sticky not working on iOS?

I'm in the process of coding a sticky notification bar seated at the bottom of a mobile screen. I want the bar to be stuck at the bottom of the users screen until the user has reached the scroll position of where the bar is actually positioned in the code (which is just before the footer of the page).
I have pretty much copied the "doctor" example from this page: https://alligator.io/css/position-sticky/
My problem is: On my page, the bar works fine when using Android Devices or when simulating a mobile device by adjusting the Browser width on my Desktop Computer. However, on iOS, the bar is not sticky, i.e. it just sits at its position and doesn't stick to the bottom of the screen until reached. This applies to both Safari and Google Chrome.
The weird thing is: On the previously mentioned alligator.io page, it works just fine on my iOS device.
I suspect this is some kind of Webkit problem having to do with the code surrounding the bar, but I cannot isolate it. I have tried debugging by adjusting my code as far as possible to the example from alligator.io, but I cannot get it to work. I have also tried looking for any overflow:auto in parent elements - without success. I have been trying to fix this for several hours and am sick and tired of the problem and could use another pair of eyes to help me find what I'm overlooking.
#jobalarm_mobile {
display: table;
font-size: 18px;
width: 100%;
height: 40px;
background: #ff8400;
color: white;
font-weight: 400;
text-align: center;
position: -webkit-sticky;
position: sticky;
bottom: -50px;
align-self: flex-end;
}
<a href="#" class="jobAlertToggle">
<div id="jobalarm_mobile">
<i class="fa fa-bell"></i>
<span>Jobalarm aktivieren</span>
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
</div>
</a>
You can visit the live page I am working on at (hidden on request of the customer, please contact me privately).
Simply start any (suggested) search and the bar will pop up (or not, if you are using iOS...)
Thanks in advance for your help.
I feel like an idiot for answering my own question, but I figured out what is causing the problem.
I hope this will help developers facing the same problem because I could not find anywhere defining this behavior.
As you can see, in my code, there is a wrapper (specifically a link) around the element, on which I use my position:sticky:
<a href="#" class="jobAlertToggle">
<div id="jobalarm_mobile">
<i class="fa fa-bell"></i>
<span>Jobalarm aktivieren</span>
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
</div>
</a>
For some reason, this is not a problem for Chrome or Firefox on Desktop as well as Android, as they seem to ignore this container, probably because it doesn't define any positioning behavior. This is why it works on other devices. However, iOS does not ignore the container and therefor positions the div relative to its parent container, which is the link. After removing the link for test purposes, it worked on all devices.
This is the real answer
position: -webkit-sticky;
position: -moz-sticky;
position: -o-sticky;
position: -ms-sticky;
position: sticky;
and works!!!
Some of the tips in my answer here may help, notably adding display: block to your container may do the trick.
For me nothing worked except jQuery/javascript in this way: give the element you need to be sticky position:absolute and left: 0, then use javascript to calculate offset of the window to the left, and add that offset to the left property of your element:
#stickyElement {
position: absolute;
left: 0;
}
function scrolling(){
$('.someElementScrollingLeft').on('scroll', function() {
let offset = $(this).scrollLeft();
/* For me it only didn't work on phones, so checking screen size */
if($( window ).width() <= 768)
{
let stickyElement = $('#stickyElement');
stickyElement.css("left", offset);
}
});
}
In my case in full screen menu it was overflow-y: auto. I eliminated this issue by adding: overscroll-behavior: contain.
I visited a website and may be I found solution for you.
Try this it may can help you:
#jobalarm_mobile {
display: none !important;
}
and then place your notification <a> tag at the end (after <footer> tag)
//write this css
.jobAlertToggle{
display: none;
}
#media (max-width: 767px)
.jobAlertToggle{
display: block;
width: 100%;
position:sticky;
position:-webkit-sticky;
bottom:-50px;
}
#jobalarm_mobile {
display: table;
font-size: 18px;
width: 100%;
height: 40px;
background: #ff8400;
color: white;
font-weight: 400;
text-align: center;
-webkit-align-self: flex-end;
align-self: flex-end;
}
For my problem it was:
I had { contain: paint; } in ancestor (container above inside-container).
Changed it to { overflow: clip; }
Sticky would not work if contain: paint was present regardless of having overflow: clip.
This was tested on Iphone 15.4.1. Other tested devices didn't break with contain: paint (tested on chrome, ipad, android)
I had so many problems with this issue as well. The sticky position wouldn't work on my phone - not in Safari or Chrome.
I tried placing the element that I wanted sticky in the top of the surrounding wrapper - it worked! Apparently the sticky position can't really work if there is something above it inside the same parent-wrapper. You don't have to change your order or design, you can just create a wrapper that's around the content, with the sticky element in the top.
<div class="container">
<p>Some text above the sticky element</p>
<div class="inside-container">
<div class="sticky-element">
<p>This is sticky</p>
</div>
<p>Some more text, that scrolls past the sticky element.</p>
</div>
</div>
I think the Problem is, that Safari (the Browser of iOS) does not support position: sticky properly. See this Article (https://caniuse.com/#feat=css-sticky). Read the Known Issues Section to find aut more. Maybe, you have to deactivate it for iOS and show a note on your Page, that its not working properly.
I hope, I could help you.
Use for ios position: -webkit-sticky and for other case position: sticky

iphone 5 responsive fixed navbar glitch?

I am trying to finish my first website and thought it was pretty much finished but am having an issue with viewing some page layouts on an iPhone 5 (S and C). On my 4 it's fine and on an iPad I tested it on. Also fine on Android.
The issue is the fixed navbar (bootstrap) is bouncing around on the galley pages (it's a photography site) which have a horizontal scrolling div but it's ok on standard page layouts. I have disabled a mouse wheel plugin it's running to check if it's that and it has no effect on the iPhone 5 issue. Normal layout pages are fine.
the url is: http://www.pjrundle.co.uk
The problem occurs on any of the photography pages.
Sorry if this is a really obvious newbie question. Here is the css for the div containing the side scrolling gallery. I tried removing absolute positioning and no effect.
.scroll {
white-space: nowrap;
background-color: white;
padding-top: 73px;
position: absolute;
left: 0px;
}
Any advice greatly appreciated.
Thanks.
Thanks mijopabe, I fixed it in the end by adding:
.scroll {
white-space: nowrap;
background-color: white;
padding-top: 73px;
position: absolute;
left: 0px;
width: 100%;
overflow: auto;
}
Not really sure why it worked without this on other browsers to be honest but fixed anyway.
Cheers.

Issue using Gmaps.js in site with twitter bootstrap. Zoom buttons not appearing

I'm using gmaps.js to create map in a site based on twitter bootstrap and the google maps zoom in/ zoom out buttons don't appear. Also I noticed when you click the marker the 'x' close button doesn't appear. Here is the link to the page.
http://www.smileconnectcard.co.uk/FindPractice/SearchResults?location=London%2C%20UK
Any help would be much appreciated.
There is an issue with Bootstrap that conflicts with google maps api. The issue applies max-width:100% to all images. This is acceptable in most cases, but it causes a conflict with google api.
There have been various attempts to fix this and various reverts by the bootstrap developers - https://github.com/twbs/bootstrap/issues/1552.
To fix this so that it only affects the google map I would recomend using the following css
#map label { width: auto; display:inline; }
#map img { max-width: none; }
On inspecting, img tag has max-width: 100%
So try this, it is working.
img {
max-width: none;
}
Maybe happened due to CSS Conflict.
Update: As I suspected, it is a CSS Conflict.
it happened because of your layout.css
img {
max-width:100%; // change it here
}

parallax scrolling | let image fly in when you scroll

there are many website that have the "parallax" scrolling effect. But I would like to start simple by letting various images fly in as I am scrolling down.
A simple illustration:
The image will actually fly in as the user is scrolling (start flying in on visible, on scroll), but I'm okay if the image fly's in directly when the image is visible to the user (trigger fly in on visible)
How can this be accomplished? Are there any demo's, library's, tutorails etc. available? Is there a specific name for this?
There are a lot of great parallax tools available. If you are looking for tutorials, my company and I list some at http://potentpages.com/parallax-tutorials/
Some of the main methods used to create parallax websites are:
Javascript (without any libraries)
jQuery (and libraries that go on top of jQuery like Stellar.js)
Skrollr.js
Jarallax
CSS (without any javascript)
My company also created a quick and simple tutorial on how to create a parallax tutorial with javascript (no extra libraries needed) at http://potentpages.com/parallax-scroll-tutorial/
I hope this helps.
html:
<body>
<div id="section1"><h1>section1</h1></div>
<div id="section2"><h1>section2</h1></div>
<div id="section3"><h1>section3</h1></div>
</body>
css:
*{ margin: 0; padding: 0;}
#section1{ width: 100%; height: 650px; background: url("http://www.wallsave.com/wallpapers/1280x960/abstact-red/186157/abstact-red-abstract-balls-186157.jpg");}
#section2{ width: 100%; height: 650px; background: url("http://wallpaper-fun.ophibian.com/wallpapers/wallpaper_08.jpg");}
#section3{ width: 100%; height: 650px; background: url("http://wonderfulengineering.com/wp-content/uploads/2014/01/Technology-Wallpaper-6.jpg");}
h1{ color: chartreuse; text-align: center; line-height: 650px;}
#section2 h1{ color: #fff;}
js:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$( window ).scroll(function() {
var val = $(window).scrollTop();
$("#val").text(val);
$("#section1").css({"background-position":"-"+val*2+"px 50%"});
$("#section2").css({"background-position":"50% -"+val*2+"px"});
$("#section3").css({"background-position":val*2+"px 50%"}); });
</script>
follow this way to help you to create and understand about parallax website
http://learning-day.blogspot.in/2014/04/how-to-create-own-parallax-website.html
Take a look at this tutorial: http://blog.themeforest.net/tutorials/create-a-funky-parallax-background-effect-using-jquery/
I prefer to use lazyload for your problem, so the image will be loaded when it reaches the viewport.
Add an eventlistener for page scrolling and when one of these object become visible, animate them. This can be implemented with jQuery like this:
$(window).scroll(function(){
var scrollTop = $(this).scrollTop();
$('.flyIns').each(function(i, element){
if($(element).offset().top < scrollTop + 400){
$(element).animate({left:'50px'}, 300);
}
});
});
I would recommend you having a look at Skrollr.js. It has a very good documentation and your effect can be accomplished with Skrollr.js very easily.
Have a look at these two tutorials to help you get started:
Simple parallax scrolling tutorial
How to create a parallax scrolling website

iframe size with CSS on iOS

There's an iframe, which basically has more content than fits into the frame. The sizing of the frame is based on the browser screen size and lets the overflow scroll, which works perfectly on all browsers, except for iOS. On iOS, safari decides to resize the frame to fit the content. Not what you'd expect.
Example code on jsFiddle:
http://jsfiddle.net/R3PKB/2/
Try it out on your iOS devices:
http://jsfiddle.net/R3PKB/2/embedded/result
The HTML:
<div class="frame_holder">
<iframe class="my_frame">
// The content
</iframe>
</div>
The CSS:
body {
position: relative;
background: #f0f0f0;
}
.frame_holder {
position: absolute;
top: 50px;
bottom: 50px;
left: 50px;
right: 50px;
background: #ffffff;
}
.my_frame {
width: 100%;
height: 100%;
border: 1px solid #e0e0e0;
}
You can make it work by adding a wrapping div with overflow: auto; and -webkit-overflow-scrolling:touch;.
Here's your example with it: http://jsfiddle.net/R3PKB/7/
According to previous questions on SO it's a bug since iOS 4. I found more info here:
https://stackoverflow.com/a/6721310/1047398
iframe on iOS (iPad) content cropping issue
This is an old question, but since it comes first on google and the issue exists on nowadays ios devices, I repost a better fix that I found on this page:
How to get an IFrame to be responsive in iOS Safari?
Basically, if you have an iframe with scroll (let's say a twitter widget), the solution above won't work very well because it makes the parent scrollable. The fix that worked for me is replacing height: 100% with height: 1px; min-height: 100%;.
If iOS Safari is displaying your iframe content from a different origin than expected (i.e. it is shifted over by some pixels), try adding scrolling="no" as an attribute to the iframe. This should prevent it from automatically fitting its content.
More here.
using height: 1px; min-height: 100%; did not work for me, though I did not need a scrolling element. I had to use the overflow:auto; on a surrounding div instead. Note that this method is discouraged as it may have unintended consequences, but I tested on Android/iOS and desktop browsers and could not find any issues yet. fingers crossed.
This is a nice post from Andy Shora on some iOS iframe nuances: http://andyshora.com/iframes-responsive-web-apps-tips.html

Resources