Home Web Front-end HTML Tutorial css3的实现的checkbox复选框和radio单选框绚丽美化效果_html/css_WEB-ITnose

css3的实现的checkbox复选框和radio单选框绚丽美化效果_html/css_WEB-ITnose

Jun 24, 2016 am 11:28 AM

css3的实现的checkbox复选框和radio单选框绚丽美化效果:
在css3之前要美化单选框和复选框无非是使用图片进行相关的替换操作,并且还有很大的局限性。
由于css3的出现,一切好像变的都变的轻松起来,并且效果非常的绚丽,这是使用css2无法做到的,下面就分享一段能够实现此功能的代码实例,需要的朋友可以做一下参考。
代码如下:

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><head><style type="text/css">@-webkit-keyframes click-wave{  0%{    width:40px;    height:40px;    opacity:0.35;    position:relative;  }  100%{    width:200px;    height:200px;    margin-left:-80px;    margin-top:-80px;    opacity:0.0;  }}@-moz-keyframes click-wave{  0%{    width:40px;    height:40px;    opacity:0.35;    position:relative;  }  100%{    width:200px;    height:200px;    margin-left:-80px;    margin-top:-80px;    opacity:0.0;  }}@-o-keyframes click-wave{  0%{    width:40px;    height:40px;    opacity:0.35;    position:relative;  }  100%{    width:200px;    height:200px;    margin-left:-80px;    margin-top:-80px;    opacity:0.0;  }}@keyframes click-wave{  0%{    width:40px;    height:40px;    opacity:0.35;    position: relative;  }  100%{    width:200px;    height:200px;    margin-left:-80px;    margin-top:-80px;    opacity:0.0;  }}.option-input{  -webkit-appearance:none;  -moz-appearance:none;  -ms-appearance:none;  -o-appearance:none;  appearance:none;  position:relative;  top:13.33333px;  width:40px;  height:40px;  -webkit-transition:all 0.15s ease-out 0;  -moz-transition:all 0.15s ease-out 0;  transition:all 0.15s ease-out 0;  background:#cbd1d8;  border:none;  color:#fff;  cursor:pointer;  display:inline-block;  outline:none;  position:relative;  margin-right:0.5rem;  z-index:1000;}.option-input:hover{  background:#9faab7;}.option-input:checked{  background:#40e0d0;}.option-input:checked::before{  width:40px;  height:40px;  position:absolute;  content:'\2716';  display:inline-block;  font-size:26.66667px;  text-align:center;  line-height:40px;}.option-input:checked::after{  -webkit-animation:click-wave 0.65s;  -moz-animation:click-wave 0.65s;  animation:click-wave 0.65s;  background:#40e0d0;  content:'';  display:block;  position:relative;  z-index:100;}.option-input.radio{  border-radius:50%;}.option-input.radio::after{  border-radius:50%;}body{  display:-webkit-box;  display:-moz-box;  display:box;  -webkit-box-orient:horizontal;  -moz-box-orient:horizontal;  box-orient:horizontal;  -webkit-box-pack:start;  -moz-box-pack:start;  box-pack:start;  -webkit-box-align:stretch;  -moz-box-align:stretch;  box-align:stretch;  background:#e8ebee;  color:#9faab7;  font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;  text-align:center;}body div{  padding:5rem;}body label{  display:block;  line-height:40px;}</style></head><body><div style="width:200px;float:left">  <label><input type="checkbox" class="option-input checkbox" checked="">Checkbox </label>  <label><input type="checkbox" class="option-input checkbox">Checkbox</label>  <label><input type="checkbox" class="option-input checkbox">Checkbox</label></div><div style="width:200px;float:left">  <label><input type="radio" class="option-input radio" name="example">Radio option</label>  <label><input type="radio" class="option-input radio" name="example">Radio option</label>  <label><input type="radio" class="option-input radio" name="example">Radio option</label></div></body></html>
Copy after login

上面的代码实现了我们的要求,这里不多介绍,如有问题可以跟帖留言。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=15388

更多内容可以参阅:http://www.softwhy.com/divcss/

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)

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

See all articles