如此正确地获取这些标签很麻烦

时间:2013-12-22 04:16:18

标签: html css css3 css-shapes

我正在尝试用纯粹的css3 / html创建带有倒圆角的标签。

Tabs

我似乎无法做对。我已经尝试了各种解决方案,即使是这个jquery:http://jquery.malsup.com/corner/我也无法看到标签在图像中的显示方式。我不得不使用图像吗?

HTML

<div class="menu">
    <div class="outer_bg_left">
        <div class="outer">
            <div class="outer_shadow">
            </div>
        </div>    
    </div>

    <ul>
       <li class="menu_item_cont"><div class="menu_item">Item 1</div></li>
       <li class="menu_item_cont"><div class="menu_item">Item 2</div></li>
       <li class="menu_item_cont"><div class="menu_item">Item 3</div></li>
    </ul>

    <div class="outer_bg_right">
       <div class="outer">
          <div class="outer_shadow">
          </div>
       </div>   
    </div>
 </div>

CSS

.outer_bg_left, .outer_bg_right {
    float: left;
    width: 70px;
    background-color: #994;
    height: 15px;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.outer_bg_left .outer {
    height: 25px;
    border-radius:  0 10px 0 0; 
    background-color: #fff;
}

.outer_bg_right .outer {
    height: 25px;
    border-radius:  10px 0 0 0;
    background-color: #fff;
}

.outer_bg_left .outer_shadow, .outer_bg_right .outer_shadow {
    box-shadow:  0 0 5px 2px rgba(0,0,0, .7) inset;
    padding-bottom: 10px;
    margin-bottom: -10px;
    height: 25px;
}

.outer_bg_left .outer_shadow {
    border-radius: 0 10px 0 0;
    padding-left: 30px;
    margin-left: -30px;
}

.outer_bg_right .outer_shadow {
    border-radius:  10px 0px 0 0;
    padding-right: 30px;
    margin-right: -30px;
}

.menu_item_cont {
    background-color: #994;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 0 5px 2px rgba(0,0,0, .7);
    background-color: #994;
    display: block;
    float: left;
}

.menu_item {    
    border-radius: 0 0 10px 10px; 
    background-color: #994;
    height: 20px;
    padding: 5px 10px;

    font-family: Arial;
    line-height: 20px;
    font-size: 14px;
    font-weight: bold;
}

.menu_item:hover {
    background-color: #000;
    border-radius: 10px;
    height: 30px;
    line-height: 30px;
    color: #fff;
}

1 个答案:

答案 0 :(得分:2)

<强> HTML

<ul class="tabs group">
  <li class="active"><a href="#one">Tab 1</a></li> 
  <li><a href="#two">Tab 2</a></li> 
  <li><a href="#three">Tab 3</a></li>
  <li><a href="#three">Tab 4</a></li> 
</ul>

CSS

   .tabs { 
        list-style: none; 
        margin: 60px auto 0; 
        width: 660px;
    }
        .tabs li { 
          /* Makes a horizontal row */
            float: left; 

            /* So the psueudo elements can be
               abs. positioned inside */
            position: relative; 
        }
        .tabs a { 
          /* Make them block level
             and only as wide as they need */
          float: left; 
          padding: 10px 40px; 
          text-decoration: none;

          /* Default colors */ 
          color: black;
          background: #ddc385; 

          /* Only round the top corners */
          -webkit-border-top-left-radius: 15px;
          -webkit-border-top-right-radius: 15px;
          -moz-border-radius-topleft: 15px;
          -moz-border-radius-topright: 15px;
          border-top-left-radius: 15px;
          border-top-right-radius: 15px; 
        }
        .tabs .active {
          /* Highest, active tab is on top */
          z-index: 3;
        }
        .tabs .active a { 
          /* Colors when tab is active */
          background: black; 
          color: white; 
        }
        .tabs li:before, .tabs li:after, 
        .tabs li a:before, .tabs li a:after {
          /* All pseudo elements are 
             abs. positioned and on bottom */
          position: absolute;
          bottom: 0;
        }
        /* Only the first, last, and active
           tabs need pseudo elements at all */
        .tabs li:last-child:after,   .tabs li:last-child a:after,
        .tabs li:first-child:before, .tabs li:first-child a:before,
        .tabs .active:after,   .tabs .active:before, 
        .tabs .active a:after, .tabs .active a:before {
          content: "";
        }
        .tabs .active:before, .tabs .active:after {
          background: black; 

          /* Squares below circles */
          z-index: 1;
        }
        /* Squares */
        .tabs li:before, .tabs li:after {
          background: #ddc385;
          width: 10px;
          height: 10px;
        }
        .tabs li:before {
          left: -10px;      
        }
        .tabs li:after { 
          right: -10px;
        }
        /* Circles */
        .tabs li a:after, .tabs li a:before {
          width: 20px; 
          height: 20px;
          /* Circles are circular */
          -webkit-border-radius: 10px;
          -moz-border-radius:    10px;
          border-radius:         10px;
          background: #fff;

          /* Circles over squares */
          z-index: 2;
        }
        .tabs .active a:after, .tabs .active a:before {
          background: #ddc385;
        }
        /* First and last tabs have different
           outside color needs */
        .tabs li:first-child.active a:before,
        .tabs li:last-child.active a:after {
          background: #fff;
        }
        .tabs li a:before {
          left: -20px;
        }
        .tabs li a:after {
          right: -20px;
        }

.group:before,
.group:after {
    content: "";
    display: table;
}
.group:after {
    clear: both;
}
.group {
    zoom: 1;
}

小提琴 http://jsfiddle.net/raunakkathuria/VLE9K/

我按照此示例进行了修改,并根据您的要求http://css-tricks.com/tabs-with-round-out-borders/

进行了修改

您也可以尝试此http://webdesign.about.com/od/layout/ss/css-3-tabs.htm