Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Table Center To Browser

Posted on 2012-03-15
8
Medium Priority
?
258 Views
Last Modified: 2012-06-21
Hi Experts!

Thanks for reading this.

Trying to build a page with a header, footer, and a table.

Need help centering table to the browser, but the contents in the table shouldn't be centered. If you could can show the table's border and add the buttons that would be gravy.

Should look like this:

screenshoot
Here's the incomplete code:

<!DOCTYPE html>
<html>
<head>
    <title>MyTitle</title>
</head>

<body>

<div id="Header">Header</div>

    <table>
    <tr>
        <td>button 1 </td>
        <td>button 2 </td>
        <td>button 3 </td>
    </tr>
</table>

<div id="Footer"> Footer</div>

</body>
</html>

Open in new window


TIA!
0
Comment
Question by:allanau20
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
8 Comments
 
LVL 22

Assisted Solution

by:Mrunal
Mrunal earned 1000 total points
ID: 37728127
Hi, try this:

<html>
<head>
<style type="text/css">
#Header {background-color:#CCC; border: solid 1px #AAA;}
#Footer {background-color:#CCC; border: solid 1px #AAA;}
.centerTable {background-color:#EEE; height:90%; width:100px; margin: 20px 0px;}
.centerTable td {text-align:center; vertical-align: middle;}
</style>
</head>

<body>

<div id="Header">Header</div>
<center>
    <table class="centerTable" cellspacing="0" cellpadding="0" border="1">
    <tr>
        <td>button 1 </td>
        <td>button 2 </td>
        <td>button 3 </td>
    </tr>
</table>
</center>
<div id="Footer"> Footer</div>

</body>
</html>

Open in new window


Now you can change width of table in CSS.
0
 
LVL 16

Accepted Solution

by:
HagayMandel earned 1000 total points
ID: 37728291
Try this:

The CSS
    <style type="text/css">
<!--
#Header {
	background-color: #99CCFF;
	padding-top: 2px;
	padding-bottom: 2px;
	padding-left: 4px;
	font-family: Geneva, Arial, Helvetica, sans-serif;
	font-size: 14px;
	border: 1px solid #000000;
}
#Footer {
	background-color: #99CCFF;
	padding-top: 2px;
	padding-bottom: 2px;
	padding-left: 4px;
	font-family: Geneva, Arial, Helvetica, sans-serif;
	font-size: 14px;
	border: 1px solid #000000;
}
#table_div {
	border: thin solid #999999;
	padding-top: 25px;
	padding-bottom: 25px;
	margin-top: 30px;
	margin-bottom: 30px;
	text-align: center;
	margin-right: auto;
	margin-left: auto;
	width: 90%;
}
#table_div #myTable {
	margin-right: auto;
	margin-left: auto;
	width: 100%;
	margin-top: 20px;
	margin-bottom: 20px;
}
#myTable .td_button {
	border: thin solid #999999;
	padding-top: 5px;
	padding-bottom: 5px;
	background-color: #CCFF00;
	margin-top: 12px;
	margin-bottom: 12px;
	float: left;
	width: 25%;
	margin-left: 6.25%;
}
-->
    </style>

Open in new window


The HTML

<div id="Header">Header</div>
<div id="table_div">
    <table id="myTable">
    <tr>
        <td class="td_button">button 1 </td>
        <td class="td_button">button 2 </td>
        <td class="td_button">button 3 </td>
    </tr>
</table> </div>
<div id="Footer"> Footer</div>

Open in new window

0
 
LVL 5

Author Comment

by:allanau20
ID: 37730856
thanks; I will try it now.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:allanau20
ID: 37730888
Thanks; you both are cool.

BTW, how do you show the border of the table?

I will split points. Thanks again.
0
 
LVL 5

Author Comment

by:allanau20
ID: 37730895
0
 
LVL 5

Author Comment

by:allanau20
ID: 37730906
nvm; HagayMandel had the table borderlined. Thanks!
0
 
LVL 5

Author Comment

by:allanau20
ID: 37731647
Hi HagayMandel,

a quick question; how do you change the Table width?
Tried several adjusting the 'width' in with the different selector in CSS and doesn't work.

Thanks!
0
 
LVL 5

Author Comment

by:allanau20
ID: 37731706
nvm; thanks; figured it out.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question