2017-04-13 40 views
1

我使用jQuery此選項卡菜單,所有的工作,但是我想保持標籤標題圓角當內容DIV被關閉,但是當其他選項卡關閉選項卡標題仍然留有左下和右側直線邊緣: enter image description hereCSS標籤菜單從這個圖像保持圓角時關閉標籤

正如您所看到的,封閉的選項卡在底部仍有明顯的邊緣。有沒有一種方法是CSS,我可以設置圓角來關閉標籤時返回?

這裏是我當前的代碼:

$(document).ready(function() 
 
{ 
 

 
    $("#myaccountSettings").accordion(
 
    { 
 
    heightStyle: "content" 
 
    }); 
 

 
});
#myaccountSettings h3 
 
{ 
 
    color: #a2a2a2; 
 
    background-color: #222222; 
 
    margin: 0; 
 
    margin-left: 3px; 
 
    margin-right: 3px; 
 
    padding: 8px; 
 
    border-radius: 4px 4px 0 0; 
 
    outline: none; 
 
} 
 

 
#myaccountSettings h3:hover 
 
{ 
 
    cursor: pointer; 
 
    color: #C33917; 
 
} 
 

 
#myaccountSettings h3:not(:first-child) 
 
{ 
 
    margin-top: 10px; 
 
} 
 

 
.accountTabContentWrapper 
 
{ 
 
    margin: 0; 
 
    margin-left: 3px; 
 
    margin-right: 3px; 
 
    padding: 8px; 
 
    background-color: #676464; 
 
    border-radius: 0 0 4px 4px; 
 
    color: #d6cbc9; 
 
} 
 

 
.accountTabContentWrapper h1 
 
{ 
 
    margin-top: 0; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 
 

 
<div id="myaccountSettings"> 
 

 
    <h3>General</h3> 
 
    <div class="accountTabContentWrapper"> 
 

 
    <h1>Hello, @username</h1> 
 

 
    
 

 
    </div> 
 

 
    <h3>Email & Password</h3> 
 
    <div class="accountTabContentWrapper"> 
 

 
    </div> 
 

 
    <h3>Delete My Account</h3> 
 
    <div class="accountTabContentWrapper"> 
 

 
    </div> 
 

 
    <!--<h3>Section 3</h3> 
 
    <div class="accountTabContentWrapper"> 
 

 
    </div>--> 
 

 
</div>

+0

,而不是'#myaccountSettings H3 {邊界半徑:4PX遞四方0 0; }'只需使用'border-radius:4px'?你在做什麼? –

回答

1

$(document).ready(function() { 
 

 
    $("#myaccountSettings").accordion({ 
 
    heightStyle: "content" 
 
    }); 
 
    $(".headers").click(function() { 
 
    current_head = this; 
 
    //$(current_head).css("border-radius","0px"); 
 
    $(current_head).css("border-top-left-radius", "5px"); 
 
    $(current_head).css("border-top-right-radius", "5px"); 
 
    $(current_head).css("border-bottom-right-radius", "0px"); 
 
    $(current_head).css("border-bottom-left-radius", "0px"); 
 
    //$(current_head).css("border-top-right-radius","0px"); 
 
    $(".headers").each(function() { 
 
     if (!$(this).hasClass("ui-state-active") && this != current_head) { 
 
     $(this).css("border-radius", "10px"); 
 
     console.log(this.innerHTML) 
 
     } 
 
    }) 
 

 
    }) 
 
    //trigger a click on first header when window onload to initiate the styling 
 
$(".headers")[0].click() 
 
});
#myaccountSettings h3 { 
 
    color: #a2a2a2; 
 
    background-color: #222222; 
 
    margin: 0; 
 
    margin-left: 3px; 
 
    margin-right: 3px; 
 
    padding: 8px; 
 
    border-radius: 4px 4px 0 0; 
 
    outline: none; 
 
} 
 

 
#myaccountSettings h3:hover { 
 
    cursor: pointer; 
 
    color: #C33917; 
 
} 
 

 
#myaccountSettings h3:not(:first-child) { 
 
    margin-top: 10px; 
 
} 
 

 
.accountTabContentWrapper { 
 
    margin: 0; 
 
    margin-left: 3px; 
 
    margin-right: 3px; 
 
    padding: 8px; 
 
    background-color: #676464; 
 
    border-radius: 0 0 4px 4px; 
 
    color: #d6cbc9; 
 
} 
 

 
.accountTabContentWrapper h1 { 
 
    margin-top: 0; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 
 

 
<div id="myaccountSettings"> 
 

 
    <h3 class="headers">General</h3> 
 
    <div class="accountTabContentWrapper"> 
 

 
    <h1>Hello, @username</h1> 
 

 

 

 
    </div> 
 

 
    <h3 class="headers">Email & Password</h3> 
 
    <div class="accountTabContentWrapper"> 
 

 
    </div> 
 

 
    <h3 class="headers">Delete My Account</h3> 
 
    <div class="accountTabContentWrapper"> 
 

 
    </div> 
 

 
    <!--<h3>Section 3</h3> 
 
    <div class="accountTabContentWrapper"> 
 

 
    </div>--> 
 

 
</div>

+0

我想保留這個純粹的CSS,所以最後我只用了top:-2px;並將該位置設置爲相對於.accountTabContentWrapper。但是你的答案也行得通,所以這就是我接受它的原因。乾杯。 – Erdss4