【问题标题】:centering unicode text in button在按钮中居中 unicode 文本
【发布时间】:2015-04-17 04:48:53
【问题描述】:

我有一个使用引导 css 的按钮,我使用 unicode 文本作为按钮,我希望 unicode 文本的字体大小为 30px,按钮高度为 34px;但似乎文本不在按钮内居中。

谁能告诉我一些解决方法

<!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.4/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <button type="button" class="btn btn-primary" style="height: 34px;"><span style="font-size:30px;">&#8649;</span></button>  
</div>
</body>
</html>

【问题讨论】:

  • 按钮高度高度:34px;是强制性的 ?如果不是,则从按钮中删除它
  • 是的,这是强制性的

标签: css twitter-bootstrap button unicode


【解决方案1】:

您可以通过两种方式实现:

  1. 带行高
  2. 移除高度

    更新:更新/添加到您的 css 文件中

    .btn{
        outline:none !important;
        }
    

    <!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.4/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
      <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    
    <style>
    .btn{
    outline:none !important;
    }
    </style>
    </head>
    <body>
    
    <div class="container">
      <button type="button" class="btn btn-primary" style="height: 34px; line-height: 16px; vertical-align:middle"><span style="font-size:30px;">&#8649;</span></button>  
    
     <button type="button" class="btn btn-primary" style=" line-height: 34px; vertical-align:middle"><span style="font-size:30px;">&#8649;</span></button>  
    </div>
    </body>
    </html>

【讨论】:

  • middle2 一个有效的vertical-align
  • 你能告诉我为什么我使用bootstrap时点击效果不大​​,在firefox中点击时我得到一些白色虚线边框
  • 你是指什么样的点击效果?我希望两者看起来都一样getbootstrap.com/css/#buttons
  • 在 Firefox 中,单击按钮时出现一些白色虚线边框
猜你喜欢
  • 2012-07-28
  • 2020-10-20
  • 2011-11-23
  • 2012-01-02
  • 1970-01-01
  • 2014-11-21
  • 2013-06-04
  • 2021-07-21
  • 2011-12-16
相关资源
最近更新 更多