20

私はこのようにする必要があります。純粋なCSSで可能ですか?

ここに画像の説明を入力

4

5 に答える 5

7

CSS3 では、 を使用border-radiusしてタブの角を湾曲させ、下側の で三角形を作成しますz-index

HTML:

<div class="tab">
    <div class="arrow"></div>
</div>

CSS:

body
{
    background-color: #666;    
}
.tab
{
    height: 50px;
    width: 150px;
    border-radius: 10px 10px 0px 0px;
    background-color: #FFF;
    position: relative;
}

.arrow
{
  border-color: transparent transparent #FFF #FFF;
  border-style: solid;
  border-width: 23px 23px 23px 23px;
  height:0;
  width:0;
  position:absolute;
  bottom:0px;
  right:-43px;
}

結果: http://jsfiddle.net/P3P3Z/2/

これは完全ではなく、ブラウザーによってレンダリングが異なる可能性がありますが、開始する必要があります。:) 見栄えを良くするために、いくつかの点を少し調整する必要があります。

于 2012-01-17T13:51:12.033 に答える
2

この質問は私に興味をそそったので、ここに実例があります。

<html>

<style type="text/css">

body {
    background: #000000;
    }
#header {
    height: 29px;
    overflow: hidden;
    }
#content {
    background: #ffffff;
    min-height: 200px;
    padding: 10px;
    border-top-right-radius: 10px;
    border-top-right-radius: 10px;
    }

#on {
    background: #ffffff;
    display: inline-block;
    padding: 5px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    vertical-align: top;
    }

#off {
    background: #888888;
    display: inline-block;
    padding: 5px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    vertical-align: top;
    margin-left: -40px;
    }

#seperatoron {
    border: none;
    border-left: 25px solid white;
    border-bottom: 0px;
    height: 0px;
    width: 0px;
    display: inline-block;
    position: relative;
    margin-top: 10px;
    border-right: 25px solid transparent;
    border-top: 25px solid transparent;
    margin-top: 4px;
    margin-left: -2px;
    }

#seperatoroff {
    border: none;
    border-left: 25px solid #888888;
    border-bottom: 0px;
    height: 0px;
    width: 0px;
    display: inline-block;
    position: relative;
    margin-top: 10px;
    border-right: 25px solid transparent;
    border-top: 25px solid transparent;
    margin-top: 4px;
    margin-left: -2px;
    }

</style>


<body>

<div id="header">
<div id="on">Tab 1</div><div id="seperatoron"></div>
<div id="off">Tab 2</div><div id="seperatoroff"></div>
</div>

<div id="content">

Document content section.

</div>

</body>
</html>
于 2012-01-17T14:26:25.823 に答える
1

左上隅の丸い境界線は、border-radius プロパティで可能です (古い IE バージョンにはありません)。ただし、各タブの右側は、画像、svg、または css3 変換を使用して回転された div で行う必要がありますが、それは確かに頭痛の種になります。

私があなただったら、左上の境界線半径と右に配置された背景画像を選びます。

border-top-left-radius: 10px;
background: white url(tab.gif) right top no-repeat;

2 番目のタブにも負の margin-left を指定する必要があると思います。

于 2012-01-17T13:51:15.477 に答える
0

cssを使用したウィンドウタイプのタブボタンは次のとおりです

.tablist{
    padding:0;
    margin:0;
    list-style:none;
    display:flex;
    justify-content:center;
}
.tablist>li{
}
.tablist >li>a{
    position: relative;
    display: block;
    color: red;
    text-decoration: none;
    line-height: 1.4;
    border-top: 1px solid red;
    border-radius: 6px 6px 0 0;
    padding: 3px 10px;
    margin: 0 5px;
}
.tablist >li>a:before{
    position: absolute;
    content: "";
    width: 9px;
    height: 29px;
    background: white;
    transform: rotate(21deg);
    border-left: 1px solid red;
    left: -5px;
    top: 2px;
    z-index: -1;
    border-radius: 2px 0 0 0px;

}
.tablist >li>a:after{
    position: absolute;
    content: "";
    width: 9px;
    height: 29px;
    background: white;
    transform: rotate(-21deg);
    border-right: 1px solid red;
    right: -5px;
    top: 2px;
    z-index: -1;
    border-radius: 2px 0 0 0px;

}

そして、htmlは次のようになります

<ul class="tablist">
<li><a href="jasscript:void(0)">Home</a></li>
<li><a href="jasscript:void(0)">About</a></li>
<li><a href="jasscript:void(0)">Contact us</a></li>
<li><a href="jasscript:void(0)">Blog</a></li>
<li><a href="jasscript:void(0)">Home</a></li>
</ul>
于 2016-05-28T19:56:36.957 に答える