全部打开手风琴/全部打印

时间:2017-11-20 23:24:28

标签: javascript html css button accordion

我已经把一个带有手风琴功能的页面放在一起,所以页面不会太长,现在当我想要打印页面时,它只会打印打开的部分,我希望打开所有按钮或打印全部按钮已实现,非常感谢任何帮助!

有人可以帮忙吗?

var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
  acc[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 {
  background-color: #13294b;
  border: 2px solid #59cbe8;
  border-radius: 0px 10px 0px 10px;
  box-shadow: 7px 7px 5px #cccccc;
  color: #fff;
  cursor: pointer;
  padding: 10px 15px 10px 15px;
  margin: 4px 0px 7px 0px;
  width: 100%;
  font-size: 18px;
  transition: 0.4s;
  outline: none;
  text-align: left;
}

button.accordion.active,
button.accordion:hover {
  background-color: #1f447b;
}

button.accordion:after {
  content: '\002B';
  color: #59cbe8;
  font-weight: bold;
  float: right;
}

button.accordion.active:after {
  content: "\2212";
}

div.panel {
  padding: 0 18px;
  background-color: white;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease-out;
}
<button class="accordion">Title 1</button>
<div class="panel">content</div>

<button class="accordion">Title 2</button>
<div class="panel">content</div>

0 个答案:

没有答案