How to change logo of a sticky menu when scroll up by CSS? - css

Here's my website http://tapash.atwebpages.com/
As you can see my logo is white and it becomes invisible when scrolled up. How can I specify a logo by CSS when scroll up the page and menu becomes sticky? I have another color logo which I would like to put there. Thanks

I have seen that you already use jQuery on your website. This makes it very easy to implement.
Give your image an ID for JavaScript:
<img src="LOGO_WHITE" id="test" />
Execute a function on scrolling:
$(window).scroll(function (event) {
...
});
When scrolling (your header turns white), a different image should be set:
$("#test").attr("src", "LOGO_BLACK");
But now the problem is that the logo is permanently black. You have to set the white logo again when the user scrolls at the top:
if($(window).scrollTop() <= 0) {
$("#test").attr("src", "LOGO_WHITE");
}
Your function should therefore look like this:
$(window).scroll(function (event) {
if($(window).scrollTop() <= 0) {
$("#test").attr("src", "LOGO_WHITE");
} else {
$("#test").attr("src", "LOGO_BLACK");
}
});
Example on JSFiddle: https://jsfiddle.net/18v9d5eq/1/
It looks like you're using a template from Drupal. If you are not familiar with web technologies, my solution above is the easiest. The cleanest solution would be to include both images (white and black) in the header and then just set the visibility with display: hide/block.

Related

Header rearrange/change on scrolling

I've looked everywhere on how to do this particular thing. But I'm attempting to create a header like on: http://pinkpeonies.com/. Where the logo moves over, and the navigation floats right when the user scrolls far enough down. I can't seem to find how to do it. How would I create a header like this? What would be the best way?
$(window).on("scroll", function () {
if ($(this).scrollTop() > 100) {
$("#header").addClass("scroll-down");
}
else {
$("#header").removeClass("scroll");
}
});
and you can style scroll-down class in css

Shrinking Bootstrap Navbar with logo on scroll

I need the fixed navbar to shrink 50% when it starts scrolling.
I have seen just text navbars, but nothing with a logo. Any help would be much appreciated.
http://carpetliquidators.com/demo/
You can pull the css and html from there.
This can be accomplished by using jQuery and a custom CSS class, like so:
$(window).scroll(function() {
if ($(document).scrollTop() > 150) {
$('.navbar').addClass('shrink');
}
else {
$('.navbar').removeClass('shrink');
}
});

custom-made lightbox cannot cover several parts of page

I try to make a lightbox of my own.
I use a div to cover the web page and display in that div the images, buttons etc.
This div has a semi-transparent background image to "dim" everything.
The problem is that three things cannot be dimed. (they overlap the image)
-An openlayers map (inside html5's article)
-An html5 video tag
-An html5 details tag
This happens cross-browser.
Any ideas? Has to do with html5? The place/order the tags have in the DOM or something?
Thanks in advance
EDIT
Here is the code. Hope it helps. Comes from a 2200 lines file, so its edited. Ask me if you want more specifications
<script type='text/javascript'>
//create image element to later append to lightbox div
var elem2 = document.createElement("img");
//open layers - set map...
map = new OpenLayers.Map('map_element', options);
//more openlayers things here
//image takes its source from an array came form a query
elem2.src=mpli[0];
//then, append to the light box div
document.getElementById("lightbox").appendChild(elem2);
//functions for hide/show the lightbox div
function lightboxme(){
document.getElementById("lightbox").style.display="block";
}
function unlightboxme(){
document.getElementById("lightbox").style.display="none";
}
</script>
//map's article
<article id='map_element' style='width: 900px; height: 400px;'>
</article>
//the small div that contains the image gallery - when clicked , shows the lightbox
<div id="smallbox" onClick="lightboxme();" ></div>
//the lightbox's div
<div id="lightbox" style="display:none ;" >
//lightbox's css
#lightbox {
position:fixed; /* keeps the lightbox window in the current viewport */
top:0;
left:0;
width:100%;
height:100%;
background:url(semi-transparent.gif) repeat;
text-align:center;
}

Sharepoint 2013 - Hide left Navigation, but not in People and Groups

I tried to hide the left Navigation bar and it works without problems. The only problem now is that when I go under: Site settings > User Permissions > People and Groups
It hides me my Groups I created there on the left side. Is there any possibility of hiding the left navigation bar in all sites and leaving "People and Groups" alone?
I made my own css file and used this to hide the Navigation bar:
MyOwnCss.css:
#sideNavBox { DISPLAY: none }
#contentBox { margin-left: 0px }
Best regards
Andrew
Solution:
Try below css (instead of yours):
.ms-core-sideNavBox-removeLeftMargin { display: none } /* hide only quick links */
#contentBox { margin-left: 0px } /* make content take full page width */
Explaination:
Div with id sideNavBox is the main container of left navigation box. But it is not the actual container that holds the quick links.
Actually quick links is contained by another div with class ms-core-sideNavBox-removeLeftMargin which is a child div of div with id sideNavBox.
Now people and groups left panel items are not contained in this div with class ms-core-sideNavBox-removeLeftMargin but is instead contained in div above it with class ms-ql-additionaltopsection (as shown in above image).
So our solution above hides this actual quicklinks containing child div:
.ms-core-sideNavBox-removeLeftMargin { display: none } /* hide only quick links */
instead of parent container
#sideNavBox { display: none } /* hide left navigation box */
You can find my detailed blog on this matter here.
If you wish to remove the sidenavbox only in special cases then you should do the following:
1. Edit the Relevant master page in SharePoint designer (in my example below I edited the System Master Page.
Below example checks for form pages and removes the sidenavbox only there.
2. Add the following script (jQuery):
Code:
<script>
$(document).ready(function () {
if(window.location.href.indexOf("newifs.aspx") > -1) {
$('#sideNavBox').css('display', 'none');
$('#contentBox').css('margin-right', '0px');
}
if(window.location.href.indexOf("editifs.aspx") > -1) {
$('#sideNavBox').css('display', 'none');
$('#contentBox').css('margin-right', '0px');
}
if(window.location.href.indexOf("displayifs.aspx") > -1) {
$('#sideNavBox').css('display', 'none');
$('#contentBox').css('margin-right', '0px');
}
})
</script>
3. Save and check-in the Master Page.
Now, you will not need to edit every page containing a form to add content webparts and such. This will work on all pages specified in the script.

Like Button Width Not Working - Causes Browser Horizontal Scrolling

I have two instances of where the Like Button is not "listening" to the width I specify in the XFBML code.
It LOOKS fine, but something is mysteriously causing the like button to be extra wide and force the browser to do horizontal page scrolling even though the entire like button is within the page.
Example:
[EXAMPLE REMOVED] - see the sidebar. I have to set the entire BODY to ignore overflow-x. If not, the like button causes a ton of extra pixels out there (but I can't see them with Firebug). I know this is the problem because if I remove it, then it looks fine.
Example 2:
Screenshot of Example - In the header, I had to move the margin over so far to the left, and I wanted it to be in the top-right corner. Play with the CSS for fbheader in firebug and you'll see.
The code I'm using there:
<div class="fbheader">
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: 'your app id', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
<fb:like href="http://www.example.com" send="true" width="300" show_faces="false" font="arial" colorscheme="dark"></fb:like>
</div> <!--// End fbheader -->
Any ideas why this is happening?? Can anyone help? It seems like a bug with the XFBML.
I had the same problem, but none of the suggestions above worked for me.
I found another solutions that did work, see http://britishinside.com/archive/2011/07/07/Facebook-Like-Button-Bug.aspx
Simply include this in your stylesheet:
#fb-root > div { left:0 }
It's a bug with facebook. Why don't you just update your fbheader class as follows:
.fbheader {
overflow:hidden;
}
That should solve your issue ..
Good luck..
I had the same problem. I found the problem was to do with a bug in Facebook's reset div. I fixed it like this:
#fb_like .fb_reset {
/* fix for Facebook bug which causes horizontal scrollbars in browser */
display: none;
}
I fixed the issue using #fb-root { display: none; }
You could try alter the width of fbheader class in css file, or even better, the parent element.
Sometimes when we use internal elements that cause the parent to get wider, the horizontal scroll get visible.
Another tip is to reposition the button, or set the margins and padding narrow.
My solution is to apply this to the parent container:
.my-parent-wrapper {
display: inline-block;
overflow: hidden;
}
skipping overflow rule will work too
I've just had the same problem, using an iFrame script from facebook for a double "share" and "like" button. I hadn't specified a width in pixels. Fixed it by getting a replacement script, but this type specifying a width of 120 pixels in the box provided.

Resources