Home Web Front-end H5 Tutorial Implementation of html5 and css3 dynamic bubble button

Implementation of html5 and css3 dynamic bubble button

Jun 12, 2018 pm 01:41 PM
css3 button

We are creating a useful set of animated buttons with the power of multiple backgrounds and animations in CSS3, without using JavaScript, with this button pack you can easily turn anything on your web page into an animated button The link just specifies a class name, friends who need it can refer to

This time, we are creating a useful setting to animate buttons with the power of multiple backgrounds and animations of CSS3. With this button pack you can easily turn any link on your web page into an animated button by just specifying a class name. No JavaScript necessary. Four color themes and three sizes are also available by assigning additional class names.
To turn a regular link on a web page into a fancy animated CSS3 button, you just need to specify the button class and one of the supported colors. See some examples below:

<a href="#" class="button blue big">Download</a> 
<a href="#" class="button blue medium">Submit</a> 
<a href="#" class="button small blue rounded">Submit</a>
Copy after login

There are four color classes – blue, green, orange and gray. The rest of the classes you see assigned to the link above are optional. You can choose from small, medium, and large sizes, and one category – Rounded, which creates a more rounded version of the button.
Effect Demonstration
It is recommended to use standard browsers such as Chrome and Firefox to view the effect. Even IE 9 has some incompatibilities.

The CSS code for all animated buttons resides in buttons.css. This makes it easy to drop into an existing project and use it.
Please note that throughout the code below, I have defined two versions of the same property in some places. This has to do with the way browsers handle CSS definitions. They parse the rules one by one and apply them, ignoring what they don't understand. This way we can have an understanding of all the rules, which is the normal version, and a CSS3 enabled one that will ignore the old ones.
The first thing we need to do is define the button class. This is the backbone of the button as it applies positioning, fonts and background styles.
The first is the style related to the font, after which the properties are displayed as follows. It is set up as an inline-block, which allows it to sit on the same line as the text around it (like an inline element), but also like an aspect block with padding and margins.
At one point you will see that each button has four background images applied to it. While this sounds scary, only one file is actually requested from the server. The first two backgrounds, the lower left and upper right sections are bubble images, which you can see in the illustration below, and the other two are pure CSS gradients.
As I mentioned above, the background of the bubble is displayed as two separate images, offset by the background position property. Using the CSS3 transition property, we defined animations that would have both versions of the background image at the top or bottom of the slide, creating a bubble effect when you see the button hovered.

/* BlueButton */ 
.blue.button{ 
color:#0f4b6d !important; 
border:1px solid #84acc3 !important; 
/* A fallback background color */ 
background-color: #48b5f2; 
/* Specifying a version with gradients according to */ 
background-image: url('button_bg.png'), url('button_bg.png'), 
-moz-radial-gradient( center bottom, circle, 
rgba(89,208,244,1) 0,rgba(89,208,244,0) 100px), 
-moz-linear-gradient(#4fbbf7, #3faeeb); 
background-image: url('button_bg.png'), url('button_bg.png'), 
-webkit-gradient( radial, 50% 100%, 0, 50% 100%, 100, 
from(rgba(89,208,244,1)), to(rgba(89,208,244,0))), 
-webkit-gradient(linear, 0% 0%, 0% 100%, from(#4fbbf7), to(#3faeeb)); 
} 
.blue.button:hover{ 
background-color:#63c7fe; 
background-image: url('button_bg.png'), url('button_bg.png'), 
-moz-radial-gradient( center bottom, circle, 
rgba(109,217,250,1) 0,rgba(109,217,250,0) 100px), 
-moz-linear-gradient(#63c7fe, #58bef7); 
background-image: url('button_bg.png'), url('button_bg.png'), 
-webkit-gradient( radial, 50% 100%, 0, 50% 100%, 100, 
from(rgba(109,217,250,1)), to(rgba(109,217,250,0))), 
-webkit-gradient(linear, 0% 0%, 0% 100%, from(#63c7fe), to(#58bef7)); 
}
Copy after login

Each color class defines a unique set of unique properties – the color of the button’s text label, text shadow and background image. Notice that we used the Background property button to add multiple images. They are the top of the hierarchy, appearing first and being defined above.
Only Mozilla and Webkit browsers currently support CSS gradients, but with completely different syntax. The remaining browsers will display the fallback background color. You may have noticed that we did not include a prefix for the free version of the gradient rules. This is due to the fact that gradients are not officially part of a CSS specification yet, and there is no preferred syntax protocol.
In the snippet above, you can see that we defined a linear gradient and a radial one above it. To make the gradient blend more smoothly with WebKit and Mozilla syntax, we define one of the RGBA radials, which makes the outer color of the gradient completely transparent.
With this, our CSS3 animated bubble button is complete!
Summary
These buttons are completely based on CSS and integration is very simple – just drop the buttons folder somewhere in your project. By modifying CSS files, you can create your own colors and shapes.

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

H5 implements the function code of uploading local images and being able to preview them

How to set up CSS Text font color

The above is the detailed content of Implementation of html5 and css3 dynamic bubble button. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to fix Microsoft Teams white screen How to fix Microsoft Teams white screen Apr 17, 2023 pm 05:07 PM

Restart Microsoft Teams If you get a blank screen after launching Teams, a good place to start is to restart the app itself. To close and restart Microsoft Teams: Right-click the Teams icon in the notification area of ​​the taskbar and click Exit from the menu. Restart Microsoft Teams from the Start menu or desktop shortcut and see if it works. Close Microsoft Teams from Task Manager If a basic restart of the Teams process doesn't work, go into Task Manager and end the task. To close Teams from Task Manager, do the following

What is the Windows Security Button? All you need to know What is the Windows Security Button? All you need to know Apr 13, 2023 pm 10:22 PM

What is the Windows Security Button? As the name suggests, Windows Security Button is a security feature that allows you to securely access the login menu and log in to your device using a password. In this case, smartphones are definitely ahead. But Windows portable devices, such as tablets, have begun adding a Windows Security button that's more than just a way to keep unwanted users out. It also provides additional login menu options. Although if you try to find the Windows Security button on your desktop PC or laptop, you might be disappointed. why is that? Tablets vs. PCs The Windows security button is a physical button that exists on tablets

5 Ways to Disable Delivery Optimization Service in Windows 5 Ways to Disable Delivery Optimization Service in Windows May 17, 2023 am 09:31 AM

There are many reasons why you might want to disable the Delivery Optimization service on your Windows computer. However, our readers complained about not knowing the correct steps to follow. This guide discusses how to disable the Delivery Optimization service in a few steps. To learn more about services, you may want to check out our How to open services.msc guide for more information. What does Delivery Optimization Service do? Delivery Optimization Service is an HTTP downloader with cloud hosting solution. It allows Windows devices to download Windows updates, upgrades, applications and other large package files from alternative sources. Additionally, it helps reduce bandwidth consumption by allowing multiple devices in a deployment to download these packages. In addition, Windo

How to restart, force restart, and shut down iPad Mini 6 How to restart, force restart, and shut down iPad Mini 6 Apr 29, 2023 pm 12:19 PM

How to Force Restart iPad Mini 6 Force restarting iPad Mini 6 is done with a series of button presses, and it works like this: Press and release for Volume Up Press and release for Volume Down Press and release the Power/Lock button until you see Apple logo, indicating that the iPad Mini has been force restarted. That’s it. You have force restarted the iPad Mini 6! Force restart is usually used for troubleshooting reasons, such as the iPad Mini freezing, apps freezing, or some other general misbehavior. One thing to note about the procedure for force restarting the 6th generation iPad Mini is that for all other devices that have ultra-thin bezels and use

After rewriting:

How to Fix PS5 Controller Not Recognized on Windows 11 After rewriting: How to Fix PS5 Controller Not Recognized on Windows 11 May 09, 2023 pm 10:16 PM

&lt;h3&gt;What should I know about connecting my PS5 controller? &lt;/h3&gt;&lt;p&gt;As good as the DualSense controller is, there have been reports of the controller not connecting or not being detected. The easiest way to solve this problem is to connect the controller to your PC using an appropriate USB cable. &lt;/p&gt;&lt;p&gt;Some games natively support DualSense. In these cases, you can simply plug in the controller. But this raises other questions, like what if you don't have a USB cable or don't want to use one

How to clear the download history of Microsoft Edge browser? How to clear the download history of Microsoft Edge browser? Apr 21, 2023 am 09:34 AM

&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Click to enter:&lt;/strong&gt;ChatGPT tool plug-in navigation&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Find and delete download history in Edge&lt; /h2&gt;&lt;p&gt;Like other browsers, Edge has a&lt;strong&gt;Download

Change the power button action on Windows 11 [5 Tips] Change the power button action on Windows 11 [5 Tips] Sep 29, 2023 pm 11:29 PM

The power button can do more than shut down your PC, although this is the default action for desktop users. If you want to change the power button action in Windows 11, it's easier than you think! Keep in mind that the physical power button is different from the button in the Start menu, and the changes below won't affect the operation of the latter. Additionally, you'll find slightly different power options depending on whether it's a desktop or laptop. Why should you change the power button action in Windows 11? If you put your computer to sleep more often than you shut it down, changing the way your hardware power button (that is, the physical power button on your PC) behaves will do the trick. The same idea applies to sleep mode or simply turning off the display. Change Windows 11

How to reset your Xbox Series S or X controller How to reset your Xbox Series S or X controller Jun 03, 2023 pm 08:19 PM

The Xbox gaming console is a favorite among gamers. With the new SeriesX and SeriesS, gaming is almost a lifelike experience. The Xbox controller is your primary tool for experiencing gaming effects. Sometimes the controller connection gets cut off or some errors are encountered while trying to connect the controller to the main console. This may be due to various issues related to pairing. This can be overcome with a few simple steps. Reset your Xbox Series S or Xbox Series X controller Step 1: Press and hold the Xbox button on your controller for a few seconds to turn off the controller. Step 2: On the screen, go to Turn off controller and press button A to select that option. NOTE: If you keep pressing X

See all articles