默認情況下,我的網頁的左側容器上有一個手風琴。我使用CSS來對齊它的中心。我嘗試在CSS代碼中使用position:center,align:left和margin-left:5px,但這些都不起作用。誰能幫我嗎。提前致謝。如何在CSS中對齊手風琴?
這裏是我的CSS代碼:
var acc_leftpanel = document.getElementsByClassName("accordion_leftpanel");
var i;
for (i = 0; i < acc_leftpanel.length; i++) {
acc_leftpanel[i].onclick = function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight) {
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + 'px';
}
}
}
button.accordion_leftpanel {
background-color: #2da0d9;
color: #444;
cursor: pointer;
padding: 5px;
width: 60%;
border: none;
align: center;
text-align: center;
outline: none;
font-size: 12px;
transition: 0.4s;
border-radius: 25px;
}
button.accordion_leftpanel.active,
button.accordion_leftpanel:hover {
background-color: #5ebb61;
}
button.accordion_leftpanel:after {
color: #ffffff;
font-weight: bold;
float: center;
margin-left: 8px;
}
<div class="leftcontentborder">
<p align="center">LIST OF SOLVED PAPERS</p>
<button class="accordion_leftpanel" align="center">June 2014</button>
<div class="panel">
<p>Paper 2</p>
<p>Paper 3</p>
</div>
</div>
http://stackoverflow.com/q/10751266/7012517......this可以幫助你 – Shobhit
嗯......你可以改變擋住元素,然後設置一個固定的寬度,所以你可以使用:''margin:0 auto;'' –
男孩,你的佈局需要一個網格系統... –