bootstrap3的新增和修改的btn-*用法

本文介绍了Bootstrap中按钮的样式及不同尺寸的实现方法,并通过示例代码展示了如何使用.btn-default和其他尺寸类如.btn-lg、.btn-xs等来调整按钮外观。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、新增的btn-*按钮:btn-group-lg、btn-group-xs、btn-group-sm,这三个是按钮组的大小

      修改后的按钮属性:

       2.*版                  3.0版

 .btn                     .btn .btn-default

.btn-mini    .btn-xs
.btn-small    .btn-sm
.btn-large    .btn-lg
使用btn-default的时候要注意,必须要结合btn使用比如:<button type="button" class="btn btn-default"> 要不btn-default会不起效果。当然 btn 可单独用

2、实验代码

<!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" />
<link rel="stylesheet" href="dist/css/bootstrap.css" >
<script src="dist/js/bootstrap.js"></script>
<title>无标题文档</title>
</head>

<body style="margin:100px">
<div class="container">
	<button type="button" class="btn btn-default">
    	 btn btn-default
    </button>
    <button type="button" class="btn-lg">
    	  <span class="glyphicon glyphicon-star"></span> btn-lg
    </button>
    <button type="button" class="btn-xs">
    	  <span class="glyphicon glyphicon-star"></span> btn-xs
    </button>
    <button type="button" class="btn-sm">
    	  <span class="glyphicon glyphicon-star"></span> btn-sm
    </button>
    <button type="button" class="btn-group-lg">
    	  <span class="glyphicon glyphicon-star"></span> btn-group-lg
    </button>
    <button type="button" class="btn-group-xs">
    	  <span class="glyphicon glyphicon-star"></span> btn-group-xs
    </button>
    <button type="button" class="btn-group-sm">
    	  <span class="glyphicon glyphicon-star"></span> btn-group-sm
    </button>
</div>
</body>

3、效果图:


<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>主页</title> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"> </head> <body> <div class="container"> <h1 class="text-dark-emphasis text-center mt-5">学生管理系统</h1> <form method="post" action="" class="row g-3 mt-3 d-flex justify-content-around align-items-center"> <div class="col-auto"> <label for="name" class="text-primary-emphasis">姓名</label> </div> <div class="col-auto"> <input type="text" class="form-control" id="name" placeholder="请输入姓名"> </div> <div class="col-auto"> <label for="age" class="text-primary-emphasis">年龄</label> </div> <div class="col-auto"> <input type="number" class="form-control" id="age" placeholder="请输入年龄"> </div> <div class="col-auto"> <label for="address" class="text-primary-emphasis">地址</label> </div> <div class="col-auto"> <input type="text" class="form-control" id="address" placeholder="请输入地址"> </div> <div class="col-auto"> <button type="submit" class="btn btn-dark">保存</button> </div> </form> <table class="mt-3 table table-light table-bordered text-center"> <thead> <tr class="text-primary-emphasis"> <th scope="col">学号</th> <th scope="col">姓名</th> <th scope="col">年龄</th> <th scope="col">地址</th> <th scope="col">操作</th> </tr> </thead> <tbody> <tr> <th scope="row">1</th> <td>张三</td> <td>15岁</td> <td>江西省南昌市青山湖区北京东路58号</td> <td> <button type="button" class="btn btn-sm btn-secondary mx-3" onclick="fillForm(this)">修改</button> <button type="button" class="btn btn-sm btn-danger">删除</button> </td> </tr> <tr> <th scope="row">2</th> <td>李四</td> <td>18岁</td> <td>江西省南昌市青山湖区北京东路59号</td> <td> <button type="button" class="btn btn-sm btn-secondary mx-3" onclick="fillForm(this)">修改</button> <button type="button" class="btn btn-sm btn-danger">删除</button> </td> </tr> </tbody> </table> </div> <script> let name = document.getElementById(&#39;name&#39;) let age = document.getElementById(&#39;age&#39;) let address = document.getElementById(&#39;address&#39;) function fillForm(item) { const tr = item.parentNode.parentNode let nodes = tr.querySelectorAll(&#39;td&#39;) console.log(nodes) name.value = nodes[0].innerText age.value = parseInt(nodes[1].innerText) address.value = nodes[2].innerText } </script> </body> </html><!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"> <title>登录页</title> <style> form { margin: 200px auto; width: 35%; height: 25%; } div.card { padding-left: 50px; padding-right: 50px; } </style> </head> <body> <div class="container"> <form class="text-center"> <img class="mb-4" src="img/logo.svg" alt="Logo" width="120" height="120"> <h1 class="h3 mb-4 fw-normal">登录</h1> <div class="mb-4 form-floating"> <label for="username">用户</label> <input type="text" class="form-control" id="username"> </div> <div class="mb-4 form-floating"> <label for="password">密码</label> <input type="password" class="form-control" id="password"> </div> <button class="w-100 btn btn-lg btn-dark" type="submit">登录</button> <p class="mt-5 mb-3 text-muted">© 2025–2035</p> </form> </div> </body> </html>
最新发布
06-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值