I am trying to do a DIV with vertically aligned text and no scroll bar. After some research I found I have to do something like this for the vertical alignment:
.container {
height: 200px;
position: relative;
}
.vertical-center {
margin: 0;
position: absolute;
top: 50%;
transform: translateY(-50%);
overflow: hidden;
}
<div class="container">
<div class="vertical-center">
<p ng-dblclick="send({payload:true})">
TEXT
</p>
</div>
</div>
This works. I have then to add the overflow: hidden;
property and this I am not able to do. I tried several ways (like adding a third div between the twos with that property set) but always unable to achieve my goal.
EDIT: to clarify some of the questions I had. What I am trying to do is a small clickable text box. Width and height are fixed. My text might be longer than the width and/or might takes more lines than the height. So, I want the text always vertically centred and no scroll bar (nor x - nor y).
EDIT 2: the solution with flex works, it is what I was looking for. Thanks.
I hope it is clear.
Any help would be much appreciated. Thanks.