将 badge 组件添加到 Bootstrap 列表组项
将 badges 组件添加到任何列表组项目,它会自动定位在右侧。只需在 <li> 元素中添加 <span class = "badge"> 即可。
你可以尝试运行以下代码来实现此操作
示例
<!DOCTYPE html> <html> <head> <title>Bootstrap Example</title> <link href = "/bootstrap/css/bootstrap.min.css" rel =" stylesheet"> <script src = "/scripts/jquery.min.js"></script> <script src = "/bootstrap/js/bootstrap.min.js"></script> </head> <body> <h3>Tutorials</h3> <ul class = "list-group"> <li class = "list-group-item">Programming</li> <li class = "list-group-item">Web Development</li> <li class = "list-group-item">Networking</li> <li class = "list-group-item"> <span class = "badge">New</span> Database </li> <li class = "list-group-item">SAP</li> <li class = "list-group-item"> <span class = "badge">New</span> Academic </li> </ul> </body> </html>
广告