What is the best way to create a floating sidebar similar to Envato's design?

I'm really impressed by the innovative floating panel on the left side of this website:

Although I'm not sure what it's called, I admire how clicking on the search button expands to a search page, and clicking on another icon displays what looks like its own separate page.

Is there a way for me to achieve something similar on my own website? Are there any tutorials available for implementing this feature using html5, JavaScript, or jQuery?

UPDATE: The responses I've received so far have only addressed creating the floating bar, but haven't covered how to click on a link within that floating bar to reveal an expanded window to the right.

Answer №1

<div id="float"></div>

#float{
    position:fixed;
    top:50px;
    left:0;
}

To see a demonstration, visit http://jsfiddle.net/TVwAv/

Answer №2

styled with CSS,

HTML

<div id="floating_container">
  insert any content here
</div>

CSS

#floating_container {
 position:fixed;
 left: 0;
 top: 80px; /* adjust to change distance from the top of the page */
}

Answer №3


I am currently implementing a "floating (sticky) menu" feature for my website. Here are the modifications I have made:

1. To prevent the 'footer' from always getting pushed down when the sidebar is taller, I only enable scrolling when necessary - which means when the content surpasses the height of the sidebar.
2. The default animation effect felt a bit too abrupt for me, so I decided to tweak the CSS directly using jQuery instead. By setting the animate time to 0, we achieve a smoother and quicker transition.
3. In this setup, the header's height is set at 100 pixels. Consider this as the threshold that triggers the scrolling behavior.

 $(window).scroll(function(){
    if ($('#sidebar').height() < $('#content').height())
    {
    if ($(this).scrollTop() > 90)
        $('#sidebar').css({"margin-top": ($(this).scrollTop()) - 100 });
        //$('#sidebar').animate({"marginTop": ($(this).scrollTop()) - 100 }, 0);
    else
        $('#sidebar').css({"margin-top": ($(this).scrollTop()) });
        //$('#sidebar').animate({"marginTop": ($(this).scrollTop()) }, 0);
    }
 });`

Answer №4

Feel free to utilize this helpful tip for your website...

Your designated HTML div can be found below:

<div id="scrolling_div">Insert your desired text here</div>

Implement the following JavaScript function accordingly:

$(window).scroll(function(){
    $('#scrolling_div').stop().animate({"marginTop": ($(this).scrollTop()) +10+ "px"}, "slow"});
});

To further enhance the design, you can apply CSS styles like so:

#scrolling_div {
 position:absolute;
 left: 0;
 top: 100px; 
}

Please note that this solution has not been tested, but it should work seamlessly.

Answer №5

This function may seem lengthy at first glance, but it actually operates using just three simple parameters: the positioning of your "floater", the designated "target" element that will float, and the "reference" element which sets the boundaries. It automatically handles top and bottom positions without the need for CSS styling.

function scrollFloater(marginTop, reference, target, fixWidth = false){

  var processScroll = function(){
    var from = reference.offset().top - marginTop;
    var to = reference.offset().top + reference.outerHeight() + marginTop - target.outerHeight();
    var scrollTop = $(this).scrollTop();
    var bottom = to - reference.offset().top + marginTop;

    if( fixWidth )
      target.css('width', target.width());

    if( scrollTop > from && scrollTop < to )
      target.css('position', 'fixed').css('top',marginTop);
    else if( scrollTop >= to )
      target.css('position', 'absolute').css('top', bottom);
    else
      target.css('position', '').css('top',marginTop);

  }

  $(window).scroll(function(){ processScroll(); });
  processScroll();

}

To implement this function, use the following example:

$(function() {
    scrollFloater(41, $('.box.auth.register'), $('.plans-floater'), true);
});

I trust this explanation will be beneficial to someone in need.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to center a div both vertically and horizontally when height is not specified?

Is it possible to center a div on a webpage without specifying a fixed height, so that the height adjusts dynamically based on the content? I am willing to consider JS/jQuery solutions with fallback options but would prefer a pure CSS approach. Currently, ...

Dropdown items and Hamburger icon are not collapsing or functioning properly even when they resize correctly

I've recently started learning web development using Bootstrap, and I'm facing an issue with the navbars. Specifically, the dropdown/collapse feature is not working as expected with the dropdown items and hamburger icon. I've attempted to i ...

Tips for altering the selected color of a checkbox?

I'm trying to change the color of my checked checkbox to green and also adjust the size, but for some reason, only the size is changing in my code. I even attempted using `:checked:after` without success. input[type='checkbox']{ width: 1 ...

Alignment issue with Ul dropdown menus and shadow

After stumbling upon a fascinating menu design at this link, I decided to tweak it for center alignment by following the advice on this forum thread. Unfortunately, my efforts have hit a roadblock - the drop down menus aren't aligning as intended and ...

"do not make use of inline labels in bootstrap version 4

I'm working on displaying a bootstrap 4 label for a dropdown hyperlink next to some text. Here is the HTML code I have: <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <img src="http://exampl ...

Why does the "error loading page" message appear on the server when there is a PHP function inside jQuery Mobile?

I am facing an issue with a function I created in my jQuery Mobile code. It works perfectly fine on my local machine, but when I host it on the server, it does not work properly. Can someone please assist me? Here is a glimpse of the code: <!DOCTYPE ht ...

React and Material UI: Ensuring Proper Whitespace Handling in Strings

Exploring the use of Typography component from Material UI (https://material-ui.com/api/typography/) The main objective is to maintain the new lines and spaces in a saved string. For instance, if the string contains leading spaces and new lines, it shoul ...

Angular's ngSubmit is malfunctioning

Check out this code snippet: <form data-ng-submit="ctrl.filter()" novalidate="true" class="search-filter ng-valid ng-dirty ng-valid-parse"> <fieldset> <div class="search-filter-group"> <div class="s ...

Removing the active class from a Bootstrap menu can be achieved by targeting the specific

I have successfully implemented a Bootstrap Menu by placing it in a separate header.html file and using the php include function to call that file on every page of my website. However, I am now trying to figure out how to dynamically change the active cl ...

How to use Selenium-Webdriver (Java Script) to wait for an element to vanish

driver.wait(until.elementIsNotVisible(By.css(".popup-backdrop fade")), 15000); Is there a way to wait for the ".popup-backdrop fade" overlay to disappear before proceeding with element click? I am working with Selenium-webdriver using JavaScript, not Jav ...

Tips for efficiently moving through divs in a personalized single page application?

Exploring the world of JS frameworks and single page app functionality is a bit of a mystery to me. Currently, I have a pseudo single page app set up without any specific framework in place. The setup involves 3 tabs that toggle visibility for 3 different ...

Reading and extracting information from an HTML page using jQuery

My goal is to extract a specific value from an AJAX response that is in HTML format. Below is the AJAX call I am working with: var result = $.ajax({ //datatype : "application/json", type: "POST", url: ddcUrl ...

Ways to fix text overlap in a pill

Click here to view the code on jsBin I quickly copied HTML/CSS code to jsBin using a tool called SnappySnippet. I attempted various solutions, but none of them worked. The best option for me seems to be overflow: ellipses word-break: break-word; word-b ...

The HTML button triggers a function to execute on a different webpage when clicked

I'm facing a straightforward issue that I can't seem to figure out due to my limited experience with Angular and web development. The problem revolves around two components, namely home and dashboard. In the home.component.html file, there's ...

How to prevent click events and still enable scrolling within a DIV using CSS/JS

Basically, I am looking to enable scrolling within a DIV while also disabling click events. Any suggestions on how this can be achieved? Appreciate any help! ...

The Json script in a Chrome extension will only execute the first time the URL is inputted

I've been working on developing a Chrome extension that utilizes CSS and HTML elements to block specific sections of the YouTube page. The problem I'm encountering is that the Json script only applies the CSS files correctly the first time I visi ...

Navigating content with style: Horizontal scrolling feature in HTML5 & CSS3

How can I create a magazine-style website similar to asidemag.com using HTML5 and CSS3, with horizontal scrolling feature? ...

Using ReactJS and Ruby on Rails to implement an AJAX delete request

There is a component named Items residing inside a parent component called ItemsContainer. A click on a button within the Items component triggers an Ajax function to delete that specific Item. However, I am encountering a 500 error message at the moment ...

Utilizing an additional parameter in React to dynamically change the API URL

Hello everyone! I'm facing a slight issue with one of my React applications: I'm attempting to retrieve Weather alerts using an API. Here's how my App.js file is set up: import React, { Component } from 'react'; import './App ...

Automated system is responsible for flagging and disabling comments

We are facing a puzzling issue at the moment. Our comments form allows users to submit their thoughts on news articles, and each submission is immediately accepted and displayed on the same page. Within each comment, there is a link that enables users to ...