我使用bootstrap 3按钮,我想将尺寸修改为更小,我尝试过以下哪些不起作用
.btn-sml {
padding: 10px 10px;
font-size: 22px;
border-radius: 8px;
}
有更好的方法来实现这一目标吗?
答案 0 :(得分:30)
Bootstrap提供四种按钮尺寸:
定义不同大小的类是:
.btn-lg
.btn-md
.btn-sm
.btn-xs
以下示例显示了不同按钮大小的代码:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Button Sizes</h2>
<button type="button" class="btn btn-primary btn-lg">Large</button>
<button type="button" class="btn btn-primary btn-md">Medium</button>
<button type="button" class="btn btn-primary btn-sm">Small</button>
<button type="button" class="btn btn-primary btn-xs">XSmall</button>
</div>
&#13;
答案 1 :(得分:5)
在y方向上手动将填充设置为0,并添加内联样式以减小字体大小,这在Bootstrap 4中为我提供了xs-Button:
<input type="submit" value="Submit" class="btn btn-sm btn-outline-primary py-0" style="font-size: 0.8em;">
答案 2 :(得分:2)
您可以使用Bootstrap 4中的height
属性轻松地使按钮变小。
例如:
.btn-sml { height: 4vh; } /* change the value according to your need. */
答案 3 :(得分:1)
Bootstrap 4不支持xs,这里我们只能对小图标使用“ btn-sm”类。
<a class="btn btn-info btn-sm"href="#"><i class="fa fa-edit fa-fw"></i></a>
答案 4 :(得分:0)
您可以使用徽章样式链接,它们的外观和行为类似于按钮:
.badge-sm {
min-width: 1.8em;
padding: .25em !important;
margin-left: .1em;
margin-right: .1em;
color: white !important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<label class="mx-1 text-dark">Buttons:</label>
<a href="#" class="badge badge-primary badge-sm" data-scale="hour" data-value="1">1</a>
<a href="#" class="badge badge-danger badge-sm" data-scale="hour" data-value="2">2</a>