2016-07-26 7 views
-1

私が見つけたすべての質問は「コメントボックスの矢印」です。分割する三角形を添付

私はこの

enter image description here

のように見えるDIVをしたいのですが、私はdivのコンテナに二つの三角形を添付する必要がありますが、私はこれを行うするかどうかはわかりません。 http://codepen.io/anon/pen/yJEyOm

.expand { 
    width: 200px; 
} 

.expand:after { 
    content: " "; 
    width: 0; 
    height: 0; 
    border-style: solid; 
    border-width: 0 5px 5px 0; 
    border-color: transparent #007bff transparent transparent; 
} 

.expand:before { 
    content: " "; 
    width: 0; 
    height: 0; 
    border-style: solid; 
    border-width: 0 5px 5px 0; 
    border-color: transparent #007bff transparent transparent; 
} 

ここでの問題は、それのほんの一部、三角形が合計で示されていないことである。現在、私のコードは次のようになります。それを解決するには?

答えて

1

このようなもの:http://codepen.io/anon/pen/OXEPmB? 問題は疑似要素の位置です。

.expand { 
    width: 100px; 
    background-color: #007bff; 
    position: relative; 
    padding-left: 10px; 
} 

.expand:after { 
    content: " "; 
    width: 0; 
    height: 0; 
    border-style: solid; 
    border-width: 0px 0px 10px 10px; 
    border-color: #fff #fff #fff #007bff; 
    position: absolute; 
    right: 0; 
    bottom: 0; 
} 

.expand:before { 
    content: " "; 
    width: 0; 
    height: 0; 
    border-style: solid; 
    border-width: 0 10px 10px 0; 
    border-color: #fff #007bff #fff #fff; 
    position: absolute; 
    left: 0; 
    bottom: 0; 
} 
1

このコードを試してみてください。この

div{ 
 
    width:100%; 
 
    position:relative; 
 
    background:red; 
 
    height:20px; 
 
} 
 
div:before{ 
 
    content: ''; 
 
    display: block; 
 
    position: absolute; 
 
    bottom: -20px; 
 
    left: 50%; 
 
    transform:translate(-50%,0); 
 
    border-top: 23px solid red; 
 
    border-left: 16px solid transparent; 
 
    border-right: 16px solid transparent; 
 
    height: 0; 
 
    width: 50%; 
 
} 
 
span{ 
 
    display:block; 
 
    position:absolute; 
 
    left:50%; 
 
    transform:translate(-50%,0); 
 
    bottom:-20px; 
 
    font-size:20px; 
 
}
<div> 
 
    <span>Expand</span> 
 
</div>

0

を試してみてください。

.container{ 
 
    width: auto; 
 
    background-color: #007bff; 
 
    height:20px; 
 
} 
 

 
.expand { 
 
    position:absolute; 
 
    width: 85px; 
 
    height: 0px; 
 
    border-left: 20px solid transparent; 
 
    border-right: 20px solid transparent; 
 
    border-top: 20px solid #007bff; 
 
    margin-top:18px; 
 
    margin-left:25px; 
 
    
 
} 
 

 
.expand p{ 
 
    margin-top:-20px; 
 
    padding-left:12px 
 
    
 
}
<div class="container"> 
 

 
    <div> 
 
    <div class="expand"><p>expand</p></div>

0

これは、あなたが追加し、好きなカスタマイズTOTことができます。単にimgを追加してスペースをカスタマイズしてください。

<!DOCTYPE html> 
 
<html> 
 
<head> 
 
\t <meta charset="UTF-8"> 
 
\t \t <title>Insert title here</title> 
 
\t \t <style> 
 
\t \t \t a { text-decoration:none; } 
 
\t \t \t ul, ul li { margin:0; padding:0; } 
 
\t \t \t ul li { display:inline-block; } 
 
\t \t \t ul li a { background: url('navrepeater.png') repeat-x #efefef; line-height: 20px; display:inline-block; } 
 
\t \t \t ul li a:before, ul li a:after { 
 
\t \t \t \t content: ""; 
 
\t \t \t \t width: 30px; 
 
\t \t \t \t height: 30px; 
 
\t \t \t \t display: inline-block; 
 
\t \t \t \t vertical-align: middle; 
 
\t \t \t } 
 
\t \t \t ul li a:before { background: url('left.png') no-repeat #ccc; } 
 
\t \t \t ul li a:after { background: url('right.png') no-repeat #ccc; } 
 
\t \t </style> 
 
\t </head> 
 
\t <body> 
 

 
\t \t <ul> 
 
\t \t \t <li><a href="#">aaa</a></li> 
 
\t \t \t <li><a href="#">aaa</a></li> 
 
\t \t \t <li><a href="#">aaa</a></li> 
 
\t \t </ul> 
 

 
\t </body> 
 
</html>

関連する問題