Problems with flex elements in chatbox widget (Streamlabs)

23 Views Asked by At

Good timezone everybody, i have been working on a CSS code for a chatbox widget for the first time and i got stuck in a problematic situation.

My ideal outcome is that, the heart shaped "buttom" and line divisor stay always to the left. As far i got it using flex elements but the problem it raised later was that when a word is too long, it overflow pushing everything out of the container.

I have tried many things but it always fix one problem and made another, I tried controlling the overflow using brea-word, what now breaks even the smaller word like "hey" or generate a second line when i detects more than 3 words.

I share pictures of some errors i got

Without word-break: break-word

With word-break: break-word

Is there a way, the decorations can stay always to the left while the message div doesn't reduce too much its own space or cut weirdly the words?

I put the code i am using, it is for streamlabs.

Adjunt a Stackblitz

https://stackblitz.com/edit/stackblitz-starters-nxe5cq?file=index.html

The CSS

/* GLOBAL BOX */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap');

*{
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

/* BODY */

body {
  font-family: 'Montserrat';
  font-weight: 700;
  line-height: 1.5em;
}

/* MESSAGE CONTAIN */

#log>div {
  animation: fadeInUp 0.4s ease-in-out forwards, fadeOut 0.25s ease {message_hide_delay};
  -webkit-animation: fadeInUp 0.4s ease-in-out forwards, fadeOut 0.25s ease {message_hide_delay};
  padding-bottom: 10px;
}

.colon {
  display: none;
}

#log{
  display: table;
  position: absolute;
  table-layout: fixed;
    bottom: 0;
    left: 0;
    padding: 0 10px 10px;
  width: 100%;
}

#log>div{
  display: block;
}

#log>div .deleted{
  visibility: hidden;
}

/* EMOTES PROPERTIES */

#log .emote {
  position: relative;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background: #F0F0F0;
  padding: 0.4em 0.2em;
}

#log .emote img {
   display: inline-block;
   height: 1em;
   opacity: 0;
}

/* MESSAGE PROPERTIES */

#log .meta,#log .message {
  display: block;
  vertical-align: left;
}

.badge {
  display: none;
}

#log .meta {
  z-index: 1;
  position: relative;
  background: #FF4E6B;
  width: fit-content;
  border-radius: 15px;
  font-size: 20px;
  text-transform: uppercase;
  text-align: center;
  padding: 10px 20px;
  margin-top: -2px;
}

#log .name{
  color: #FFFFFF;
}

.container{
  display: flex;
  width: 100%;
  column-gap: 20px;
  margin: -20px 0px 0px 20px;
}

.thread {
  border: none;
  border-left: 7.5px dotted #FF4E6B;
  margin-top: 2.5px;
}

.message-container {
  z-index: 0;
  display: flex;
  width: 90%;
}

#log .message {
  display: flex;
  background: #FFF2F2; 
  min-width: 40%;
  max-width: 90%;
  padding: 20px 20px 20px 20px;
  border: 5px solid #FF4E6B;
  outline: 2px solid #FF4E6B;
  outline-offset: 5.5px;
  border-radius: 25px;
  margin-bottom: 15px;
  color: #FF4E6B;
  font-size: 20px;
  text-align: justify;
  word-break: break-word;
 }

.separator {
  width: 100%;
  flex: 1 0 fill;
  background: blue;
}

.divisor {
  display: flex;
  flex: 0 0 40px;
  background: green;
  border-left: 5px dotted #FF7F95;
  align-items: center;
  justify-content: center;  
}

.heart01{
  position: absolute;
  margin: -20px 0px 0px 16px;
}

.heart01::before, .heart01::after {
  position: absolute;
  content: "";
  background: #FF7F95;
  height: 20px;
  width: 12.5px;
  border-radius: 20px 20px 0px 0px;
}

.heart01::before {
  transform: rotate(-45deg);
  transform-origin: 0 100%;
}

.heart01::after {
  transform: rotate(45deg);
  transform-origin: 100% 100%;
  margin-left: -12px;
}

.heart02{
  position: absolute;
  margin: -17px 0px 0px 16px;
}

.heart02::before, .heart02::after {
  position: absolute;
  content: "";
  background: #FFF2F2;
  height: 14px;
  width: 6.5px;
  border-radius: 20px 20px 0px 0px;
}

.heart02::before {
  transform: rotate(-45deg);
  transform-origin: 0 100%;
}

.heart02::after {
  transform: rotate(45deg);
  transform-origin: 100% 100%;
  margin-left: -5.5px;
}

The HTML

<!-- item will be appened to this layout -->
<div id="log" class="sl__chat__layout">
</div>

<!-- chat item -->
<script type="text/template" id="chatlist_item">
  <div data-from="{from}" data-id="{messageId}">
    <span class="meta">
      <span class="badges"></span>
      <span class="name">{from}</span>
      </span>
    <span class="container">  
      <span class="thread"></span>
      <span class="message-container">
        <span class="message">{message}
          <span class="separator"></span>
          <span class="divisor">
            <span class="heart01"></span>
            <span class="heart02"></span>
          </span>
        </span>
      </span>
    </span>
  </div>
</script>
0

There are 0 best solutions below