Designing a horizontal slide banner with enhanced functionality

I am working on displaying a vertical banner that slides out horizontally from the right side of the screen when the user clicks on the open button/div, and also has the ability to close it. The basic design concept is illustrated in the sample image below.

To see my progress, I have created a demonstration on CodePen: http://codepen.io/anon/pen/oXgePX

<div class="horizontal-slide" id="other-menu"><<</div>


<div class="menu-other slide-right slide-opened" id="other-menu-content">
  horizontal on right slide div
</div>

UPDATE:

I was able to achieve the desired effect by enclosing the banner and button within another div.

.wrapper{
  float:right;
  position:absolute;
  right:0;
}

Here is an improved example: http://codepen.io/anon/pen/aOzyxo

I am still working on making the button slide along with the banner for a smoother appearance.

Answer №1

It seems a modification to your CSS is necessary.

Take this for instance:

/* adjust floating */
float:left;

/* fixed positioning */
position:fixed;

Your code should resemble something like this:

http://codepen.io/anon/pen/mJyMgY

Am I misunderstanding your query?

Answer №2

Perhaps this is the solution you were looking for. It seems like a promising start to me.

$(function() {

  //slideout-menu-toggle
  $(".banner-slide").click(function(event) {
    var _slideMenu = $("#right-banner");
    if (_slideMenu.hasClass("slide-opened")) {
      $( "#right-banner" ).animate({ "right": "-190px" }, "slow" );
      $(  "#hbanner" ).html("<<");
      //alert('a')
    } else {
      $( "#right-banner" ).animate({ "right": "0" }, "slow" );
      $(  "#hbanner" ).html(">>");
    }

    _slideMenu.toggleClass("slide-opened");
  });
});
#right-banner {
  position:absolute;
  right:0;
  top: 0;
  width: 210px;
}

.right-banner {
  width: 150px;
  height: 200px;
  background-color: green;
  padding: 20px;
  float: right;
  background-color: blue;
}

#hbanner {
  float: left;
  background-color: red;
  cursor:pointer;
}

.wrapper {
  float: right;
  position: absolute;
  right: 0;
  z-index: 100000;
}

.content {
  width: calc(100% - 210px);
  background-color: magenta;
  height: 200px;
  float: left;
  text-align: right;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="content">
  This is sample text</div>
<div class="wrapper">
  <div id="right-banner" class="slide-opened">
    <div class="banner-slide" id="hbanner">
      >>
    </div>

    <div class="right-banner" id="hbanner-wrapper">
     horizontal on right slide div
     </div>
   </div>
</div>

Answer №3

Make your code cleaner and more concise by utilizing CSS transitions along with a basic toggleClass function in jQuery:

$('#clickMe').on('click', function(){
    $('#box').toggleClass('open');
});

Check out the live demo: http://codepen.io/jsmith/pen/RqLxYP

Answer №4

implement a jQuery toggle function

$('#slider').toggleClass('sliderthing');

combining it with CSS for styling should create a good effect

Answer №5

To achieve this effect, I enclosed the banner and button within another container.

You can view the updated demonstration here: http://codepen.io/anon/pen/eWzbxJ

I included specific animations to ensure that the red button appears and disappears immediately upon clicking, accompanied by a seamless transition.

.container {
  float: right;
  position: absolute;
  right: 0;
  z-index: 100000;
}

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

Strategies for organizing your week with a calendar

Hello, I am working on creating a weekly calendar using PHP and I want to add events to the calendar like in this example. However, I am unsure how to display the events in the calendar at the correct time of day. Here is the code snippet I am currently u ...

Encountering a 404 error while attempting to upload files with multer in node.js

I am currently developing a website using node.js where users can create small adverts with various information and upload images. I have successfully set up a mongodb database to store the data, but I am encountering a 404 error when trying to upload imag ...

Steps for coloring an image using pixel values retrieved from a database

My goal is to create a heat map by dividing an image I captured from Google Maps into a grid, which can be seen here: https://i.sstatic.net/uNv4e.jpg I want to assign colors to specific grid squares based on the number of people living in them. For exampl ...

Inject the error into the Router in Express.js, utilizing Node.js

Is it possible to pass an error into an express.js Router? The express.js documentation does not provide a clear answer regarding passing errors in relation to middleware, routers, and error handling (I am unable to include links as I lack reputation). I ...

When validating with Sequelize, an error occurred due to one or more columns being undefined:

Hello everyone, I'm facing some issues. Can anyone explain why this.day_number and this.teacher_id are coming up as undefined? 'use strict' module.exports = (sequelize, DataTypes) => { const Teacher = sequelize.models.teachers ...

Creating a new object through manipulation of existing objects

In my attempt to transform an existing object into a new object structure, I am facing some challenges. Here is the current data set: const jsonStructure = { "a11/a22/animations": "snimations", "a11/a22/colours": "sl/colours", "a11/a22/fonts" ...

Enhancing an identity function with type hinting

I am looking to define a specification for a function that returns its input argument, regardless of its type. The crucial aspect here is to mirror the interface of the argument in the return value. For instance, when I type z. on line 6 as shown in the i ...

Issue with Internet Explorer 7 causing table to display with added height

Currently investigating why there is additional space being added by IE. The only fixed data is the width of the image (171 px). Using Jquery, I checked the height of the div in Firefox, Chrome, and Opera which came out to 164px, but in IE 7 it's 172 ...

How can union types be used correctly in a generic functional component when type 'U' is not assignable to type 'T'?

I've been researching this issue online and have found a few similar cases, but the concept of Generic convolution is causing confusion in each example. I have tried various solutions, with the most promising one being using Omit which I thought would ...

Incorporate a fresh key-value pair into the Redux Toolkit's state

I am currently working on an application that enables users to create and modify recipes. To manage the state, I have chosen to utilize React Toolkit and Redux. Here is an example of the state structure: const ingredients = [ { ingredientName: &apos ...

What methods are available to keep a component in a fixed position on the window during certain scrolling intervals?

I need help creating a sidebar similar to the one on this Airbnb page. Does anyone have suggestions for how to make a component stay fixed until you scroll past a certain section of the page? I am working with functional React and Material-UI components, ...

Adjust the position of elements based on their individual size and current position

I am faced with a challenge regarding an element inside a DIV. Here is the current setup... <div id="parent"> <div id="child"></div> </div> Typically, in order to center the child within the parent while dynamically changing i ...

"Encountering a problem with installing packages on Node.js through npm

After spending the last 2 hours scouring StackOverflow and Google, I've come to the decision to seek help here. The issue I'm facing is that I'm unable to install any packages using npm. Specifically, when trying to install jQuery (as well ...

What is the best way to show all cards in Angular when no filtering input is provided?

I have implemented a filter feature for multiple cards in Angular using Pipes. The filter works well, but I am facing an issue where no cards are displayed when there is no input value provided. I would like all the cards to be displayed when no input is g ...

An issue with MVC Ajax calls to an API resulting in a null model retrieval

I've been scratching my head for hours because I'm facing a strange issue with my API in one project, while everything is working fine in another project! The Problem: Here's the JavaScript code snippet: var data = new FormData(), ...

Show a dynamic modal with a widget displayed inside

I am facing an issue with my Angular.js website that is filled with a multitude of widgets. Each widget consists of a template.html file paired with a controller.js file to form an angular module. These widgets are utilized on a dashboard where users have ...

Tips for incorporating over ten elements in a carousel

I have encountered an issue while attempting to include more than ten elements in a bootstrap carousel. Whenever I click on the thumbnail corresponding to the element above number ten, it redirects me back to the first slide. For a demonstration and the s ...

What can I do to prevent masonry images from piling on top of one another?

I have been working on creating a photo gallery using the Bootstrap 5 example on masonry, and everything is working well so far. I have also successfully implemented modal boxes. However, the only issue I'm facing is with the JS Image Loaded not preve ...

The functionality of session_start() is operating smoothly in Firefox, however, it is experiencing compatibility issues

session_start() seems to be functioning properly in Firefox, but is not working in Chrome. I have placed session_start() at the beginning of a file, yet it still fails in Google Chrome. I have implemented a condition in my code where if the session is se ...

Utilize emit to distribute / allocate a variable

I have some variables stored in a file called server.js (and they tend to change frequently). My goal is to pass these variables to client.js whenever the client sends a request (triggers the 'validate' event). Even though the event is triggered, ...