0

Trying to create a "chat bubble" type of thing and here is my code. The little triangle is made via a pseudo element ::after but I can't make it show.

Any ideas what I am doing wrong?

 .playernamechat.self-message { width: auto; background-color: blue; border-radius: 12px; padding: 5px 10px; margin-left: 5px; display: inline-block; max-width: 280px; overflow: hidden; float: left; position: relative; color: white; } .self-message::after { content: ""; position: absolute; top: 50%; right: 100%; margin-top: -5px; border-width: 5px; border-style: solid; border-color: #555 transparent transparent transparent; }
 <span class="playernamechat self-message">hello</span> 

5
  • 4
    The issue is overflow: hidden; in the .playernamechat.self-message styling. The pseudo element is showing outside it, so this property is hiding it. Commented Feb 8, 2018 at 14:02
  • Is there a way to show it while keeping overflow: hidden. It is a chat bubble and I do not want it to overflow with text Commented Feb 8, 2018 at 14:03
  • Sorry, I don't think there's a way around that. Overflow will hide any content that's outside the constraints of the container. Commented Feb 8, 2018 at 14:04
  • You could change the position: absolute from :after with position: relative Commented Feb 8, 2018 at 14:06
  • 1
    @SWC instead of using overflow:hidden I used overflow-wrap: break-word which did the same thing but allowed me to have a regular overflow. If you havent already go comment your answer so I can upvote it! Commented Feb 8, 2018 at 14:15

1 Answer 1

2

Actually, it is showing but hidden. In your CSS remove overflow: hidden;. See below:

.playernamechat.self-message { width: auto; background-color: blue; border-radius: 12px; padding: 5px 10px; margin-left: 5px; display: inline-block; max-width: 280px; /*overflow: hidden;*/ float: left; position: relative; color: white; } .self-message::after { content: ""; position: absolute; top: 50%; right: 100%; margin-top: -5px; border-width: 5px; border-style: solid; border-color: #555 transparent transparent transparent; }
<span class="playernamechat self-message">hello</span>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.