我已經創建了HTML和CSS,看起來是這樣的: https://jsfiddle.net/jw7pfb1w/的onClick行動,以顯示更多的信息,HTML,CSS,JavaScript的
正如你所看到的,我在高度做那些盒子300像素,但我有更多的信息,這是與overflow: hidden;
隱藏。現在我創建了一個按鈕
//html
<a id="show-more" class="show">Show More</a>
/css
.show {
display: block;
background-color: #75868E;
width: 100px;
font-size: 12px;
text-transform: uppercase;
display: inline-block;
margin: 20px auto;
cursor: pointer;
height: 15px;
padding: 10px 0;
}
現在我想在點擊按鈕時看到這三個框中的所有信息。我想是這樣的
我已將此添加CSS:
#model1.open {
max-height: 1000px;
//transitions
-webkit-transition: max-heigth 0.7s;
-moz-transition: max-heigth 0.7s;
transition: max-heigth 0.7s;
}
,這給JavaScript
var content = document.getElementByClassName(".model1");
var button = document.getElementById("show-more")
button.onclick = function(){
if(content.className == "open"){
content.className = "";
button.innerHTML = "Show More";
} else {
content.className = "open";
button.innerHTML = "Show Less";
}
};
但does'not工作。我被卡住了。有人可以幫我做這項工作嗎?