Bootstrap图标栏跨度不可见

时间:2017-07-15 06:51:09

标签: html css twitter-bootstrap

我正在开发一个项目,在做标题的时候,我找不到为什么下拉按钮中的span图标栏没有显示的原因:

这是代码的html,你必须在行中找到第三个div,里面有两个按钮:

<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/styles.css">
    <meta charset="UTF-8">
    <title>SoftHouse</title>
</head>
<body>
<div class="container">

    <nav class="navbar navbar-default">

        <div class="container">

            <div class="row">

            <div class="navbar-header col-lg-4">

                <a href="#" class="navbar-brand"><span class="wb"><span class="big">S</span>OFT</span><span class="big">H</span>OUSE</a>

            </div>

            <div class="nav-container col-lg-4">

            <ul class="nav nav-justified">
                <li>What</li>
                <li>Work</li>
                <li>About</li>
            </ul>

            </div>

            <div class="col-lg-4" style="text-align: center;">

                <button class="btn btn-sm">CONTACT</button>
                <button>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
            </div>



        </div>

    </div>

    </nav>

</div>


</body>
</html>

这是css

body
{
    margin:0;
    padding:0;
}

.navbar-default{
    border-radius: 0;
    background-color: white;
}

.wb
{
font-weight:bold;
}

.big
{
font-size: 25px;
}

.navbar-header .navbar-brand
{
font-size: 17px;
}

.icon-bar
{
    background-color: red;
    color:red;
}

.nav-justified
{
    line-height: 52px;
}

3 个答案:

答案 0 :(得分:0)

您只能为切换图标栏添加自举按钮类,如下所示:

请参阅Updated demo

<button type="button" class="navbar-toggle" data-toggle="collapse" data-
 target="Your class">
  <span class="icon-bar"></span>
  <span class="icon-bar"></span>
  <span class="icon-bar"></span>
</button>

CSS:

.btn-group-sm>.btn, .btn-sm {
    float: none;
}
.navbar-toggle {
    display: inline-block;
    float: none;
}

答案 1 :(得分:0)

你说:我希望图标栏始终显示,所以可以使用.WOFButton,不需要bootstarp图标:

Css:

after

<强> HTML

.btn-sm + span:after {
    content: '\2261';
    margin-left: 10px;
    font-size: 15px;
} 

<div class="col-lg-4" style="text-align: center;">
   <button class="btn btn-sm">CONTACT</button>
   <span><span><--------------Added
   <span class="icon-bar"></span><---------------Remove
   <span class="icon-bar"></span><---------------Remove
   <span class="icon-bar"></span><---------------Remove
</div>
body
{
    margin:0;
    padding:0;
}

.navbar-default{
    border-radius: 0;
    background-color: white;
}

.wb
{
font-weight:bold;
}

.big
{
font-size: 25px;
}

.navbar-header .navbar-brand
{
font-size: 17px;
}

.icon-bar
{
    background-color: red;
    color:red;
}

.nav-justified
{
    line-height: 52px;
} 

.btn-sm + span {
    border:1px solid #ccc;
    text-align:center;
    padding:5px 10px;
    cursor:pointer;
}

.btn-sm + span:hover {
 background-color:#ccc;
}

.btn-sm + span:after {
    content: '\2261';
    font-size: 15px;
}        

答案 2 :(得分:0)

使用font awesome

执行此操作

html代码: -

        <!DOCTYPE html>
        <head>
         <meta charset="UTF-8">
         <meta name="viewport" content="width=device-width, initial-scale=1">
         <title>SoftHouse</title>

         <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
         <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
         <link rel="stylesheet" type="text/css" href="css/style.css">

        </head>
        <body>
          <div class="container">

            <nav class="navbar navbar-default">

                <div class="container">

                    <div class="row">

                        <div class="navbar-header col-lg-4">

                            <a href="#" class="navbar-brand"><span class="wb"><span class="big">S</span>OFT</span><span class="big">H</span>OUSE</a>

                        </div>

                        <div class="nav-container col-lg-4">

                        <ul class="nav nav-justified">
                            <li>What</li>
                            <li>Work</li>
                            <li>About</li>
                        </ul>

                        </div>

                        <div class="col-lg-4" style="text-align: center;">

                            <button class="btn btn-sm">CONTACT</button>
                            <a class="icon-bar" href="#"><i class="fa fa-caret-down"></i></a>
                        </div>
                   </div>

               </div>

            </nav>

        </div>

        </body>
        </html>

在css中: -

.icon-bar { color: red; }