I have two tables. One above the other. I want to move the bottom table to the right of the top table. Right now when I run the server, the top table is positioned above the bottom table. Is there a way to move the bottom table to the right side of the top table?
<table>
<tr><th>Type</th><th>Quantity</th></tr>
</tr><td>Tape + Film</td><td>{{total_tape_and_film_items}}</td></tr>
</tr><td>Electrical Equipment</td><td>{{total_electrical_equipment_items}}</td></tr>
</tables>
<table>
<tr><th></th><th>Status</th><th>Quantity</th></tr>
<tr><td><a id="new_client" href='{% url tiptop.views.in_items client.pk%}'/>View</a></td><td>In</td><td>{{in_items|length}}</td</tr>
<tr><td><a id="new_client" href='{% url tiptop.views.out_items client.pk%}'/>View</a></td><td>Out</td><td>{{out_items|length}}</td</tr>
<tr><td><a id="new_client" href='{% url tiptop.views.empty_items client.pk%}'/>View</a></td><td>Empty</td><td>{{empty_items|length}}</td</tr>
</table>
Change <table> to <table style="float: left">
After the last </table> add <div style="clear: both"></div>. This is to make sure nothing goes to the right of the second table.
Set both tables to have a fixed width and then float them using CSS:
table { float:left; width:400px; }
Something like this should work:
<div style="width: 400px;">
<div style="width: 200px; float: left;">
<table>
<tr><th>Type</th><th>Quantity</th></tr>
</tr><td>Tape + Film</td><td>{{total_tape_and_film_items}}</td></tr>
</tr><td>Electrical Equipment</td><td>{{total_electrical_equipment_items}}</td></tr>
</tables>
</div>
<div style="width: 200px; float: left;">
<table>
<tr><th></th><th>Status</th><th>Quantity</th></tr>
<tr><td><a id="new_client" href='{% url tiptop.views.in_items client.pk%}'/>View</a></td><td>In</td><td>{{in_items|length}}</td</tr>
<tr><td><a id="new_client" href='{% url tiptop.views.out_items client.pk%}'/>View</a></td><td>Out</td><td>{{out_items|length}}</td</tr>
<tr><td><a id="new_client" href='{% url tiptop.views.empty_items client.pk%}'/>View</a></td><td>Empty</td><td>{{empty_items|length}}</td</tr>
</table>
</div>
<div style="clear: both;"></div>
</div>
You should move the CSS to your stylesheet instead if you apply this to production. Good luck.
If you don't have to support IE<8, you can set display: inline-block on the tables. This will make them behave like inline elements on the outside, but block-level elements on the inside. You'll also want to explicitly set the table widths, as well as the width of the containing block, unless you want the second table to pop below the first one when there's not enough room.
Related
As a backend dev I didnt know how hard frontend was ;).
How can I put the "Create" button above the left side of the table:
Right now the button is in the middle of the table because the table is in a . This is the full code:
<div align="center">
<h1>All Tournaments </h1>
<p>Show: History or Unplayed</p>
Create
<table style="width:50%" id="tournament_table">
<tr id="table_head">
<th>Name</th>
<th>Players needed</th>
<th>Rounds</th>
<th>Host</th>
<th>Select robot</th>
<th>Played</th>
<th>Join tournament</th>
The button is the element. I want the page look like this:
Thanks
EDIT: The complete page looks like this.
The text above and the table beneath the Create button need to be centered. If I pull the button out of the align center div it appears completely to the left.
Wrap in a div and add class text-left on parent as follows:
<div align="center" style="width: 50%; margin: 0 auto">
<div class="text-left">
<h1>All Tournaments </h1>
<p>Show: History or Unplayed</p>
Create
</div>
<table id="tournament_table">
<tr id="table_head">
<th>Name</th>
<th>Players needed</th>
<th>Rounds</th>
<th>Host</th>
<th>Select robot</th>
<th>Join tournament</th>
<th>Played</th>
</tr>
</table>
</div>
Add a class .pull-left to the button
Create
<div class="clearfix"></div>
I have used <div align="center"> and put the image inside the div tag. Well the image is at the center but not at the middle. The image started from the top of div tag and placing at the center but I want it to be placed at the middle not at the top.
When I googled it I found <td valign="middle">. and its working as I intended and below is what I have designed after googling,
<div align="center" style="width:510px;height:510px;margin-left:300px">
<table style="width:510px;height:510px">
<tr>
<td align="center" valign="middle">
<img id="main" src="dock.jpg" style="max-width:500px;max-height:500px"/>
</td>
</tr>
</table>
</div>
But using a table for these purpose is it harmful ? Because I have tried <div align="center" style="vertical-align:middle"> but does not seem to work as i expected and please let me know if there is a way to do without table ?
You shouldn't be using <div align="center"> either really, its been deprecated:
http://reference.sitepoint.com/html/div/align
This attribute is deprecated. The correct method for aligning a div is
to use the CSS text-align attribute.
I'm not certain on the best way of vertically aligning div's (although you may find this article worth reading), but I know that you are right, you shouldn't use tables as a solution. Table should only be used when creating a table of data results for example, never layout purposes.
This will help you i think so:
just give #to div. and then style it in CSS as follow:
position: absolute;
left: 50%;
right: 50%;
width: _px;
height: _px;
margin: half of the width, half of the height;
Try this. May help you.
<div style="width:510px;height:510px;border:1px solid;margin:auto;">
<table style="width:100%; height:100%;">
<tr>
<td align="center">
<img id="main" src="wp1.JPG" style="max-width:300px;max-height:300px;"/>
</td>
</tr>
</table>
</div>
I can't get right positions for my tables. I have code like this:
<div style="width: 1270px;">
<div>
<table style="float:left>
<tr><td>something1</td></tr>
<tr><td>something2</td></tr>
</table>
<img src="some_sorce">
<table style="float:left>
<tr><td>something3</td></tr>
<tr><td>something4</td></tr>
</table>
</div>
</div>
And I have two problems:
First I want tables to be placed in bottom of containing div. I try some kind of "vertical-align" in some places but it fail for me. Secoundly i want the image to be in center of div, "text-align: center" don't do the trick. Could someone help me anyhow?
Instead of:
<table>
<img src="some_sorce">
it should be:
</table>
<img src="some_sorce">
And by default images have display: inline attribute so You need to do something like:
<img src="some_sorce" style="display: block">
to center image
I want do do a layout that is search engine and speed-browser friendly with content first in source code. Usually this looks like this:
<body>
<div id="content" style="margin-top: 200px;">
i am content, i go first
</div>
<div id="head" style="height: 200px; position: absolute;">
i am an header that is depressed because my designer things i am not important
</div>
</body>
but I need an dynamic sized header increases the height with its content...
this must be a common problem. is it possible to solve somehow?
any ideas?
I agree with #babtek though, I'd really like to be wrong, cause this looks interesting.
Also, this is probably not what you need, but HTML5 has a "reversed" attribute for <ol> that could do the trick.
I do not think this is possible using CSS alone. Need JavaScript.
As far as I am concerned it can only be achieved using tables.
<table>
<tr>
<td><!-- empty table cell --></td>
<td rowspan="2" valign="top">General Content</td>
</tr>
<tr>
<td valign="top">Navigation</td>
</tr>
</table>
Since you've tagged the divs with id, it makes more sense to put the styles in css.
In any case, have you tried
height: auto;
If you want to let the height adjust with content but have it at least 200px, then
min-height: 200px;
should do the trick.
I want to display 4 or 5 boxes(vary) which occupy's 100% of the page width, so it will span start to end of page. and want height just to fit contents.
I am trying to use table for that so it will assign width for each box and fill up whole row.
Problem with code below is all divs in td are centered and does not have same height. tried all i can think of but it doesn't work. tried vertical alignment, height to 100% .....
How can i have all div in td with same height?
Also if there is another way to doing same please let me know. I am html dummy so may not using the right thing.
<table style="width: 100%; text-align:justify;">
<tr>
<td>
<div style="margin-right:15px; background-color:Gray">
Some text here
</div>
</td>
<td>
<div style="margin-right: 15px; background-color:Gray">
column 2 text here
</div>
</td>
<td>
<div style="margin-right: 15px; background-color:Gray">
Column 3 text here
</div>
</td>
<td>
<div style="background-color:Gray">
Last column text here
</div>
</td>
</tr>
</table>
Like I've told plenty of other people, you shouldn't be using divisions inside table cells.
This will achieve the exact same effect, without the divisions:
<table style="width: 100%; text-align: justify;">
<tr>
<td style="margin-right: 15px; background-color: gray;">
Some text here
</td>
<td style="margin-right: 15px; background-color: gray;">
column 2 text here
</td>
<td style="margin-right: 15px; background-color: gray;">
Column 3 text here
</td>
<td style="background-color: gray;">
Last column text here
</td>
</tr>
</table>
If you get rid of the divs and apply your styles and content directly to the table cells you will get the effect you want.
In case there is no special purpose of using div tag inside td. I would just do it without div. add style to td tag.
Mamu, I would suggest that you do not use inline style elements. Instead of styling your table tags it would be far more efficient, and better to add the the following between your <head> tags:
<style type="text/css">
table {width:100%; text-align:justify;}
table td {margin-right:15px; background-color:gray;}
</style>
Using only those two lines of code you can apply the same elements consistently across your entire website. If you only wanted to apply them to some elements, you could create classes by adding a "." to a name of your choice:
<style type="text/css">
.MyTable {width:100%; text-align:justify;}
.MyTable td {margin-right:15px; background-color:gray;}
</style>
And add the following to your HTML:
<table class="MyTable">
Note that class names are case sensitive. But this reusable code is far more efficient.
Furthermore, I would urge to consider the use of tables only if you are presenting tabular data. Tables load slower and are not SEO friendly. It would not be semantically correct to use them for layout. You should separate content from presentation whenever possible, and if it is layout you are after I would suggest using divs and other elements instead.