Formatting CSS with data-tooltip element - php

I'm still learning, please go gentle with me.
When I run my script everything works except the full formatting with my css. In the snipped of code, I would like the . However, when I have the div in the middle of the , as seen below, when I run the page I have two lines of information. Line one contains the flag image, line two contains my outputted "luchthavencode", underlined as desired.
How would I format the css / php/html code so that they all are contained within one line.
If I move the to before the img, everything is in a line as desired -- it's OK that when you hover over the flag the name comes up, also), it also generates two lines.
echo "<td width='100px' bgcolor='#C6DEFF'><img src='http://globe-trekking.com/vg/img/flags/".$row['countryflag']."'> <div class='top10_luchthaven' data-tooltip=\"".htmlspecialchars($row['luchthavennaam'])."\" >".$row['luchthavencode']."</div></td>";
Using the following css styles
.top10_luchthaven {
position: relative;
border-bottom: .1em dotted;
width:30px;
}
.top10_luchthaven:hover:after {
background: url(http://globe-trekking.com/vg/img/hovercard-bg.png) repeat-x;
border-radius: 5px;
bottom: 5px;
color: #fff;
content: attr(data-tooltip);
left: 20%;
padding: 5px 15px;
position: absolute;
z-index: 98;
width: 400px;
}
.top10_luchthaven:hover:before {
border: solid;
border-color: #333 transparent;
border-width: 6px 6px 0 6px;
bottom: 20px;
content: "";
left: 50%;
position: absolute;
z-index: 99;
with the full table php/html code:
echo "<table width='200px' border='0' cellpadding='2' cellspacing='2'>";
echo "<tbody>";
echo "<tr>";
echo "<td bgcolor='#0033FF'><strong class='home_box_header'>#</strong>";
echo "<td bgcolor='#0033FF'><strong class='home_box_header'>Luchthaven</strong>";
echo "<td bgcolor='#0033FF'><strong class='home_box_header'>No.</strong>";
echo "</tr>";
$line = 1;
while($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td bgcolor='#C6DEFF'>$line</td>";
echo "<td width='100px' bgcolor='#C6DEFF'><img src='http://globe-trekking.com/vg/img/flags/".$row['countryflag']."'> <div class='top10_luchthaven' data-tooltip=\"".htmlspecialchars($row['luchthavennaam'])."\" >".$row['luchthavencode']."</div></td>";
echo "<td width='60px' bgcolor='#C6DEFF'>".$row['sum']."</td>";
echo "</tr>";
$line++;
}
echo "</tbody>";
echo "</table>";

The problem is that divs are block level elements by default, which means they line break, so you need to have CSS that instructs those divs to be inline with the image next to it. Try doing this...
.top10_luchthaven {
display: inline;
}
If that doesn't work, then do display: inline-block instead.

Related

How to get the text box on the right under the picture

As you can see in the picture, there is a box to the right with some text and a lot of white space.
My goal is to have the text under the pictures while I have 3 pictures in a row that are nicely aligned.
When I try this either the pictures aren't aligned anymore or the pictures aren't cropped anymore.
I wanted every picture with the same size and still sharp but, then this issue came up.
#content {
width: 100%;
max-width: 100%;
margin: 20px auto;
}
form {
width: 50%;
margin: 20px auto;
}
form div {
margin-top: 5px;
}
#img_div {
width: 30%;
margin-left: 2%;
margin-right: 1%;
margin-bottom: 3%;
border: 2px solid #d8680c;
float: left;
}
#img_div:after {
content: "";
display: block;
clear: both;
}
img {
float: left;
object-fit: cover;
width: 250px;
height: 250px;
}
#pictext {
word-wrap: break-word;
}
<div id="content">
<?php
while ($row = mysqli_fetch_array($result)) {
echo "<div id='img_div'>";
echo "<img src='fotopage\images/" . $row['image'] . "' >";
echo "<p id='pictext'>" . $row['image_text'] . "</p>";
echo "</div>";
}
?>
</div>
use class instead of using ID
ID must be unique and when you do the loop there will be some other divs with same ID
add it like this
<?php
while ($row = mysqli_fetch_array($result)) {
echo "<div class='img_div'>";
echo "<img src='fotopage\images/" . $row['image'] . "' >";
echo "<p class='pictext'>" . $row['image_text'] . "</p>";
echo "</div>";
}
?>
make sure to reflect them via JS or JQuery depends on what your are using

Div Styled As Table for Form Input not Rendering

I'm working on a php powered site for a musician, part of which involves the ability for him to add upcoming shows to his site through a form. I want a table layout where he can see his upcoming shows, and can choose to add a new one. I tried using a table, but quickly found they don't really work with PHP forms. So I tried to format my form as a table with CSS display properties. That had it not rendering at all, in fact, if you go into the inspector in Chrome,it shows all of the information clearly there, laid out in the HTML, but with no height. I tried manually adding height and width, but to no avail. I tried changing from a form to a div, just to see, and that didn't help either.
.form-table {
width: 100%;
display: table;
font-size: 20px;
}
.admin-table-row {
display: table-row;
width: 100%;
}
.admin-table-cell {
display: table-column;
}
.admin-venue {
width: auto;
text-align: left;
}
.admin-age {
text-align: right;
width: 75px;
}
.admin-date {
text-align: right;
width: 200px;
}
.admin-time {
text-align: right;
width: 100px;
}
.admin-time {
text-align: right;
width: 100px;
}
.admin-edit {
text-align: right;
width: 100px;
}
.admin-delete {
text-align: right;
width: 100px;
}
//echo "<form class='form-table' action='' method='post'>";
echo "<div class='form-table'>";
foreach($stmt as $upcomingShow)
{
$date = date("j F, Y", (strtotime($upcomingShow['date'])));
$time = date("g:i a", (strtotime($upcomingShow['time'])));
echo "<div class='admin-table-row'>";
if(!empty($upcomingShow['link']))
{
echo "<div class='admin-venue admin-table-cell'><a href='" . $upcomingShow['link'] . "' style='text-decoration: none;'>" . $upcomingShow['venue'] . "</a></div>";
}
else
{
echo "<div class='admin-venue admin-table-cell'>" . $upcomingShow['venue'] . "</div>";
}
echo "<div class='admin-age admin-table-cell'>" . $upcomingShow['age'] . "</div>";
echo "<div class='admin-date admin-table-cell'>" . $date . "</div>";
echo "<div class='admin-time admin-table-cell'>" . $time . "</div>";
echo "<div class='admin-edit admin-table-cell'><input name='edit' id='edit' type='submit' value=' Edit ' style='background: none; border: none; padding: 0; font: inherit; cursor: pointer;'></div>";
echo "<div class='admin-delete admin-table-cell'><input name='delete' id='delete' type='submit' value=' Delete ' style='background: none; border: none; padding: 0; font: inherit; cursor: pointer;'></div>";
echo "<input name='show-id' id='show-id' type='hidden' value='" . $upcomingShow['id'] . "'>";
echo "</div>";
}
echo "</div>";
//echo "</form>";
Thanks for all the help. Best, Chris.
Checking your CSS, the issue is in here:
.admin-table-cell {
display: table-column;
}
The display: table-column is not used to specify that the element is a cell, but to specify that the element contains a column of cells; and by definition it is not rendered:
Elements with 'display' set to 'table-column' or 'table-column-group' are not rendered (exactly as if they had 'display: none')
That's why you don't see the contents even after setting a height. What you need to use to specify that the div is a cell, is display: table-cell. Then it will display the content of each cell correctly. This change should fix the issue:
.admin-table-cell {
display: table-cell;
}

CSS class is not working properly

I have this code in my HTML file
echo "<article class='room-full-width'>";
$room_query = mysql_query("SELECT * FROM roomdetails WHERE hotelname = '".$row['hotelname']."'");
while($room=mysql_fetch_array($room_query)){
echo "<span class='room-details'>";
echo "<span class='room-name'>";
echo $room['roomtype'];
echo "</span>";
echo "<a class='gradient-button' title='Book now' href='hotel.html'>Book now</a>";
echo "</span>";
}
echo "</article>";
And I am adding this following Style in .css file:
.room-full-width{
float: left;
margin-bottom: 2%;
margin-top: -2%;
width: 100%;
}
.room-full-width .room-details{
background-color: -moz-buttonhoverface;
float: left;
padding: 1% 2% 0;
width: 90%;
}
.room-full-width .room-details .room-name{
color: #333333;
font-size: 1.6em;
font-weight: bolder;
max-width: 30%;
overflow: visible;
width:29%;
}
.room-full-width .room-details .gradient-button{
bottom: 5px;
float: right;
position: relative;
right: 20px;
}
But this class .room-full-width is not at all working , if I test it with my firebug it is not even showing this class but other classes like .room-details and .room-name and .gradient-button all are working fine.
But the parent class is not at all shown in Firebug itself.
I am using latest version of Firefox - it supports HTML5 and CSS3.
Try to use
echo "<article class=\"room-full-width\">";
It might be the single quotes it's not agreeing with.
Or better yet:
echo '<article class="room-full-width">';

Dropdown menu wont stick to table

I have a CSS related problem, that would look easy, but I have been slamming my head against the wall for the last hour, since the tweaks arround i tried are not applying.
For some odd reason, the select dropdown menu wont stick into the cell, but is placed above the table.See picture below
The loop code to generate the table is build up as followed: (i didnt bother posting the php cause thats not relevant)
echo '<tr class="items">';
echo '<td id="cell11">'.$Date.'</td>';
echo '<td id="cell21">'.$link.'</td>';
echo '<td id="Fright1">'.MakeUserRoleDropdown($StatusId).'</td>';
echo '</tr>';
The CSS is pretty basic:
select { width: 367px; font-family: Verdana; font-size: 12px; color: #666; background: white; border: 1px solid #CECECE; padding: 4px;}
.dropdownrole { width:150px;}
#cell11 { padding-left: 10px; padding-right: 10px; width: 200px; text-align:left;}
#cell21 { padding-left: 10px; padding-right: 10px; width: 200px; text-align:left;}
#Fright1 { padding-left: 10px; padding-right: 10px; width: 200px; text-align:right;}
table.items tr { height: 32px; background:url(../images/tableRow.png); border-top: 1px solid #CCC; padding: 0; margin: 0;}
.items { width: 100%; border-collapse: collapse; color: ##797979; font-family: Verdana; font-size: 11px; }
table { border-spacing:2px;}
dropdownrole is in this case te class applied to the dropdown menu.
As you see, the dropdown wont apply to the row and just is put above the table (even in the code it's not even in the cell) And I cant wrap my head arround why. I made cells already bigger in size (height and width) but no luck.
Did i do something wrong within the CSS?
EDIT
Per request of the dropdown function.
function MakeUserRoleDropdown($StatusId){
echo "<select name='StatusId' class='dropdownrole'>";
$results = LoadRoles();
while($row = mysql_fetch_array($results)){
echo "<option value='".$row['SgroupId']."' ";
if($StatusId == $row['SgroupId']){
echo "selected='selected'";
};
echo ">".$row['SgroupUser']."</option>";
}
echo "</select>";
}
And here is the output in HTML.
I Think the problem is, that you call MakeUserRoleDropdown which contains echos
you proceed to use this method in this string: echo '<td id="Fright1">'.MakeUserRoleDropdown($StatusId).'</td>';
Alter your MakeUserRoleDropdown to this:
function MakeUserRoleDropdown($StatusId){
$str = '';
$str .= "<select name='StatusId' class='dropdownrole'>";
$results = LoadRoles();
while($row = mysql_fetch_array($results)){
$str .= "<option value='".$row['SgroupId']."' ";
if($StatusId == $row['SgroupId']){
$str .= "selected='selected'";
};
$str .= ">".$row['SgroupUser']."</option>";
}
$str .="</select>";
return $str;
}
And you should be good.

How to make my chat div's appear below each other

I am making a small chat and I am having issues making the div's appear below each other. This is what I have:
$i = 0;
while($i < 5)
{
echo "<div class='MyChatholders'>";
echo "<div class='pro_pic'>";
//my image
echo "</div>";
echo "<div class='ChatInfo'>";
//my information
echo "</div>";
echo "</div>";
echo "<br />";
$i++;
}
MY CSS:
div.MyChatholders
{
left: 5px;
color: black;
width: 290px;
height: 100px;
border-radius: 10px;
}
div.pro_pic
{
left: 5px;
width: 30px;
height: 30px;
border: solid black 1px;
}
div.ChatInfo
{
color: black;
font-size: 14px;
left: 40px;
width: 245px;
}
Please note that the (while function) is just to simulate the information drawn from the DBase.
Now my issues is that all the div's are in one position. I would like them to fall below each other. I do not understand why this is happening. Can someone help me with my code and explain why?
I have looked at this solution but it is not working for me Check here
Add position:relative; to your divs.
Working fiddle based on your code: http://jsfiddle.net/MmGyU/1/
Note: Borders in the fiddle are for demonstration purposes.
div.MyChatholders {
position: relative;
left: 5px;
color: black;
width: 290px;
height: 100px;
border-radius: 10px;
}
div.pro_pic {
position:relative;
left: 5px;
width: 30px;
height: 30px;
}
div.ChatInfo {
position:relative;
color: black;
font-size: 14px;
left: 40px;
width: 245px;
}
Make it print your <div> tags to a new line in your loop using \n
$i = 0;
while($i < 5)
{
echo "<div class='MyChatholders'>\n";
echo "<div class='pro_pic'>\n";
//my image
echo "</div>\n";
echo "<div class='ChatInfo'>\n";
//my information
echo "</div>\n";
echo "</div>\n";
echo "<br />\n";
$i++;
}
EDIT Syntax was wrong, the \n needs to be within quotes
2nd EDIT My mistake, \n is not HTML and it won't work. You could use <br /> instead according to this post
Add clear:both; to your chat divs.

Categories