I am building a website and I use a table as a header. The table has 7 columns. I use some code to automatically resize my website, the resize script works perfect. Everything resizes except the table when it is at a certain size. I think it's because of the cellpadding which is 15 but I want to keep it at 15. This is the table script:
<div id="header">
<table width="100%" align="center" cellpadding="0" cellspacing="20" style="font- family:Tahoma, Geneva, sans-serif; color:#FFFFFF; background:#FF0101">
<tr>
<td width="100%" height="70%" align="center" valign="top"><table align="left" cellpadding="15" cellspacing="0" class="menu">
<tbody><tr><td class="menu" bgcolor="#5B8CFF" onmouseover"style.backgroundColor='#B30000';" onmouseout="style.backgroundColor=''">Home</td>
<td class="menu" onmouseover="style.backgroundColor='#B30000';" onmouseout="style.backgroundColor=''">Transport</td>
<td class="menu" onmouseover="style.backgroundColor='#B30000';" onmouseout="style.backgroundColor=''">Distributie</td>
<td class="menu" onmouseover="style.backgroundColor='#B30000';" onmouseout="style.backgroundColor=''"> Historie</td>
<td class="menu" onmouseover="style.backgroundColor='#B30000';" onmouseout="style.backgroundColor=''">Vacatures</td>
<td class="menu" onmouseover="style.backgroundColor='#B30000';" onmouseout="style.backgroundColor=''">Route</td>
<td class="menu" onmouseover="style.backgroundColor='#B30000';" onmouseout="style.backgroundColor=''">Contact</td> </tr>
</tbody></table></td>
</tr>
</table></div>
I hope somebody could help me to let the table automatic resize with the website width and not stuck at a certain width. Thanks a lot. ( I changed the href to website because I want to keep the website I'm making this for private.)
I suggest you to change your structure to something more flexible, also remember use inline styles are not aceptable (if you only use them due to your example I think it is ok, but always use css, even for examples because it is easy to help you):
Example:http://jsfiddle.net/GBTg4/
HTML
<div id="nav">
<ul>
<li>Home</li>
<li>Transport</li>
<li>Distributie</li>
<li>Historie</li>
<li>Vacatures</li>
<li>Route</li>
<li>Contact</li>
</ul>
</div>
CSS
#nav ul
{
width:100%;
list-style-type: none;
margin:0;
padding:0;
}
#nav li
{
display:inline;
float:left;
width:14.28571428571429%;
background-color: blue;
text-align:center;
}
#nav a
{
color:#FFF;
line-height:35px;
display:inline-block;
width:100%;
}
#nav a:hover
{
background-color:#B30000;
}
Related
I'm playing with a new layout of the site and I am getting quite hopeless in chrome and opera everything renders the way it should be but in Mozilla I get unformated output from PHP that is causing this and how to fix this.
I have put everything in a fixed cell but it is somehow ignored:
<td width="900px"> <div id="dynamiclist_index"><?php echo $dynamic_list;?></div></td>
The site is: http://musetemplatespro.com/.
but would not recommend putting styles in div's or td best to create separate stylesheet
<td style="width:900px;">
<td style="width:900px; margin: 0px auto;">
style sheet:
.container {width: 900px margin: 0px auto;}
best to have a container example
<div class="container">
<div id="dynamiclist_index">
<td><?php echo $dynamic_list;?></td>
</div>
</div>
it may work or not
There is no need to create a single table for each output.
It is better if you use it like this:
<table width="900" align="left" border="0" cellspacing="10" cellpadding="0">
<tbody>
<?php foreach($your_values as $value){ ?>
<tr style="width:300; float:left;">
<td>
<ul>
<li><img style="border:#666 1px solid;" src="images/theme_pic/3/3.jpg" alt="3" width="300" height="400" border="1"></li>
<li><a style="font-family: Helvetica, Arial, sans-serif; font-weight: lighter; ">1</a></li>
<li><hr></li>
</ul>
</td>
</tr>
<?php } ?>
</tbody>
</table>
There will be need of more styling but this is safer for cross-browser compatibility
I have a big problem with creating a HTML footer for my dad's firm. They are using OE and Outlook 10. I've working on the code for very long, but still I have some problems. Can I use external font? How should I make it working? How about positioning it with width: X% ?
I would like it to look like this:
But it doesn't...
Here's the code:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>www.k#$#$#$#$#$#$#$.com</title>
<style>
#font-face {
font-family: times_Sans_Serif;
src: url('http://a#$#$#$#$#$#$#$.pl/tem/TIMESS_.ttf');
}
p, a, span {
font-family: times_Sans_Serif;
}
a {
text-decoration:none;
}
.header {
width:100%;
height:5px;
display:block;
background-color:#6d5759;
}
.section li{
float: left;
display: inline;
list-style-type: none;
margin:0% 3%;
padding:0;
position:relative;
}
.section p{
display:block;
text-align: left;
color:#6d5759;
}
.section a{
color: #6d5759;
}
#logo {
text-decoration:none;
text-align: right;
}
.footer {
clear:both;
font-size:11px;
width:100%;
height:auto;
display:block;
background-color:#6d5759;
color:#FFF;
text-align:center;
padding: 5px;
}
.footer a{
color:#FFF;
}
</style>
</head>
<body>
<div class="main">
<div class="header"></div>
<ul class="section">
<li id="osoba">
<p>
Marcjusz K#$#$#$#$#$#$#$<br>
+48 500 000 000<br>
marcjusz#k#$#$#$#$#$#$#$.com
</p>
</li>
<li id="logo">
<img src="http://#$#$#$#$#$#$#$.pl/tem/image001.png">
</li>
</ul>
<div class="footer">
<span> K#$#$#$#$#$#$#$ Ubezpieczenia Sp.J. | 31-475 Kraków ul. STREET1 | 32-700 Bochnia ul. STREET2 | 32-800 Brzesko ul. STREET 3 | www.kr#$#$#$#$#$#$#$.com</span>
</div>
</div>
</body>
</html>
Can you help me with that? I would be very helpful!
Style sheets are NOT supported by most mail clients. Some inline styles are allowed. Positioning is generally NOT supported to prevent emails from escaping their containers - imagine an email trying to spoof a Gmail menu or something like that.
In general:
use tables for layout
use inline styles
For a good guild to what is supported, see:
http://www.campaignmonitor.com/css/
emails are weird in that you almost need to use html from 10 years ago to make it work properly. A lot of clients strip out most of the things in the head (including the actual body tag). This includes gmail, yahoo, hotmail etc. They keep only certain things. Some keep the styles, but not all.
I suggest you move your styles away from the head and inline them inside the tags using the style="" property and use tables (think back to the 90s)
so you might have something like this:
<table width="100%">
<tr>
<td id="osoba" style="">..Osoba...<td>
<td id="logo" style="">..logo..</td>
</tr>
<tr>
<td id="footer" style="">...footer...</td>
</tr>
</table>
note: I put the id's there for clarification purposes but since we stripped out your id's, they are not necessary.
I've done it! It looks as I wanted. ;) It was kind of mental pain for me to make layout using tables, but it works! ;P Thanks for help!
Here is the code for anybody who has similar problems:
<html>
<head>
<meta charset="utf-8">
<title>www.#¤#¤#¤#¤#¤#¤#¤#¤#.com</title>
</head>
<body>
<table width="100%" align="center">
<tr>
<td colspan="4" style="width:100%; height:5px; background-color:#818285"></td>
</tr>
<tr style="color: #818285;" align="center">
<td width="20%"></td>
<td align="right" width="24%">
<div style="text-align:left; width:180px; right:0%; color:#818285;">
<a style="color:#818285; text-decoration:none;" href="http://k#¤#¤#¤#¤#¤#¤#¤#¤#.com/o-nas" target="_blank">Marcjusz K#¤#¤#¤#¤#¤#¤#¤#¤#</a><br>
+48 500 000 000<br>
<a style="color:#818285; text-decoration:none;" href="mailto:marcjusz#k#¤#¤#¤#¤#¤#¤#¤#¤#.com">marcjusz#k#¤#¤#¤#¤#¤#¤#¤#¤#.com</a>
</div>
</td>
<td align="center" width="4%" style="font-size:2em; color:#818285;"></td>
<td align="left" width="52%">
<a style="color:#818285; text-decoration:none;" href="http://k#¤#¤#¤#¤#¤#¤#¤#¤#.com/" target="_blank"><img src="http://#¤#¤#¤#¤#¤#¤#¤#¤#.pl/tem/logo-poziom300.jpg"></a>
</td>
</tr>
<tr><td colspan="4" style="font-size:11px; background-color:#818285; color:#FFF; text-align:center; padding: 5px; ">
<span> K#$#$#$#$#$#$#$# Ubezpieczenia Sp.J. | 31-475 Kraków ul. STREET 6a | 32-700 Bochnia ul. STREET 14 | 32-800 Brzesko ul. STREET 3 | <a style="color:#FFF; text-decoration:none;" href="http://k#$#$#$#$#$#$#$#$#.com/" target="_blank">www.k#$#$#$#$#$#$#$#.com</a></span>
</td></tr>
</table>
</body>
</html>
Below is my code for my website. It works perfectly on firefox but not in chrome or safari. The only thing that doesn't work is the navigation row displays to the right of the header picture and the home button is the full length of the header picture. I think it has something to do with the display:inline in the css but I'm note sure.
<html>
<head>
<title>Workouts</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id = "page">
<table border="0" cellspacing="0" cellpadding="0" align="center" class="border" width = "50%" height ="100%">
<div id = "header">
<tr>
<td>
<img src =images/header_logo2.png />
</td>
</tr>
</div>
<tr class = "nav" height="30px" width="100%">
<td></td>
<td>Home</td>
<td>About</td>
<td>Workouts</td>
<td>Trainers</td>
<td>Contact</td>
<td></td>
</tr>
<tr class = "content" width="100%">
<td><img width="100%" src="images/content.png" /></td>
</tr>
</table>
</div>
</body>
</html>
This is my stylesheet
* {
margin-top:0;
padding-top:0;
padding-bottom: 0;
margin-bottom: 0;
}
body{
background:pink;
}
.border{
background-color: #c92f51;
}
.nav a{
text-decoration: none;
color:pink;
}
.nav a:hover{
color:gray;
}
.nav td{
display: inline-table;
width: 14.29%;
height="30px";
text-align: center;
font-size: 24px;
color:pink;
}
tr .content{
background:#c92f51;
}
.content td{
background:white;
padding: 30px 30px 30px 30px;
}
Invalid mark-up without DOCTYPE declaration. Check your code by copy/paste in w3c validator check the errors.
Every table row has to have the same number of columns. If you don't, you need a colspan attribute to make up for it.
Also you should not have <div> tags directly instead a table. How browsers handle these types of errors is not very consistent, so it's best to fix them. Try changing:
<table border="0" cellspacing="0" cellpadding="0" align="center" class="border" width = "50%" height ="100%">
<div id = "header">
<tr>
<td>
<img src =images/header_logo2.png />
</td>
</tr>
</div>
To
<table border="0" cellspacing="0" cellpadding="0" align="center" class="border" width = "50%" height ="100%">
<tr id = "header">
<td colspan="7">
<img src =images/header_logo2.png />
</td>
</tr>
And also add the same colspan on the last row:
<tr class = "content" width="100%">
<td colspan=7><img width="100%" src="images/content.png" /></td>
</tr>
More generally, using tables for layout like this is not good practice nowadays. If you search google for "css layouts vs tables" you can find out a lot more about it.
Use a validator. Your HTML is invalid and at least one of your errors causes significant differences in how different browsers error recover from it.
Some will move the <div> that is a child element of the <table> so it is outside the table (because it isn't allowed there).
You don't have any tabular data in there, so get rid of all the table markup and use something more appropriate (e.g. a list for your list of links and so on).
I have a table with buttons on it, align at left, but when I convert one button to a menu using <ul> that moves all the buttons to the right and a bit down... I'm sure that it's cos <ul> but, i don't know what to do to delete that format.
I'd try with list-style: none, but that didn't work.... any ideas??
This is the code in html:
<div id="submenu">
<div id="subopciones" class="menudesp">
<ul>
<table border="0" id="tabla_submenu" cellpadding="0" cellspacing="0">
<tr>
<td id='celda_submenu'><li><a href="#" id='opcion_submenu' class='opcion_selec'>Blog</a>
<ul>
<li>Clasicos</li>
<li>Screencasts</li>
<li>Tips</li>
</ul>
</li></td>
<td id='espacio_submenu'></td>
<td id='celda_submenu'><a href='prueba.php' id='opcion_submenu' >Gran Formato</a></td>
<td id='espacio_submenu'></td>
<td id='celda_submenu'><a href='prueba.php' id='opcion_submenu' >Digital</a></td>
</tr>
</table>
</ul>
</div>
</div>
if you are not using css file try:
<ul style="margin:0; padding:0">
if you are using css, add to the file:
ul{
margin:0;
padding:0;
}
I can't understand why doesn't this table align properly. There are 9 pictures in first row, and 3 pictures in the second row. For some reason this table stretches beyond what is necessary, and produces gaps between the pictures. The width of the table is 990 and sum of widths of all the pictures for each row is also 990 (I don't count border width here, I just included it to show where the cells separate. The gap between the pictures is so large that it can not be explained by the border width).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body bgcolor="#008000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >
<table id="Table_01" width="990" border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td colspan="1"><img src="images/index_02.jpg" width="90" height="52" /></td>
<td colspan="1"><img src="images/index_03.jpg" width="102" height="52" /></td>
<td colspan="1"><img src="images/index_04.jpg" width="112" height="52" /></td>
<td colspan="2"><img src="images/index_05.jpg" width="120" height="52" /></td>
<td colspan="1"><img src="images/index_07.jpg" width="120" height="52" /></td>
<td colspan="2"><img src="images/index_06.jpg" width="112" height="52" /></td>
<td colspan="1"><img src="images/index_07.jpg" width="120" height="52" /></td>
<td colspan="1"><img src="images/index_08.jpg" width="134" height="52" /></td>
<td colspan="1"><img src="images/index_09.jpg" width="80" height="52" /></td>
</tr>
<tr>
<td colspan="4"><img src="images/index_11.jpg" width="346"/></td>
<td colspan="3"><img src="images/index_12.jpg" width="308"/></td>
<td colspan="4"><img src="images/index_13.jpg" width="336"/></td>
</tr>
</tbody>
</table>
</body>
</html>
Here is how it looks. I made page background color to be green, so that it can be easily separated from images :
Try creating a css file that contains the following code and link it to your table.
#table {
border-collapse: collapse;
border-spacing: 0;
}
This should work for getting rid of the padding and margins in your table
Here is my version:
css
body { font-size:10pt; font-family:Verdana; }
.header ul li { background: url('tab-left.png') bottom left no-repeat; float:left; list-style:none; }
.header ul li a { background: url('tab-right.png') bottom right no-repeat; color:#fff; display:block; padding:10px 26px; text-decoration:none; }
.header ul li a:hover { text-decoration:underline; }
.sub-header { clear:both; }
.sub-header li { background: url('...'); }
.sub-header li a { background: url('...'); font-size:12pt; text-transform:uppercase; }
html
<div class="header">
<ul>
<li>Home</li>
<li>About Us</li>
<li>Clients</li>
<li>Contact</li>
<li>Coordinates</li>
<li>Corporate Portfolio</li>
</ul>
<ul class="sub-header">
<li>Need Staff?</li>
<li>Looking for a job?</li>
<li>Something....</li>
</ul>
</div>
images
and
result
OK so here's my code of how I would lay this out with HTML with a little CSS to try to help put you on the path to being current with your HTML skills.
I'm going to start with your background image. Currently you have it as part if your images that you are piecing together in the table. If you have syntax errors in your code, this can lead to misalignment like what you are seeing. If instead you defined it as the background image of the body, this would never occur.
Next is the navigation. You have a bunch of tabs. These tabs include part of the background when they should really only be the images themselves. A navigation is a list of webpages, so in essence you should use an unordered list, because they are in no particular order. the css selector display: inline; tells the list's line item to change it's display type so all the images float next to each other instead of being listed down from each other. in the .nav class the margin tells it to center it, and the width is self explanatory.
<head>
<style type="text/css">
body { background-image: url('/images/background-image.png') repeat-y; }
.nav { width: 800px; margin: 0 auto; }
.nav li { display: inline }
</style>
</head>
<body>
<ul class="header-nav nav">
<li><img></li>
<li><img></li>
<li><img></li>
<li><img></li>
<li><img></li>
<li><img></li>
</ul>
<ul class="other-nav nav">
<li><img></li>
<li><img></li>
<li><img></li>
</ul>
</body>
To fix the above you would need to remove all the colspans from the first row. They are useless then have the colspans in the 2nd row equal no more and no less than the rowspans of the 1st row. After doing that the problem with that is your images don't add up mathematically so it'll be wrong. You really need to recut your images as well.
Definitely go CSS versions that people have posted. Please don't perpetuate 1995 HTML....
However, to answer your original question, add up the widths you've specified.
<td colspan="1"><img src="images/index_02.jpg" width="90" height="52" /></td>
<td colspan="1"><img src="images/index_03.jpg" width="102" height="52" /></td>
<td colspan="1"><img src="images/index_04.jpg" width="112" height="52" /></td>
<td colspan="2"><img src="images/index_05.jpg" width="120" height="52" /></td>
Those columns correspond to a colspan=4 group with a specified width of 346. You'd be splitting the last column as it has a colspan of 2. My head hurts already.
The second group is 3 columns:
<td colspan="1"><img src="images/index_07.jpg" width="120" height="52" /></td>
<td colspan="2"><img src="images/index_06.jpg" width="112" height="52" /></td>
Which add up to 232px. The next corresponding row is colspan=3 adding up to 308. Since 308 != 232, you're going to have spaces.
Rinse and repeat for the next columns. If you make the first row match up with the columns from the second row, your spaces go away. If I was to do this (which I wouldn't) I would just have one row and one big column with all buttons in it.....
Do not split the 2nd tr into 3 tds.
Just make 1 td in the 2nd tr and make it be td colspan='9'
I would also recommend not even doing 9 tds in the 1st <tr> because it's redundant (the images will "push" the boundaries of the table to fit their specs, regardless of td height/width settings.