Home > Web Front-end > CSS Tutorial > Handwritten CSS+js to implement radio button

Handwritten CSS+js to implement radio button

青灯夜游
Release: 2018-10-10 15:42:52
forward
3358 people have browsed it

This article introduces handwritten CSS js to implement radio radio buttons. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Sometimes we need to use prettier radio buttons, then we have to abandon the original one and write it. Here is what I implemented

<p class="radio"><span class="yuan rdactive"><span></span></span>你丑你先</p>
	<p class="radio"><span class="yuan"><span></span></span>你才丑你先</p>
<p class="radio"><span class="yuan"><span></span></span>你更丑你先</p>
Copy after login
	.radio{
		display: flex;
		align-items: center;
		width: 100px;
		cursor: pointer;
	}
	.yuan{/*大圈*/
		display: block;
		width: 10px;
		height: 10px;
		border-radius: 50%;
		background: #ececec;/*这里写自己喜欢的颜色*/
		display: flex;
		align-items: center;
		margin-right: 5px;
	}
	.radio>span.rdactive{
		background: #EF6121;/*这里写自己喜欢的颜色*/
	}
	.yuan span{/*小圈*/
		display: block;
		width: 4px;
		height: 4px;
		border-radius: 50%;
		background: white;/*这里写自己喜欢的颜色*/
		margin: 0 auto;
	} 
Copy after login
$(".radio").children(&#39;.yuan&#39;).on(&#39;click&#39;,function(){
	$(&#39;.rdactive&#39;).removeClass(&#39;rdactive&#39;);
	$(this).addClass("rdactive").siblings().removeClass("rdactive");
})
Copy after login

Rendering:

Handwritten CSS+js to implement radio button

Okay, you can achieve it here. Isn’t it very simple? You can try it yourself!

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study. For more related tutorials, please visit CSS Video Tutorial!

Related recommendations:

php public welfare training video tutorial

CSS Online Manual

##div/css graphic tutorial

The above is the detailed content of Handwritten CSS+js to implement radio button. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template