纯html5和css3写的好看按钮

| 阅读数:--次| 作者:小猪仔
摘要:在过去的Web开发中,通常使用图片来做按钮的样式。不过随着CSS3技术的发展,你完全可以通过几行代码来定制一个漂亮的按钮,并且还可以呈现渐变、框阴影、文字阴影等效果。此类按钮最大的优势是省去了加载和设计图片的步骤,并且非常易于编辑、扩展和定制,在线查看效果,复制就可运行
html5代码
运行代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>www.webkfa.com | CSS3好看的按钮</title>
		<style>
#dark {
	background-color: #333;
	border: 1px solid #000;
	padding: 10px;
	margin-top: 20px;
}

#light {
	background-color: #FFF;
	border: 1px solid #dedede;
	padding: 10px;
	margin-top: 20px;
}

li {
	list-style: none;
	padding-top: 10px;
	padding-bottom: 10px;
}

.button,.button:visited {
	background: #222 repeat-x;
	display: inline-block;
	padding: 5px 10px 6px;
	color: #fff;
	text-decoration: none;
	-moz-border-radius: 6px;
	-webkit-border-radius: 6px;
	-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
	-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
	text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
	border-bottom: 1px solid rgba(0, 0, 0, 0.25);
	position: relative;
	cursor: pointer
}

.button:hover {
	background-color: #111;
	color: #fff;
}

.button:active {
	top: 1px;
}

.small.button,.small.button:visited {
	font-size: 11px
}

.button,.button:visited,.medium.button,.medium.button:visited {
	font-size: 13px;
	font-weight: bold;
	line-height: 1;
	text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
}

.large.button,.large.button:visited {
	font-size: 14px;
	padding: 8px 14px 9px;
}

.super.button,.super.button:visited {
	font-size: 34px;
	padding: 8px 14px 9px;
}

.pink.button,.magenta.button:visited {
	background-color: #e22092;
}

.pink.button:hover {
	background-color: #c81e82;
}

.green.button,.green.button:visited {
	background-color: #91bd09;
}

.green.button:hover {
	background-color: #749a02;
}

.red.button,.red.button:visited {
	background-color: #e62727;
}

.red.button:hover {
	background-color: #cf2525;
}

.orange.button,.orange.button:visited {
	background-color: #ff5c00;
}

.orange.button:hover {
	background-color: #d45500;
}

.blue.button,.blue.button:visited {
	background-color: #2981e4;
}

.blue.button:hover {
	background-color: #2575cf;
}

.yellow.button,.yellow.button:visited {
	background-color: #ffb515;
}

.yellow.button:hover {
	background-color: #fc9200;
}
</style>
	</head>
	<body>
		<noscript>
			<div id="noscript">
				You need JavaScript enabled to view most of the demos!
			</div>
		</noscript>
		<div id="container">
			<div id="inner_wrap">
				<div id="light">
					<ul>
						<li>
							<a class="super button pink">Pink Button</a>
							<a class="large button green">Green Button</a>
						</li>
						<li>
							<a class="large button blue">Blue Button</a>
							<a class="large button red">Red Button</a>
						</li>
						<li>
							<a class="large button orange">Orange Button</a>
							<a class="large button yellow">Yellow Button</a>
						</li>
					</ul>
				</div>
				<div id="dark">
					<ul>
						<li>
							<a class="super button pink">Pink Button</a>
							<a class="large button green">Green Button</a>
						</li>
						<li>
							<a class="medium button blue">Blue Button</a>
							<a class="large button red">Red Button</a>
						</li>
						<li>
							<a class="small button orange">Orange Button</a>
							<a class="medium button yellow">Yellow Button</a>
						</li>
					</ul>
				</div>
			</div>
			<div id="footer">
				<a href="http://www.webkfa.com">更多web开发例子</a>
			</div>
		</div>
	</body>
</html>
返回顶部
学到老代码浏览 关闭浏览