HTML:
<?php
require ('Assests/connection/connection.php');
//iam retriving parent elements only
$query=mysqli_query($conn,"SELECT * from test where refid=".'0');
$tab_list='';
$tab_content='';
$i=0;
while($row=mysqli_fetch_array($query)){
if($i==0) {
//for the first parent element i am adding class as active
$tab_list .= '
<li class="active"><a href="#'.$row["id"].'" data-
toggle="tab">'.$row["name"].'</a></li>';
$tab_content .= '
<div id="'.$row["id"].'" class="tab-pane fade in active">';
}
else
{
//for remaining parents adding li class
$tab_list .= '
<li><a href="#'.$row["id"].'" data-
toggle="tab">'.$row["name"].'</a></li>';
$tab_content .= '
<div id="'.$row["id"].'" class="tab-pane fade">';
}
//i am passing the retrivedid
$test_query = "SELECT * FROM test WHERE refid =
'".$row["id"]."'";
$result = mysqli_query($conn, $test_query);
while($rows = mysqli_fetch_array($result))
{
//Adding the checkboxes for child elemens
$tab_content .=
"<li class='lichild'><input type='checkbox'
name='names[]'value='".
$rows['id'] ."'>".$rows['name'];
}
$tab_content .= '<div style="clear:both"></div></div>';
$i++;
}
?>
CSS:
<div class="rectangle">Some text</div>
答案 0 :(得分:3)
.rectangle {
width: 300px;
height: 80px;
border: 5px solid red;
border-right: none;
position: relative;
}
/* for the triangular shape */
.rectangle::after {
content: "";
position: absolute;
right:-45px;
bottom: 0;
top:-5px;
width: 0;
height: 0;
border-left: 45px solid red;
border-top: 45px solid transparent;
border-bottom: 45px solid transparent;
z-index:1000;
}
/* for hiding the portion except the border
of the triangle shape */
.rectangle::before {
content: "";
position: absolute;
right:-40px;
bottom: 0;
top:0;
width: 0;
height: 0;
border-left: 40px solid white;
border-top: 40px solid transparent;
border-bottom: 40px solid transparent;
z-index:1001;
}
<div class="rectangle">Some text</div>
如果您不需要类似边框的结构,则可以避免::before
部分并将背景颜色设置为主div。
.rectangle {
width: 300px;
height: 80px;
border: 5px solid red;
border-right: none;
position: relative;
background:red;
}
.rectangle::after {
content: "";
position: absolute;
right:-45px;
bottom: 0;
top:-5px;
width: 0;
height: 0;
border-left: 45px solid red;
border-top: 45px solid transparent;
border-bottom: 45px solid transparent;
}
<div class="rectangle">Some text</div>
有关更多形状,请参阅:CSS Tricks
答案 1 :(得分:1)
要仅保留边框而不填充div
,您可以尝试使用::before
和::after
。
这样的事情:
.rectangle {
width: 200px;
height: 40px;
position: relative;
border-top: 2px solid red;
border-bottom: 2px solid red;
border-left: 2px solid red;
-moz-border-radius: 3px 0 0 3px;
-webkit-border-radius: 3px 0 0 3px;
border-radius: 3px 0 0 3px;
margin-left: 50px;
}
.rectangle::after {
content: "";
position: absolute;
left: 100%;
width: 0;
height: 0;
top: 2px;
border-top: 18px solid transparent;
border-left: 10px solid #fff;
border-bottom: 17px solid transparent;
}
.rectangle::before {
content: "";
position: absolute;
left: 100%;
width: 0;
top: -2px;
height: 0;
border-top: 22px solid transparent;
border-left: 14px solid red;
border-bottom: 22px solid transparent;
}
<div class="rectangle">Some text</div>
答案 2 :(得分:1)
通过声明transform: rotate()
属性值来考虑转动伪元素,如下面嵌入的代码段所示。
作为实现声明border
属性规则的相同行为的替代方法,此方法允许仅使用一个伪元素以直观方式在元素上声明边框。
以这种方式旋转元素还可以选择用纯色填充元素 - 让您可以更自由地进行自定义。
代码段示范:
.rectangle {
width: 300px;
height: 80px;
border: 5px solid red;
/* additional */
border-right: 0;
box-sizing: border-box;
position: relative; /* required */
}
/* Additional */
.rectangle:after {
content: "";
position: absolute;
width: 55px;
height: 55px;
border-right: 5px solid red;
border-top: 5px solid red;
box-sizing: inherit;
right: -28px;
top: 7px;
transform: rotate(45deg);
}
&#13;
<div class="rectangle">Some text</div>
&#13;
答案 3 :(得分:0)
你必须使用伪类after
.rectangle {
position: relative;
width:200px;
height:40px;
margin-left:40px;
color:#FFFFFF;
background-color:red;
text-align:center;
line-height:40px;
}
.rectangle:after {
content:"";
position: absolute;
left: 100%;
top:0px;
width:0px;
height:0px;
border-top:20px solid transparent;
border-left:40px solid red;
border-bottom:20px solid transparent;
}
<div class="rectangle">Some text</div>
答案 4 :(得分:0)
#pointer {
width: 200px;
height: 40px;
position: relative;
background: red;
}
#pointer:after {
position: absolute;
left: 0;
bottom: 0;
width: 0;
height: 0;
border-left: 20px solid white;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
#pointer:before {
content: "";
position: absolute;
right: -20px;
bottom: 0;
width: 0;
height: 0;
border-left: 20px solid red;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
&#13;
<div id="pointer">
</div>
&#13;
答案 5 :(得分:0)
您可以使用:before
和:after
.rectangle {
width: 300px;
height: 80px;
border: 5px solid blue;
border-right: none;
position: relative;
}
.rectangle::before {
content: '';
border-top: 5px solid blue;
width: 120px;
position: absolute;
right: -115px;
bottom: 16px;
transform: rotate(-21deg);
}
.rectangle::after {
content: '';
border-top: 5px solid blue;
width: 120px;
position: absolute;
right: -115px;
top: 16px;
transform: rotate(21deg);
}
&#13;
<div class="rectangle">Some text</div>
&#13;