I'm doing a message app with html js and php, but the css of the messages does something I don't uderstand : basically the width of the p isn't the with of the text but the max-width of the parent element here's the image of what happens : messages
i've tried multiple things, like assigning a static width but the width should change with the text, the php output is put in the chat-box with jquery
.chat-area header {
display : flex;
align-items : center;
padding : 18px 30px;
}
.chat-box {
height : 500px;
background : #f7f7f7;
padding : 10px 30px 20px 30px;
box-shadow : inset 0 32px 32px -32px rgb(0 0 0 / 5%),
inset 0 -32px 32px -32px rgb(0 0 0 / 5%);
overflow-y : auto;
}
.chatbox .chat {
margin : 15px 0;
}
.chatbox .chat p {
word-wrap : break-word;
padding : 8px 16px;
}
.chatbox .outgoing {
display : flex;
}
.chatbox .incoming {
display : flex;
}
.outgoing .details {
margin-left : auto;
max-width : calc(100% - 130px);
margin-right : 10px;
}
.outgoing .details p {
margin-left : auto;
position : relative;
background : #333;
color : #fff;
padding : 10px;
border-radius : 18px 18px 0px 18px;
margin-bottom : 10px;
}
.incoming .details {
margin-left : 10px;
margin-right : auto;
max-width : calc(100% - 130px);
}
.incoming .details p {
color : #333;
background : #fff;
border-radius : 18px 18px 18px 0px;
padding : 10px;
margin-bottom : 10px;
}
<section class="chat-area" style="width : 100%">
<header>
<i class="fas fa-arrow-left" id="goBackToSearch"></i>
<div class="content">
<div class="details">
<span id="CalledName">Admin</span>
<p>Active Now</p>
</div>
</header>
<div class="chat-box">
</div>
<form action="#" class="typing-area" autocomplete="off">
<input type="text" class= "input-field" placeholder="Scrivi un messaggio...">
<button><i class='bx bxs-caret-right-circle' ></i>
</form>
</section>
$query = "
SELECT *
FROM messages
WHERE outgoing_msg_id = :outgoing_id AND incoming_msg_id = :incoming_id
OR outgoing_msg_id = :incoming_id2 AND incoming_msg_id = :outgoing_id2
";
$output = "";
$check = $pdo->prepare($query);
$check->bindParam(':outgoing_id', $outgoing_id, PDO::PARAM_STR);
$check->bindParam(':outgoing_id2', $outgoing_id, PDO::PARAM_STR);
$check->bindParam(':incoming_id', $id, PDO::PARAM_STR);
$check->bindParam(':incoming_id2', $id, PDO::PARAM_STR);
$check->execute();
$messages = $check->fetchAll(PDO::FETCH_ASSOC);
for($i=0;$i<$check->rowCount();$i++){
if ($messages[$i]["outgoing_msg_id"] == $outgoing_id){ //he is a message sender
$output .= '<div class="chat outgoing">
<div class="details">
<p>'.$messages[$i]["msg"].'</p>
</div>
</div>';
} else if ($messages[$i]["outgoing_msg_id"] == $id) { //he is a message receiver
'<div class="chat incoming">
<div class="details">
<p>'.$messages[$i].'</p>
</div>
</div>';
}
}
echo $output;
Related
How can I fix the problem when zooming in and out(e.g. 80%) the checked radio button is slightly changing the position of the dot in the radio button?
Tried position fixed but it didn't help.Something to do with width and height probably but I can't figure out.
This is how it looks after zooming out
input[type="radio"] {
-webkit-appearance : none;
width : 20px;
height : 20px;
border-radius : 50%;
/* outline : none; */
border : 3px solid gray;
}
input[type="radio"]:before {
content : "";
display : block;
width : 60%;
height : 60%;
margin : 20% auto;
border-radius : 50%;
}
input[type="radio"]:checked:before {
background : green;
}
input[type="radio"]:checked {
border-color : green;
}
.role {
margin-right : 80px;
margin-left : 20px;
font-weight : normal;
}
.checkbox label {
margin-bottom : 20px !important;
}
.roles {
margin-bottom : 40px;
}
<div class="roles">
<input type="radio" name="role" value="ONE" id="one" />
<label class="role" for="one">ONE</label>
<input type="radio" name="role" value="TWO" id="two" />
<label class="role" for="two">TWO</label>
</div>
To achieve expected result, using display:flex for class roles and align-items:center for aligning vertically
Sample working code below and codepen- https://codepen.io/nagasai/pen/rNrgeOx for reference -
input[type="radio"] {
-webkit-appearance : none;
width : 20px;
height : 20px;
border-radius : 50%;
/* outline : none; */
border : 3px solid gray;
}
input[type="radio"]:before {
content : "";
display : block;
width : 60%;
height : 60%;
margin : 20% auto;
border-radius : 50%;
}
input[type="radio"]:checked:before {
background : green;
}
input[type="radio"]:checked {
border-color : green;
}
.role {
margin-right : 80px;
margin-left : 20px;
font-weight : normal;
}
.checkbox label {
margin-bottom : 20px !important;
}
.roles {
margin-bottom : 40px;
display: flex;
align-items: center;
}
<div class="roles">
<input type="radio" name="role" value="ONE" id="one" />
<label class="role" for="one">ONE</label>
<input type="radio" name="role" value="TWO" id="two" />
<label class="role" for="two">TWO</label>
</div>
I have read that to make a children box relative to its father , you must set the children position to absolute and the father position to relative.
But , in practice , I'am having some troubles.
I have an example of it , if you want to see it in this link :
Code Pen link
Basically , what happens is this :
I have set a box relative to its parent 75% to the left , which looks fine when the windows is full size.
<body>
<div id = "myspace"> My Space
<input type="text" placeholder="Search..">
<div id = "wallet">Minha Carteira<hr>
<div class="dropdown-content">
<ul style="list-style: none;">
<li>Stock 1</li>
<li>Stock 2</li>
<li>Stock 3</li>
<li> Ou adicione mais acções à sua carteira , clicando aqui..</li>
</ul>
</div>
</div>
<div id = "calendario">Calendário e Eventos<hr>
<div class="dropdown-content2">
<div id ="calendar-box"></div>
</div>
<table></table>
</div>
<div id = "resumo">Resumo do dia<hr></div>
</div>
</body>
#myspace
{
border: 2px solid black;
text-align: center;
position : relative;
}
#wallet
{
border: 2px solid black;
margin : 2px;
text-align: center;
background-color: blue;
}
.dropdown-content
{
display : none;
}
li{
border-bottom: 2px solid black;
width : 96%;
}
li:hover
{
background-color: white;
}
#wallet:hover .dropdown-content
{
display : block;
cursor: grab;
}
#calendario
{
border: 2px solid black;
margin : 2px;
text-align: center;
background-color: lightblue;
}
.dropdown-content2
{
display : none;
}
li{
border-bottom: 2px solid black;
width : 96%;
}
#calendario:hover .dropdown-content2
{
display : block;
position: relative;
}
#calendar-box
{
height : 300px;
width : 300px;
border : 2px solid black;
margin : 5px;
position: relative;
left : 70%;
}
The issue happens when I resize the window this box , goes outside the parent , when it should maintain its position relative to the parent.
I have tried to change the position both of the father and the children between relative and absolute , but still I keep failing.
Some help would be great!
Thanks
I am not at all good with CSS so need your help with below issue. I have following structure:
<div class="RowClass">
<div class="CellClass1" > Test1 </div>
<div class="CellClass2" data-value= "Summer" > </div>
<div class="CellClass2" data-value= "Winter" > </div>
<div class="CellClass2" data-value= "Monsoon" > </div>
</div>
Purpose of above structure is have a row, and different cells inside a single row. Cells with Class "CellClass2" have data-value attribute because, we want to change background color of cell(not just the text inside) according to the value in cell. For that, we have used below:
.CellClass2::after{
content: attr(data-value);
}
.CellClass2[data-value="Summer"]:after {
color: white;
background : Yellow;
}
The above code works just fine. It changes the color to white and background to blue. Only problem is we want entire cell to be blue. It just changes the text background to yellow.
Please help to fix the above scenario.
EDIT: Adding CSS for both rowclass and cellclass2 :
.CellClass2{
display: table-cell ;
text-align : center ;
border: solid ;
border-color : gray ;
text-align : center ;
color:black;
height : 30px ;
padding-top : 10px ;
padding-bottom: 10px;
padding-right: 7px;
padding-left: 7px;
border-width: thin;
font-size: 12px;
font-weight: 600;
}
.RowClass{
display : table-row ;
background: #eee ;
padding: 20px ;
margin: 20px ;
font-weight : bold ;
table-layout: fixed;
width: 200%;
}
Thanks in advance.
Remove the :after in the .CellClass2[data-value="Summer"] section
.CellClass2::after{
content: attr(data-value);
}
.CellClass2[data-value="Summer"] {
color: white;
background : Yellow;
}
.CellClass2{
display: table-cell ;
text-align : center ;
border: solid ;
border-color : gray ;
text-align : center ;
color:black;
height : 30px ;
padding-top : 10px ;
padding-bottom: 10px;
padding-right: 7px;
padding-left: 7px;
border-width: thin;
font-size: 12px;
font-weight: 600;
}
.RowClass{
display : table-row ;
background: #eee ;
padding: 20px ;
margin: 20px ;
font-weight : bold ;
table-layout: fixed;
width: 200%;
}
<div class="RowClass">
<div class="CellClass1" > Test1 </div>
<div class="CellClass2" data-value= "Summer" > </div>
<div class="CellClass2" data-value= "Winter" > </div>
<div class="CellClass2" data-value= "Monsoon" > </div>
</div>
My goal is to have an image show to the right of an h3 when a user hovers over it. My code works if the h3 is one line, but it breaks if h3 becomes two or more lines because the image shows still shows immediately after the text instead of after the whole block.
I am working on a WordPress Template.
I added the absolute positioning to a:hover:after because otherwise the insert of the image shifted the whole h3 element.
<div class="col-sm-10 offset-sm-1">
<div class="blog-entry">
<?php
the_title( '<h3 class="blog-entry-title">🥑 <a href="' . esc_url(
get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
?>
</div>
</div>
Here is my CSS
.blog-entry-title {
min-height: 75px;
}
.blog-entry-title a {
color: #232323;
padding: 15px 90px 15px 15px;
}
.blog-entry-title a:hover {
color: #66ccff;
}
.blog-entry-title a:hover:after {
content:url('https://example/color-burst.png');
position: absolute;
top: -10px;
}
Try with background-image instead of content:url. You can adjust the background-position instead of moving top the img element generated.
I'm using position:absolute as well, but only to set the width and height, so elements stays at the end of the line.
.wrapper {
width: 250px;
}
.blog-entry-title {
min-height: 75px;
}
.blog-entry-title a {
color: #232323;
padding: 15px 90px 15px 15px;
}
.blog-entry-title a:hover {
color: #66ccff;
}
.blog-entry-title a:hover:after {
content: '';
background: url("https://upload.wikimedia.org/wikipedia/commons/f/fe/Farm-Fresh_bullet_error.png");
background-repeat: no-repeat;
background-position: 50% 40%;
position: absolute;
width: 16px;
height: 16px;
}
<div class="wrapper">
<div class="blog-entry">
<h3 class="blog-entry-title">Hello world</h3>
</div>
<div class="blog-entry">
<h3 class="blog-entry-title">The Best Guacamole Recipe in the World</h3>
</div>
<div class="blog-entry">
<h3 class="blog-entry-title">Goodbye world</h3>
</div>
</div>
</div>
I have used position:relative to move the priceholder div above its initial position, now when I put another div below it which is the description div (you can check it on my jsfiddle), you can see that the priceholder div still occupies the area of its initial position.
My question is how do I remove this extra space? I do not want to use another position relative on my description div to fix it because it messes up my layout.
<div class="frame">
<div class="imageholder"><img src="http://i.imgur.com/daiSXVG.jpg"/></div>
<div class="priceholder"><p>$ 456</p></div>
<div class="description">This is a test description.</div>
</div>
Here is my jsfiddle: http://jsfiddle.net/MarkTe/g6zs8qhx/2/
I redid your structure a bit, removing some (unnecessary elements)
body {
margin-top: 50px;
}
.frame {
margin: 0 auto;
padding: 6px;
background: #fedd02;
border-radius: 6px;
width: 200px;
height: 150px;
}
.frame img {
max-width: 100%;
}
.priceholder {
border: 1px solid black;
border-radius: 50%;
width: 74px;
height: 74px;
position: absolute;
box-sizing: border-box;
margin-left: -37px;
margin-top: -43px;
padding: 10px 0 0 10px;
}
<div class="frame">
<p class="priceholder">$ 456</p>
<img src="http://i.imgur.com/daiSXVG.jpg" />
<p>This is a test description.</p>
</div>
Or see the updated Fiddle.
EDIT
To add this in a loop you could use something like this:
<?php
while( ...statement... ) {
echo '<div class="frame">';
echo ' <p class="priceholder">$ 456</p>';
echo ' <img src="http://i.imgur.com/daiSXVG.jpg" />';
echo ' <p>This is a test description.</p>';
echo '</div>';
}
?>