2
I’m doing a mini chat, I’m having trouble when styling user conversations, my goal is to make the div
that will show the conversations does not get larger than your content, ie if the user only typed a word, it gets the size of that word, I’m having trouble with that, I have the div
father whose name is box_mensagem
and within that div
have the li
that will hold users' conversations, and within those li
have the div box_msg
that takes 100%
of div
which is the box_mensagem
and within that box_msg
finally got the div
that holds all my conversation is the div segura_msg
by default she has a float: left;
and to identify when I send the message I added the class eu
with a float: right;
, and that div
has a width: 400px;
that limits its size, and within it I have the div that shows the photo and the user’s message with the width: auto;
, only I’m having trouble with that, my message was to stay on the right, and the picture out of that div
with width: auto;
but when I give a negative margin in the photo, she ends up disappearing from div
, what I’m doing wrong ?
http://prntscr.com/j5dvm8
<style type="text/css">
.align_left {
float: left;
}
.box_mensagem {
width: 100%;
height: 100%;
overflow-x: hidden;
overflow-y: auto;
}
.box_mensagem::-webkit-scrollbar {
width: 0px;
}
.box_mensagem ul li .box_msg {
margin: 0 0 0.5em 0;
width: 570px;
height: 120px;
background-color: purple;
}
.box_mensagem ul li:last-child .box_msg {
margin: 0;
}
#chat #left #mensagem .box_mensagem ul li .box_msg .segura_msg {
float: left;
width: 400px;
height: 100%;
background-color: pink;
}
.box_mensagem ul li .box_msg .eu,
.box_mensagem ul li .box_msg .segura_msg .m_msg {
float: right;
}
.box_mensagem ul li .box_msg .segura_msg .mostra_msg {
float: left;
width: auto;
height: auto;
background-color: #ccc;
}
.box_mensagem ul li .box_msg .segura_msg img {
float: left;
width: 55px;
height: 55px;
}
</style>
<div class="box_mensagem align_left">
<ul>
<li><div class="box_msg">
<div class="segura_msg">
<div class="mostra_msg">
<img src="fotos/1.jpg" border="0">
aqui vem a primeira conversa do chat
</div>
</div>
</div></li>
<li><div class="box_msg">
<div class="segura_msg eu">
<div class="mostra_msg m_msg">
<img src="fotos/2.jpg" border="0">
aqui vem o usuário 02
</div>
</div>
</div></li>
</ul>
</div>
Your CSS only has
id
s#
but the HTML shown does not have 1 element with one of theseid
s.– Sam
css is showing all my structure, I will edit the question
– goio
now it’s better, but I can’t understand what you want to do...
– Sam
For example, the person who’s talking to me type, for example, "Okay?" , the div that shows the photo and the message that she wrote only takes the size of the message, and the photo gains a negative margin, to stay out of this div, and when I answer the same thing, only my div has to have a
float: right
did you understand ? adiv m_msg
I mean my message, I gave afloat: right
She just didn’t take– goio
similar to that friend, http://prntscr.com/j5ea89
– goio