Reputation: 37
I was wondering if there was a way I could have two divs/spans in the same column and have an adequate space in between.
End goal:
What I currently have:
With Text Count:
HTML:
<div class="emoji-text-container">
<textarea type="text" class="text-area form-control" maxlength="279" formControlName="twitterText">
</textarea>
<button #toggleEmojiTwitter class="emoji-button mt-2 mr-2" type="button" (click)="_isTwitterEmojiPickerVisible = !_isTwitterEmojiPickerVisible"><mdb-icon class="emoji-icon" far icon="smile"></mdb-icon></button>
<span class="text-count" [hidden]="_isTwitterEmojiPickerVisible">
<span>{{_twitterCharLimit - this._postsForm.get('twitterText').value.length}}</span>
</span>
</div>
CSS:
//Emoji and Text Count
.emoji-container,
.emoji-text-container {
display: flex;
justify-content: center;
align-items: start;
margin: auto;
border: 1px solid #d9d7d8;
}
.text-area {
min-height: 15rem;
border: 0;
resize: none;
outline: none;
border: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
.emoji-button {
border-radius: 25px;
width: 45px;
height: 30px;
border: 1px solid #c8c8c8;
font-size: 20px;
background: transparent;
cursor: pointer;
&:focus {
outline: 0;
}
}
.emoji-icon {
color: #9a9696;
}
.text-count {
font-size: 14px;
border-radius: 25px;
background-color: #f4f2f2;
width: 3rem;
height: 12%;
padding-top: 4px;
font-weight: bold;
color: #8e8d8d;
border: 1px solid #c8c8c8;
text-align: center;
}
Upvotes: 2
Views: 183
Reputation: 17566
The simple skeleton for your issue would be look like below. Two approaches: 1: flex with position and 2) only flex.
It think you looking for the second one.
.w {
border: 1px solid black;
display: flex;
min-height:200px;
}
.left {
width:100%;
border: 1px solid black;
}
.right {
width:70px;
}
.icons {
position:relative;
height:100%;
width:100%;
}
.top, .bottom {
position:absolute;
}
.top {
top:0;
}
.bottom {
bottom:0;
}
<div class="w">
<div class="left">1</div>
<div class="right">
<div class="icons">
<div class="top">top</div>
<div class="bottom">buttom</div>
</div>
</div>
</div>
I use flex box and the position top and bottom for the icons.
.w {
border: 1px solid black;
display: flex;
min-height:200px;
}
.left {
width:100%;
border: 1px solid black;
}
.right {
width:70px;
}
.icons {
height:100%;
display: flex;
flex-direction: column;
justify-content: space-between;
background: gray;
flex-wrap: nowrap;
}
<div class="w">
<div class="left">1</div>
<div class="right">
<div class="icons">
<div class="top">top</div>
<div class="bottom">buttom</div>
</div>
</div>
</div>
Upvotes: 1
Reputation: 1581
you can use flex for the same, first group those two buttons like
<div class="btnGp">
<button #toggleEmojiTwitter class="emoji-button mt-2 mr-2" type="button" (click)="_isTwitterEmojiPickerVisible = !_isTwitterEmojiPickerVisible"><mdb-icon class="emoji-icon" far icon="smile"></mdb-icon></button>
<span class="text-count" [hidden]="_isTwitterEmojiPickerVisible">
<span>{{_twitterCharLimit - this._postsForm.get('twitterText').value.length}}</span>
</span>
</div>
.btnGp{
display : flex;
justify-content : space-between;
flex-direction : column;
height : 100%;
}
by this way it comes up and down, but it does not go to the bottom, why ? because it has 100% height but cant expand, why it cant expand ? because percentage is the relative quantity and the parent does not have any height so add
.emoji-text-container{
// a size of your choice
}
and remove the min height from text-box
and add height 100% to it
Upvotes: 1
Reputation: 640
The easiest setup will be to wrap your smiley and count elements in additional flex wrapper, like so:
.container {
display: flex;
}
.textarea {
height: 100px;
}
.sidebar {
display: flex;
justify-content: space-between;
flex-direction: column;
}
<div class="container">
<textarea class="textarea"></textarea>
<div class="sidebar">
<div class="smile">😅</div>
<div class="text">12</div>
</div>
</div>
Upvotes: 2
Reputation: 1
you can try this
.emoji-text-container --- position:relative;
.text-count --- position:absolute;
after this you can move "text count" using bottom:0; right:0;
Upvotes: 0