Reputation: 727
The idea is that i want a table with 2 columns. The left column will contain an image and the right one will have 6 rows which will display data about the image.
________________________________
| |_______________|
| |_______________|
| image |_______________|
| |_______________|
| |_______________|
|_______________|_______________|
This example displays it as i want it index.php:
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
</style>
</head>
<body>
<table style="width:50%" height = "350" align="center">
<tr>
<th rowspan="6" ><img src="1466570127.jpg" alt=""></img></th>
<td>555 77 854</td>
</tr>
<tr><td>555 77 855</td></tr>
<tr><td>555 77 856</td></tr>
<tr><td>555 77 857</td></tr>
<tr><td>555 77 858</td></tr>
<tr><td>555 77 859</td></tr>
</table>
</body>
</html>
But when i tried to use this code in my project for some reason it gets messed up and looks exactly like this:
________________________________
| | |
| | |
| image | |
| | |
| | |
| |_______________|
| |_______________|
| |_______________|
| |_______________|
| |_______________|
|_______________|_______________|
I belive the problem has to be in my css file but i still can't find it. Any hint will be helpfull and thank you in advance for your time. I will give you my code in case it helps: html:
<?php
include_once("config.php"); //include the config
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Photography Site </title>
<link rel="stylesheet" type="text/css" href="CSS/Mainbody.css" />
<link rel="stylesheet" type="text/css" href="CSS/800px.css" media="screen and (max-width: 800px)" />
<link rel="stylesheet" type="text/css" href="CSS/Menu.css" />
<link rel="stylesheet" type="text/css" href="CSS/SideBar.css" />
</head>
<body>
<div id="Container">
<?php include 'menu.php';?>
<?php include 'display_photos.php';?>
<div id="MainBody">
<?php
//display all photos in database
$rows = $_SESSION['rows'];
for ($x = 0; $x < $rows; $x++) {
$name = $_SESSION['array'][$x][1];
$username = $_SESSION['array'][$x][8];
$category = $_SESSION['array'][$x][9];
$description = $_SESSION['array'][$x][2];
$likes = $_SESSION['array'][$x][7];
$path = $_SESSION['array'][$x][3];
$res_path = $_SESSION['array'][$x][4];
?>
<table style="width:50%" height = "350" align="center">
<tr>
<th rowspan="6" ><img src="<?php echo $res_path ?>" alt=""></img></th>
<td>Name: <?php echo $name; ?></td>
</tr>
<tr><td>User: <?php echo $username; ?></td></tr>
<tr><td>Category: <?php echo $category; ?></td></tr>
<tr><td>Description: <?php echo $description; ?></td></tr>
<tr><td>path: <?php echo $path; ?></td></tr>
<tr><td>Likes: <?php echo $likes; ?></td></tr>
</table>
<?php } ?>
</div>
</div>
</body>
</html>
my css file:
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/* ~~~~~~~~ css reset finished ~~~~~~~~~~*/
body{
margin-left:0px;
margin-right:0px;
margin-top:0px;
margin-bottom:0px;
background-color:#EBF4FA;
}
#Container{
width:1000px;
height:auto;
margin-left:auto;
margin-right:auto;
margin-top:11px;
margin-bottom:21px;
}
#Header {
height: 140px;
background: url(logo.png);
}
#Menu{
height:60px;
background-color:#25383C;
}
#SideBar{
width:150px;
height:200px;
background-color:#25383C;
float:left;
border:1px;
border-style: solid;
}
#MainBody{
width:848px;
height:auto;
background-color:#F88158;
//background: url(Mainbodybg.png);
float:right;
text-align:center;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
Upvotes: 1
Views: 1497
Reputation: 2635
If you add vertical align top to the css, it produces the result you are looking for.
th, td {
vertical-align: top;
}
Upvotes: 1
Reputation: 67798
You could use a nested table in the second column/cell:
<table style="width:50%" height = "350" align="center">
<tr>
<td><img src="1466570127.jpg" alt=""></img></td>
<td>
<table>
<tr><td>555 77 854</td></tr>
<tr><td>555 77 855</td></tr>
<tr><td>555 77 856</td></tr>
<tr><td>555 77 857</td></tr>
<tr><td>555 77 858</td></tr>
<tr><td>555 77 859</td></tr>
</table>
</td>
</tr>
</table>
Upvotes: 1
Reputation: 773
You need to set the vertical-align
attribute on the cell with the image. In this case, I believe you just want to add vertical-align:bottom;
to get the data about the image to display aligned with the top of the image. Example here: http://jsbin.com/rofekasoto/edit?html,css,output
Upvotes: 2