我正在尝试解析一个大文本文件并使用手风琴文本效果显示所有文本。这是结果:
正如你所看到的,使用小文本就可以了,没问题,但是文字太大......它无法正常工作。
如何正确添加滚动效果或使框更大才能正确显示所有文字内容?
的jsfiddle: https://jsfiddle.net/jbfz09Ln/
代码:
HTML:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" lang="es-es">
<link rel="stylesheet" href="css/layout.css" type="text/css" media="screen">
<link rel="stylesheet" href="css/menu.css" type="text/css" media="screen">
<link rel="stylesheet" href="css/accordion.css" type="text/css" media="screen">
</head>
<body>
<!--Añadimos al area principal el efecto acordeon con el texto -->
<section class="mainArea" align="center">
<button class="accordion">Boot and Services</button>
<div id="placeholder" class="panelacc"></div>
</section>
<script>
/* nos permite gestionar los eventos para el texto en forma de acordeon */
var acc = document.getElementsByClassName("accordion");
for (var j = 0; j < acc.length; j++) {
acc[j].onclick = function(){
this.classList.toggle("active");
this.nextElementSibling.classList.toggle("show");
}
}
</script>
</body>
</html>
accordion.css:
button.accordion {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
transition: 0.4s;
}
button.accordion.active, button.accordion:hover {
background-color: #ddd;
}
button.accordion:after {
content: '\02795';
font-size: 13px;
color: #777;
float: right;
margin-left: 5px;
}
button.accordion.active:after {
content: "\2796";
}
div.panelacc {
padding: 0 18px;
background-color: white;
max-height: 0;
overflow: hidden;
transition: 0.6s ease-in-out;
opacity: 0;
}
div.panelacc.show {
opacity: 1;
max-height: 500px;
}
div.panelacc.show p {
color: black;
}
答案 0 :(得分:0)
我添加了一些css代码。这是你想要的吗?
class div.panelacc:
border:solid 1px green;
overflow-y:scroll;
overflow-x:hidden;
//max-width:200px; // set max width
class .mainArea:
height:100%;
class div.panelacc.show:
max-height: 100%;
答案 1 :(得分:0)
根据你的代码,你做错了两件事:
.mainArea{
height:300px; /* REMOVE this one */
border: 1px solid red;
}
/* AND */
div.panelacc.show {
opacity: 1;
max-height: 500px; /* HERE you are setting a fix height */
}
解决方案:移除height:300px;
行并将500px
更改为100%
,例如max-height: 100%;