I want to make a button inside auto generated block to change overflow from hidden to auto.
I created recursive responsive auto-grid in Less, css like this:
.container {
.container-fixed();
[class*='col-'] {
float: right;
width: 100%;
}
.make-grid(@container-xs);
.make-grid(@container-sm);
.make-grid(@container-md);
.make-grid(@container-lg);
}
.container-fixed(@gap: @grid-gap-width) {
margin-right: auto;
margin-left: auto;
padding-left: (@gap / 2);
padding-right: (@gap / 2);
}
.generate-columns(@container-width;
@number-cols;
@i: 1) when (@i =< @number-cols) {
.col-@{i} {
@single-width: @container-width / @number-cols - 0.5;
width: @i * @single-width; // 800px
}
.generate-columns(@container-width;
@number-cols;
@i + 1);
}
.make-grid(@container-width) {
@media(min-width: @container-width) {
width: @container-width;
.generate-columns(@container-width, @grid-c);
}
}
[class*='col-'] {
text-align: center;
overflow: hidden;
height: 250px;
background: @color-h;
display: block;
margin: 1px;
color: @color-text;
position: relative;
}
And now I have long text in HTML inside one of blocks no matter which one, eg. col-9 where is part hidden because I used overflow:hidden;.
What I would like to do is to create a button and on click to change from overflow:hidden; to overflow: auto;.
My question is how to do that, to change from hidden to auto, on click and again to return back to previous state on new click.
I tried something like this but that is not good:
Less - >
[class*='col-'] {
text-align: center;
overflow: hidden;
height: 250px;
background: @color-h;
display: block;
margin: 1px;
color: @color-text;
position: relative;
.show {
overflow: auto;
}
}
JS - >
var content = document.getElementsByClassName("[class*='col-']");
var button = document.getElementbyID("show");
button.onclick = function() {
if (content.className == "show") {
content.className= "";
button.inerHTML = "Read";
} else {
content.className="show";
button.inerHTML = "Close";
}
};
html - >
<div class="col-9">
<a id="button-show">Read</a>
<script src="js/read.js"></script>
<p> some long text ........ </p>
</div>
I hope I am clear enough, what I want to do.