Hi I know this is a simple question. But I am unable to do it. I want to place images in a table. Everything is working fine in a new html file. But when I am trying to insert the table in my project file, the images are getting overlapped.They are not fitting in a table. What mistake am I doing? Kindly look at the image that is attached.
table,td,th {border: 3px solid black;padding: 15px}
<table>
<tr><th>Choose from the icons</th></tr>
<tr><td ><img src='http://www.freeiconspng.com/uploads/smiley-icon-1.png' width='20%'/></td></tr>
<tr><td ><img src='http://www.freeiconspng.com/uploads/smiley-icon-1.png'width=20%/></td></tr>
</table>
Try:
table,
td,
th {
border: 3px solid black;
padding: 15px
}
img.icon {
width: 20%;
height: auto;
}
<table>
<tr>
<th>Choose from the icons</th>
</tr>
<tr>
<td>
<img src='heart1.png' class="icon" />
</td>
</tr>
<tr>
<td>
<img src='heart1.png' class="icon" />
</td>
</tr>
</table>
this may works. if you have any query, you can comment and ask further.
this solution fix your image inside <td>
table,
td,
th {
border: 3px solid black;
padding: 15px
}
td img {
max-width: 100%;
height: auto;
}
<table>
<tr>
<th>Choose from the icons</th>
</tr>
<tr>
<td>
<img src='heart1.png' class="icon" />
</td>
</tr>
<tr>
<td>
<img src='heart1.png' class="icon" />
</td>
</tr>
</table>
First you should always specify both height and width.
Second you should specify the width in pixels. AFAIK, the image tag does not support percentages.
IMG tag
Third, your second image does not have quotes around the width value.
Ideally you should resize the image to work without a width and height defined.
The best way might be to set the image as the background image of the cell.
Related
I have table defined in style like this:
<style>
table.box-left, table.box-left td, table.box-left th {
border: 1px solid #005a8c;
border-collapse: collapse;
width: 320px;
box-shadow: 1px 1px 1px #888888;
margin-bottom: 5px;
}
table.box-left thead tr .lightgreen {
height: 20px;
background-color: #8DB135;
}
</style>
In the table cell I have an image and a paragraph of text, for some reason text doesn't wrap around the image. Can someone help?????
<table class="box-left">
<thead>
<tr>
<th class="lightgreen">Test</th>
</tr>
</thead>
<tr>
<td>
<img src="../images/54.jpg" width="80" height="140" />
Hello, for some reason text doesn't display correctly as it supposed to. Can you help? Thanks so much in advance!!!
</td>
</tr>
</table>
Just add img { float: left; } and it should work as expected.
Check this fiddle.
Modify HTML like this:
<table class="box-left">
<thead>
<tr>
<th class="lightgreen">Test</th>
</tr>
</thead>
<tr>
<td>
<div id="floated">
<img src="../images/54.jpg" width="80" height="140" style="position: relative;" />
</div>
Hello, for some reason text doesn't display correctly as it supposed to. Can you help? Thanks so much in advance!!!
Hello, for some reason text doesn't display correctly as it supposed to. Can you help? Thanks so much in advance!!!
Hello, for some reason text doesn't display correctly as it supposed to. Can you help? Thanks so much in advance!!!
</td>
</tr>
</table>
And add this to CSS:
#floated{
float: left;
}
Check This JSFiddle : http://jsfiddle.net/jhts4hxe/3/
I'm writing a simple form for sending some data to a database.
I use it in my own company so I don't need to have a perfect style.
I am using a table for the layout (this is okay in this application).
<table width="500px" style="border:1px solid black; overflow:hidden">
<tr>
<td>Born <input type="text" name="nato_pf" /></td>
</tr>
</table>
I would like to set the width of the input text to 100% (to the end of the line) , but, if I do that, the input text wraps to a new line.
I have found solutions only using div and they are not for me at the moment.
EDIT: Sometimes I have two input (with different sizes) on the same line, so I think I cannot add other td tags.
http://jsfiddle.net/gmmr7/1
table {
border:1px solid black;
width: 200px;
}
.left {
float: left;
}
.left2 {
overflow: hidden;
padding: 0 4px;
}
.left2>input {
width: 100%
}
<table>
<tr>
<td>
<label class="left">Born</label>
<div class="left2">
<input type="text" name="nato_pf" />
</div>
</td>
</tr>
</table>
<table width="500px" style="border: 1px solid black; verflow: hidden">
<tr>
<td style="width: 50px;">
Born
</td>
<td>
<input type="text" name="nato_pf" style="width: 99%;" />
</td>
</tr>
</table>
99% of width because with 100% the textbox goes over the table's border :)
and also give a width to the first td ;)
jsFiddle http://jsfiddle.net/2yZmB/
you can define another td element
<table width="500px" style="border:1px solid black; overflow:hidden">
<tr>
<td>Born </td><td><input type="text" name="nato_pf" /></td>
</tr>
</table>
css
input{
width:99%;
}
I have created nested tables with the following markup, where the first table contains an example of a typical row:
<table class="outer">
<tr>
<td>
<table class="column" id="left_column">
<tr>
<td>
<table class="cell" id="t1">
<tr>
<td>
<asp:Literal runat="server" ID="t1r2c0" />
</td>
<td>
<asp:Literal runat="server" ID="t1r2c1" />
</td>
<td class="image">
<span id="s1" runat="server">
<asp:PlaceHolder ID="p1" runat="server">
</asp:PlaceHolder>
</span>
</td>
<td>
<asp:Literal runat="server" ID="t1r2c3" />
</td>
<td class="gray">
<asp:Literal runat="server" ID="t1r2c4" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="cell" id="t2">
<!-- ... -->
</table>
</td>
</tr>
</table>
</td>
<td>
<table class="column" id="rightColumn">
<!-- ... -->
</table>
</td>
</tr>
</table>
And here is the relevant CSS:
#rightColumn table, #leftColumn table {
width: 100%;
}
.cell {
border-collapse: collapse;
border: 2px solid black;
margin: 5px;
}
.cell td {
border-collapse: collapse;
border: 2px solid black;
text-align: center;
vertical-align: middle;
}
.image {
padding: 0;
margin: 0;
width: 75px;
}
In Firefox this renders like this:
but in IE6 it renders like this:
Two things are going wrong in IE:
The right hand border is missing from every table.
The 2nd and 3rd tables in the right hand column have arbitrary sizes for the last column despite the fact that these cells are class "image" and should have a fixed width of 75px.
Any advice is greatly appreciated.
EDIT: #rightColumn table, #leftColumn table { width: 100%; background: Red }
Check whether IE is rendering your page is in quirks mode or not. Quirks mode often affects element widths in particular, so I would suggest that this is a very strong candidate for the cause of your problem.
You should make sure the page is in standards mode in order to render correctly.
This is easily done by making sure the page has a valid doctype at the top of the page.
If you don't have a doctype, you can add any valid doctype to get it working in standards mode, but if you're not sure which one to use, just use the following:
<!DOCTYPE html>
Hope that helps.
So I have this certain table. I know I'm not supposed to use table for layout, but in this case I'm forced to.
I need to style a specific TD's cell-spacing (the TD with the class .ritey). I know I have to target the TABLE to set its cell-spacing, but I don't want other TDs got affected. I only need to style this single TD.
Is there any way to do this?
Here is a quick rough sketch with MS Paint, I hope this explains what I need:
In the overall layout there will be multiple rows (multiple TR). In this question I only show one row. I need all columns (all TDs) to remain unchanged, except for .ritey. I want .ritey to have 10px margin around it (margin, not padding). I hope this explains better!
.
And here is what I got in my HTML. I tried td.ritey { border-spacing:10px; } but it does not seem to work.
<table width='100%' border='0' cellspacing='1' cellpadding='3' class='postable'>
<tr>
<td valign='middle' class='row4 uname' colspan='2'>
<div class='name'>
<a href='#'>Guest</a>
</div>
</td>
</tr><tr>
<td width='100%' valign='top' class='ritey'>
<div class='postcolor'>
Post content
</div>
</td><td valign='top' class='lefty'>
<div class='postdetails'>
Details
</div>
</td>
</tr></table>
Any help is really appreciated.
See fiddle for code and demo
fiddle: http://jsfiddle.net/kDKEw/2/
demo: http://jsfiddle.net/kDKEw/2/embedded/result/
HTML:
<table cellspacing="1" cellpadding="3" border="1" width="100%" class="postable">
<tbody><tr>
<td valign="middle" colspan="2" class="row4 uname">
<div class="name">
Guest
</div>
</td>
</tr><tr style="height: 36px;">
<td width="100%" valign="top" class="ritey" style="width: 90%; position: absolute; margin: 4px;">
<div class="postcolor">
Post content
</div>
</td><td valign="top" class="lefty" style="float: right; width: 6%;">
<div class="postdetails">
Details
</div>
</td>
</tr>
</tbody>
</table>
SS:
Updated Fiddle as per image illustration ( http://i.imgur.com/o56CD.png ): given by deathlock
Fiddle: http://jsfiddle.net/7xfxF/1/
Demo: http://jsfiddle.net/7xfxF/1/embedded/result/
SS:
In CSS, you would use padding for cellpadding and border-spacing for cellspacing. Here's the working code:
EDIT
I revised the CSS according to the image you provided. I added extra styling for the postcolor class. See the updated CSS and Fiddle. I also updated the screenshot.
If you want the borders to collapse, change border-collapse to collapse and remove the border-spacing property.
<style type="text/css">
table.postable {
border-collapse: separate !important;
border-spacing: 1px;
}
table.postable td {
border:1px solid black;
padding: 5px;
}
td.ritey {
border: 0px !important;
padding: 10px 5px 10px 5px !important;
}
td.lefty {
padding: 10px 5px 10px 5px !important;
}
div.postcolor {
margin: 3px;
padding: 10px;
border: 1px solid black;
}
</style>
<table width='100%' class='postable'>
<tr>
<td colspan='2'>
<div class='name'>
<a href='#'>Guest</a>
</div>
</td>
</tr>
<tr>
<td width='100%' valign='top' class='ritey'>
<div class='postcolor'>
Post content
</div>
</td>
<td valign='top' class='lefty'>
<div class='postdetails'>
Details
</div>
</td>
</tr>
</table>
OUTPUT:
See this jsFiddle for a demonstration.
I have an image, which I am trying to create a border around it, to make it look nicer. I have sliced an image, to have an image for top right, top, top left, right, left, bottom right, bottom left and bottom..
The border is all fine, except for the corners, can any body help me out here? I think Im missing some CSS. The image appears to be sliced fine - but Im open to suggestions.
Thanks and kind regards
This is the HTML
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td >
<img alt="Corner" src="graphics/bgTopLeft.PNG" width="15px" height="13px" /></td>
<td class="AdminBoxTitleMainTop" >
</td>
<td>
<img alt="Corner" src="graphics/bgTopRight.PNG" /> </td>
</tr>
<tr>
<td class="AdminBoxTitleMainLeft">
</td>
<td> <img id="afMgrPhoto" alt="Affiliate Manager" src='#' runat="server" />
</td>
<td class="AdminBoxTitleMainRight">
</td>
</tr>
<tr>
<td>
<img alt="Corner" src="graphics/bgBottomLeft.PNG" /> </td>
<td class="AdminBoxTitleMainBottom">
</td>
<td >
<img alt="Corner" src="graphics/bgBottomRight.PNG" /> </td>
</tr>
</table>
This is the CSS
.AdminBoxTitleMainTop {
background-image: url(../graphics/bgTop.PNG);
background-repeat: repeat-x;
height: 17px;
}
.AdminBoxTitleMainBottom {
background-image: url(../graphics/bgBottom.PNG);
background-repeat: repeat-x;
height: 17px;
}
.AdminBoxTitleMainRight {
background-image: url(../graphics/bgRight.PNG);
background-repeat: repeat-y;
height: 17px;
}
.AdminBoxTitleMainLeft {
background-image: url(../graphics/bgLeft.PNG);
background-repeat: repeat-y;
height: 17px;
}
You can try setting the width property for the rightmost and the leftmost cells (td elements). I guess you are trying to give a border using supplementary images which is not the best practice in HTML unless you're doing some rounded corner stuff. But if you don't want rounded corners. You can just use an IMG element and give a border (event with some padding) to make it look nice (and fewer HTML codes, which is nicer.)
<img style="padding: 5px; border: solid 1px #dedede" src="img.png" alt="" />
You can event shift the border color for the mouseover event of the image (works only if you place the img element inside element) without any javascript.
<a href='#'><img src="img.png" alt="" /></a>
Style:
a img
{
border: solid 1px #dedede;
padding: 5px;
}
a:hover img
{
border-color: #069;
}