CSS 在引导程序中制作较小的按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39635474/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Make smaller button in bootstrap
提问by Dsenese1
I use bootstrap 3 buttons and I want to modify the size to smaller, I've tried with the following which doesn't work
我使用 bootstrap 3 按钮,我想将大小修改为更小,我尝试了以下不起作用
.btn-sml {
padding: 10px 10px;
font-size: 22px;
border-radius: 8px;
}
There is a better way to achieve this ?
有没有更好的方法来实现这一目标?
回答by Dsenese1
Bootstrap provides four button sizes:
Bootstrap 提供了四种按钮大小:
The classes that define the different sizes are:
定义不同大小的类是:
.btn-lg
.btn-md
.btn-sm
.btn-xs
The following example shows the code for different button sizes:
以下示例显示了不同按钮大小的代码:
<!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>
回答by Nils L.
Manually setting the padding in y-direction to 0 and adding an inline-style to reduce the font size gave me an xs-Button in Bootstrap 4:
手动将 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;">