Steps to create a translating floating chat button on your website

Hello there! I am attempting to replicate the style of a Floating Website Chat Button. When a user clicks on the large button, I want it to disappear and transform into a chat box. Something similar to this example: https://codepen.io/neilkalman/pen/VPJpaW

Here is the fiddle link to my progress so far: https://jsfiddle.net/Lkagowe7/. I also aimed to make the button spin around the bottom, utilizing another thread for reference.

Here is the HTML code:

<!DOCTYPE html>
<html lang="en">
    ... (HTML code omitted for brevity) ...
</html>

And here is the CSS code:

body {
    ... (CSS code omitted for brevity) ...
}

Answer №1

Check out this link for a different approach. I made some changes to your code to make it functional. While it may not match the exact example, it demonstrates how you can animate your chat box to appear and disappear.

Using the display css property to hide and show elements doesn't allow for smooth animations. Instead, try using properties like opacity, height, and width to create a shrinking effect when hiding and expanding effect when showing.

.form-box {
  margin: 16px auto;
  font-size: 16px;
  border-radius: 9px;
  position: fixed;
  opacity: 0;
  overflow: hidden;
  bottom: 0;
  right: 10px;
  transform: translate(-50%,-50%);
  width: 30px;
  height: 30px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 5px 10px rgba(0,0,0,0.2);
  box-sizing: border-box;
  background-color: #f5f5f7;
  transition: all .25s ease-in-out;
}

.form-box.open {
  transform: translate(10px, -70px);
  height: 490px;
  width: 366px;
  opacity: 1;
}

If you're not using styles to hide and show elements, you can toggle a class to achieve the same effect. Below is the change I applied to your myFunction function to incorporate this class toggling:

if (x.classList.contains('open')) {
  x.classList.remove("open");
 } else {
  x.classList.add("open");
  document.getElementById("test").focus();
}

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

The importance of adding blank spaces in email formatting

A Visual Basic 6 application is sending a HTML email. The issue is that when the email is received, all blank spaces are removed. For example, in the code snippet below, the email sent says "this is a test" instead of displaying the actual spaces on line ...

Why does the styling on my <a> tags in the footer only take effect when I apply padding to the form above?

It seems that when styling the <a> tag for the list in the footer, no changes occur even if correctly applying the style. However, adding padding to the form in the main part of the code causes the links in the footer to show the change. To see this ...

How can I efficiently pass a JavaScript object to a function using jQuery syntax?

Recently, I've delved into the world of JavaScript and started exploring object orientation, prototyping, and using objects for all functions and variables. However, there is one aspect that many frameworks like jQuery or extJS have that I struggle wi ...

To ascertain whether the mouse is still lingering over the menu

I have a condensed menu construction that unfortunately cannot be changed in HTML, only CSS and JS modifications are possible! $('span').on("hover", handleHover('span')); function handleHover(e) { $(e).on({ mouse ...

Animating transitions on a dynamic Bootstrap navbar using jQuery

I have the code attached here, and I successfully changed the color of the navbar and logo when scrolling down. However, I am looking to add a transition effect when this change occurs. I experimented with various transition options in CSS, but unfortunat ...

Instructions for inserting a hyperlink into a column of a table with the *ngFor directive in Angular2

I currently have a table with 4 columns: Name, ID, Department, and City. I am fetching both the row data and column data as an array from a TypeScript file and iterating through them using *ngFor. Below is a snippet of my code: <tbody> <tr *ng ...

Updating values of objects during iterations and for get requests is ineffective

Currently, I am looping through multiple select fields and attempting to run a get request for each of them. var selects = { key1 : value } $(".chosen-select-field").each( function ( index ) { selects[key2] = $( this ).attr('data-placeholder& ...

Displaying a visual representation of time remaining with a countdown progress bar

While browsing online, I stumbled upon a creative progress bar code featured on this particular website. My goal is to implement a countdown timer that displays the remaining minutes and seconds rather than a percentage. In order to achieve this, I have i ...

Create an HTML table to view JSON data from a cell on a map

Looking to transform the JSON data into a table by organizing the information based on supplier and product. Below is the JSON input and code snippet: $(document).ready(function () { var json = [{ "Supplier": "Supplier1", "Product": "O ...

Divider displayed between images in Internet Explorer 8

On my website, I have arranged four images in a square using the code below: <div id="tempo_main"> <div id="tempo_content"> <div style="text-align: center;z-index: 3;position: absolute;right:350px; left:350px; t ...

An alternative to Beautiful Soup for Python 3.2

Looking to create a web crawler for extracting information from various web pages, I discovered Beautiful Soup which seemed like an excellent tool. It allows me to parse entire documents, create dom objects, iterate through them, and extract attributes sim ...

Is there a similar function to -moz-linear-gradient in Chrome?

My button's CSS includes background: -moz-linear-gradient(center top, #59a1d8, #27247D) repeat scroll 0 0 #0f78c7;, which works well in Mozilla Firefox. However, it does not display properly in the Chrome browser. Can someone suggest an equivalent cod ...

Issue with HTML While Utilizing wp_get_attachment_image

This script : $source = wp_get_attachment_image( get_the_ID(), 'medium' ); $weburl = wp_get_attachment_image_url( get_the_ID(), 'full' ); echo( '<p><a href="%s"><img src="%s"></a></p>', $weburl, ...

Implementing transparency to clip-path using HTML and CSS

How can I apply opacity to the clip-path/clip area, similar to the image shown below? Please find my code snippet for reference: .item--clip .demo { width: 200px; height: 250px; } .item--clip .has-mask { position: absolute; clip: rect(10px, 19 ...

Bootstrap 4 Carousel: Displaying Multiple Frames Simultaneously and Sliding One at a Time

A different query was raised regarding the same issue (refer to the mentioned question) for Bootstrap 3, however, the suggested solutions are not compatible with Bootstrap 4. The illustration in this post effectively conveys what I am aiming for. Take a ...

I can view this email signature correctly in VS Code and my browser, but all the other applications I've tried so far are unable to display it correctly

Simply put, I am facing an issue with my email signature. I use eM Client, while my client uses Outlook and I've also checked it in iCloud webmail. Surprisingly, none of these platforms display my email signature correctly, but VS Code and all my brow ...

Improve the performance of my website and resolve the zooming problem

Trying my hand at teaching myself jquery and creating a decent layout. I believe what I have done is acceptable, but I still have some questions. This is my first attempt at jquery without copying someone else's work. I've aimed to keep it relev ...

Arranging the placement of the dropdown menu

I am struggling with positioning the items in my dropdown menu. The functionality itself is working perfectly, but the issue arises when it comes to aligning the dropped down items. Initially, I positioned them based on a smaller screen size, but when view ...

Looking to dynamically adjust row color based on status using ANGULAR 4

In my table, I have 6 columns: name, email, phone, company, status_1, and status_2. Both status_1 and status_2 can have two options: "1" or "0." My Requirement: I want to change the color of the row based on the following logic: if(status_1 is "1" ...

Tips for maintaining the alignment of four buttons in a single row as the size of the screen changes

I'm creating a simple browser game as part of my web development learning process. I have a set of divs that represent a warrior, and at the head of the "div table" I have a group of 4 buttons arranged horizontally. However, when the screen size is re ...