示例 2 : 按钮工具栏 示例 3 : 按钮组大小 示例 4 : 垂直排列的按钮组 示例 5 : 复选框 示例 6 : 单选框
按钮组
<!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.0.3/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<div class="btn-group" role="group" aria-label="web">
<button type="button" class="btn btn-default">Html</button>
<button type="button" class="btn btn-default">Css</button>
<button type="button" class="btn btn-default">JS</button>
</div>
<!DOCTYPE html> <script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script> <link href="https://how2j.cn/study/css/bootstrap/3.0.3/bootstrap.min.css" rel="stylesheet"> <script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script> <div class="btn-group" role="group" aria-label="web"> <button type="button" class="btn btn-default">Html</button> <button type="button" class="btn btn-default">Css</button> <button type="button" class="btn btn-default">JS</button> </div>
按钮工具栏
<!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.0.3/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<div class="btn-toolbar" role="toolbar" aria-label="study">
<div class="btn-group" role="group" aria-label="java">
<button type="button" class="btn btn-default">基础</button>
<button type="button" class="btn btn-default">中级</button>
<button type="button" class="btn btn-default">高级</button>
</div>
<div class="btn-group" role="group" aria-label="web">
<button type="button" class="btn btn-default">Html</button>
<button type="button" class="btn btn-default">Css</button>
<button type="button" class="btn btn-default">JS</button>
</div>
<div class="btn-group" role="group" aria-label="framework">
<button type="button" class="btn btn-default">Hiber</button>
<button type="button" class="btn btn-default">Struts</button>
<button type="button" class="btn btn-default">Spring</button>
</div>
</div>
按钮组大小
<!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.0.3/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<style>
br{
margin:20px;
}
</style>
<div class="btn-group btn-group-lg" role="group" aria-label="web">
<button type="button" class="btn btn-default">Html</button>
<button type="button" class="btn btn-default">Css</button>
<button type="button" class="btn btn-default">JS</button>
</div>
<br>
<div class="btn-group btn-group" role="group" aria-label="web">
<button type="button" class="btn btn-default">Html</button>
<button type="button" class="btn btn-default">Css</button>
<button type="button" class="btn btn-default">JS</button>
</div>
<br>
<div class="btn-group btn-group-sm" role="group" aria-label="web">
<button type="button" class="btn btn-default">Html</button>
<button type="button" class="btn btn-default">Css</button>
<button type="button" class="btn btn-default">JS</button>
</div>
<br>
<div class="btn-group btn-group-xs" role="group" aria-label="web">
<button type="button" class="btn btn-default">Html</button>
<button type="button" class="btn btn-default">Css</button>
<button type="button" class="btn btn-default">JS</button>
</div>
垂直排列的按钮组
<!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.0.3/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<div class="btn-group-vertical" role="group" aria-label="web">
<button type="button" class="btn btn-default">Html</button>
<button type="button" class="btn btn-default">Css</button>
<button type="button" class="btn btn-default">JS</button>
</div>
<!DOCTYPE html> <script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script> <link href="https://how2j.cn/study/css/bootstrap/3.0.3/bootstrap.min.css" rel="stylesheet"> <script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script> <div class="btn-group-vertical" role="group" aria-label="web"> <button type="button" class="btn btn-default">Html</button> <button type="button" class="btn btn-default">Css</button> <button type="button" class="btn btn-default">JS</button> </div>
复选框
<!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default active">
<input type="checkbox" checked>LOL(默认选中)
</label>
<label class="btn btn-default">
<input type="checkbox" > DOTA
</label>
<label class="btn btn-default">
<input type="checkbox" > WOW
</label>
</div>
<!DOCTYPE html> <script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script> <link href="https://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet"> <script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script> <div class="btn-group" data-toggle="buttons"> <label class="btn btn-default active"> <input type="checkbox" checked>LOL(默认选中) </label> <label class="btn btn-default"> <input type="checkbox" > DOTA </label> <label class="btn btn-default"> <input type="checkbox" > WOW </label> </div>
单选框
<!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default active">
<input type="radio" checked>LOL(默认选中)
</label>
<label class="btn btn-default">
<input type="radio" > DOTA
</label>
<label class="btn btn-default">
<input type="radio" > WOW
</label>
</div>
<!DOCTYPE html> <script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script> <link href="https://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet"> <script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script> <div class="btn-group" data-toggle="buttons"> <label class="btn btn-default active"> <input type="radio" checked>LOL(默认选中) </label> <label class="btn btn-default"> <input type="radio" > DOTA </label> <label class="btn btn-default"> <input type="radio" > WOW </label> </div>
HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。
问答区域
2019-12-11
br margin 设置问题
回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
2019-04-01
checked 作用是?
2 个答案
NoColor 跳转到问题位置 答案时间:2019-08-13 active只是让你看上去选中了(按钮呈现未激活状态),而在input加上checked是实际选中。你用js分别判断一下他们选中状态就明白了
genglong 跳转到问题位置 答案时间:2019-05-01 在html中如果设置了checked属性,那么无论checked为何值,都为选中状态
这里可能是没体现出作用
回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
2019-03-14
div元素的自动换行问题
2017-12-11
单选框和复选框的代码好像是一样的吧?
提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
|