添加形状为活动标签的箭头

时间:2013-01-12 14:52:23

标签: css twitter-bootstrap tabs

如何在活动标签下添加箭头形状?

.nav-tabs2 .active { background-image:url(http://www.asiarooms.com/assets/themes/v1/images/areas/details/menu-arrow.png); background-repeat:no-repeat; background-position:bottom center; }

http://jsfiddle.net/DJHZb/13/

<div class="box-head tabs">
  <ul class="nav2 nav-tabs2">
   <li class="active">
    <a href="#0" data-toggle="tab" class="firstelement">Active Tab</a></li>
   <li><a href="#1" data-toggle="tab">Inactive Tab</a></li>
   <li><a href="#2" data-toggle="tab">Inactive Tab #2</a></li>
  </ul>
</div>

3 个答案:

答案 0 :(得分:9)

看看“css讲话泡泡”的想法是一样的:http://nicolasgallagher.com/pure-css-speech-bubbles/demo

你必须弄乱伪css :: after和:: before(在某些IE中不起作用),并且边框创建一个彼此重叠的正方形或三角形。

示例:

.active::after {
content: "";
position: absolute;
bottom: -15px;
left: 50px;
border-width: 15px 15px 0;
border-style: solid;
border-color: #F3961C transparent;
display: block;
width: 0;
}

以下是如何使用框和边框创建三角形的说明:http://www.sitepoint.com/pure-css3-speech-bubbles/

答案 1 :(得分:1)

对于像这样的代码(使用bootstrap):

<body>
  <div class="panel panel-primary">
    <div class="panel-heading" style="font-size:large">
       Klujo
    </div>

    <div class="panel-body">
        <div class="wizard">
            <a >
                Step 1<br>
        Authorize the app
            </a>
            <a class="active">
                Step 2<br>
        Post your jobs
            </a>

        </div>
   </div>

  </div>
</body>

你可以使用这样的css:

.wizard a {
    background: #efefef;
    display: inline-block;
    margin-right: 5px;
    min-width: 150px;
    outline: none;
    padding: 10px 40px 10px;
    position: relative;
    text-decoration: none;
}

.wizard .active {
    background: #007ACC;
    color: #fff;
}

.wizard a:before {
    width: 0;
    height: 0;
    border-top: 25px inset transparent;
    border-bottom: 35px inset transparent;
    border-left: 20px solid #fff;
    position: absolute;
    content: "";
    top: 0;
    left: 0;
}

.wizard a:after {
    width: 0;
    height: 0;
    border-top: 35px inset transparent;
    border-bottom: 25px inset transparent;
    border-left: 21px solid #efefef;
    position: absolute;
    content: "";
    top: 0;
    right: -20px;
    z-index: 2;
}

.wizard a:first-child:before,
.wizard a:last-child:after {
    border: none;
}

.wizard a.active:after {
    border-left: 21px solid #007ACC;
}

获得所需的结果

答案 2 :(得分:0)

  </body>   
  <style>   
    .tool {
     position: relative;
     display: inline-block;
     border-bottom: 1px dotted red;
     }

   .tool .text {
    visibility: hidden;
    width: 100%;
    background-color: blue;
    color: white;
    text-align: center;
    border-radius: 5px;
    padding: 5px 0;
    position: absolute;

    top: -1px;
     left: 110%;
     }

    .tool .text::after {
     content: "";
      position: absolute;
      top: 10%;
      right: 99%;
       margin-top: -2px;
      border-width: 5px;
      border-style: solid;
      border-color: transparent blue transparent transparent;
      }
     .tool:hover .text {
     visibility: visible;
       }
     </style>   

     <div class="tool">Mouse Hover
      <span class="text">I Can pop up on the right side of these   words</div>
      </body>