I have created some nested tables using the following markup where the first table contains an example of a row. The span inner HTML ultimately gets replaced with an image that is selected by the user through a dropdown menu.
<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="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>
Here is the relevant CSS:
.outer
{
border: none;
margin-left: auto;
margin-right: auto;
}
.outer td
{
vertical-align: top;
}
.column
{
border: none;
}
#rightColumn table, #leftColumn table
{
width: 100%;
}
.cell
{
border-collapse: collapse;
border: 2px solid black;
margin: 5px;
overflow: hidden;
}
.cell td
{
border-collapse: collapse;
border: 2px solid black;
text-align: center;
vertical-align: middle;
padding-left: 3px;
padding-right: 3px;
padding-top: 0px;
padding-bottom: 0px;
font-size: 10pt;
}
.cell .image
{
padding: 0;
margin: 0;
height: 20px;
width: 65px;
}
And here is a screenshot of how it displays in IE8 in standards compliance mode:
Notice that in the 3rd and 4th tables in the right hand column that the right most image field has an arbitrary width (showing white space on either side of the image) despite the fact that these cells are both class="image" and should have a fixed width of 65px. The DOCTYPE declaration is the first line of the rendered HTML and I have checked in developer tools that the mode of IE8 is standards compliant.
I would really like to fix these two table cells. Any advice is appreciated.
Regards.
EDIT: Here is the HTML for the affected tables:
<table class="cell" id="t5">
<tr><th colspan="9"><strong><asp:Literal runat="server" ID="t5r0c0" /></strong></th></tr>
<tr><td class="orange" colspan="4"><asp:Literal runat="server" ID="t5r1c0" /></td><td class="blue" colspan="4"><asp:Literal runat="server" ID="t5r1c4" /></td><td class="blue span2" rowspan="2"><asp:Literal runat="server" ID="t5r1c8" /></td></tr>
<tr><td class="blue" colspan="2"><asp:Literal runat="server" ID="t5r2c0" /></td><td class="blue" colspan="2"><asp:Literal runat="server" ID="t5r2c2" /></td><td class="blue" colspan="2"><asp:Literal runat="server" ID="t5r2c4" /></td><td class="blue" colspan="2"><asp:Literal runat="server" ID="t5r2c6" /></td></tr>
<tr><td class="green" colspan="2"><asp:Literal runat="server" ID="t5r3c0" /></td><td class="green" colspan="2"><asp:Literal runat="server" ID="t5r3c2" /></td><td class="green" colspan="2"><asp:Literal runat="server" ID="t5r3c4" /></td><td class="green" colspan="2"><asp:Literal runat="server" ID="t5r3c6" /></td><td class="image"><span id="s21" runat="server"><asp:PlaceHolder ID="p21" runat="server"></asp:PlaceHolder></span></tr>
</table>
<table class="cell" id="t6">
<tr><th colspan="9"><strong><asp:Literal runat="server" ID="t6r0c0" /></strong></th></tr>
<tr><td class="orange" colspan="4"><asp:Literal runat="server" ID="t6r1c0" /></td><td class="blue" colspan="4"><asp:Literal runat="server" ID="t6r1c4" /></td><td class="blue span2" rowspan="2"><asp:Literal runat="server" ID="t6r1c8" /></td></tr>
<tr><td class="blue" colspan="2"><asp:Literal runat="server" ID="t6r2c0" /></td><td class="blue" colspan="2"><asp:Literal runat="server" ID="t6r2c2" /></td><td class="blue" colspan="2"><asp:Literal runat="server" ID="t6r2c4" /></td><td class="blue" colspan="2"><asp:Literal runat="server" ID="t6r2c6" /></tr>
<tr><td class="green" colspan="2"><asp:Literal runat="server" ID="t6r3c0" /></td><td class="green" colspan="2"><asp:Literal runat="server" ID="t6r3c2" /></td><td class="green" colspan="2"><asp:Literal runat="server" ID="t6r3c4" /></td><td class="green" colspan="2"><asp:Literal runat="server" ID="t6r3c6" /></td><td class="image"><span id="s22" runat="server"><asp:PlaceHolder ID="p22" runat="server"></asp:PlaceHolder></span></td></tr>
</table>
EDIT: Adding style="width: 100%" to all colspan=2 elements:
The effect of doing this is different on the two affected tables. The first columns are greatly expanded while the others are greatly reduced.
Couple of ideas
I notice that it's intranet. You mention that the "mode" is IE8 standards - is that both browser and document? IE8 will do strange things in intranet mode.
Not sure if it's a typo, but table t5 doesn't close the last <td>
There's no chance that any spaces have crept into the markup when you're setting the contents of the image placeholder?
The issue may have something with the other table cells having colspan set. Try setting a width on the other cells, as answered on this question: Internet Explorer 8 table cell width bug with colspan set
Related
So, I have this table in which I need to place the td that contains the profile info further to the right as following:
Example
this is my HTML:
<table>
<tr>
<td>
<asp:Label ID="****" runat="server" CssClass="FieldLabelRqrd" Text="Name"></asp:Label>
</td>
<td>
<asp:Label ID="***" runat="server" Text="ID=****"></asp:Label>
</td>
<td colspan="4">
<div id="cssProfile">
<asp:Label ID="lblProfile" runat="server" Text="Profile:" CssClass="lblProfile"></asp:Label>
<asp:HyperLink ID="hlGoProfile" runat="server" ForeColor="blue" Target="_blank" CssClass="hlGoProfile" Text="Go"></asp:HyperLink>
</div>
</td>
</tr>
</table>
I tried colspan and rowspan but this does no work and here's the CSS
#cssProfile{
display:flex;
justify-content: start-flex;}
.lblProfile{
margin-left: auto;}
.hlGoProfile{
margin-left: auto;}
Give your table 100% width and add text-align: right to the cell in question.
BTW, you could remove that colspan, if you don't need it for any other purpose.
table {
width: 100%;
}
#cssProfile {
border: 1px solid red;
text-align: right;
}
<table>
<tr>
<td>
<asp:Label ID="****" runat="server" CssClass="FieldLabelRqrd" Text="Name">A</asp:Label>
</td>
<td>
<asp:Label ID="***" runat="server" Text="ID=****">B</asp:Label>
</td>
<td colspan="4">
<div id="cssProfile">
<asp:Label ID="lblProfile" runat="server" Text="Profile:" CssClass="lblProfile">C</asp:Label>
<asp:HyperLink ID="hlGoProfile" runat="server" ForeColor="blue" Target="_blank" CssClass="hlGoProfile" Text="Go">D</asp:HyperLink>
</div>
</td>
</tr>
</table>
How do I add a hover to this class in my CSS file? I can add a hover effect when I do not specify this class by using onmouseover, however I want to use both this CSS class and the hover.
tr.TableData td
{
background-color:white;
color:Black;
font-family:'Exo', sans-serif;
font-size: 16px;
height:60px;
border-bottom:1pt solid #E2E2E8;
padding: 0px 15px 0px 15px;
margin:0px;
width:199px;
font-weight:400;
}
This is my table. It is an ItemTemplate in a listview:
<ItemTemplate>
<tr class="TableData">
<td style="width: 30%;">
<table>
<tr class="NoBorder">
<td style="width: 20%;">
<img src='<%#Eval("standard_image") %>' alt="" width="80" onerror="this.src='Content/Images/placeholder.png';" />
</td>
<td>
<asp:Label ID="lblProductLine" runat="server" Text='<%#Eval("product_line")%>' />
</td>
</tr>
</table>
</td>
<td style="width: 24%;">
<asp:Label ID="lblModelNum" runat="server" Text='<%#Eval("model")%>' />
</td>
<td style="width: 16%;">
<asp:Label ID="lblSerialNum" runat="server" Text='<%#Eval("serial_number")%>' />
</td>
<td style="width: 12%; text-align:center;">
<asp:LinkButton runat="server" ID="SelectCategoryButton" CommandName="Select">
<img id="Img1" runat="server" src='<%#Eval("display_status") %>' alt="" width="20" />
</asp:LinkButton>
</td>
<td style="width: 18%; text-align:right;">
<asp:Label ID="lblShipDate" runat="server" Text='<%#Eval("date")%>' />
</td>
</tr>
</ItemTemplate>
If you mean a hover effect on the table-cell, then this should work:
tr.TableData td:hover {
background-color: red;
}
I'm trying to create a table with 2 table data and 2 table headers. After researching about html codes, I realized the way to shift the word to the left is Text-Align="Left" as written below. Unfortunately, it didn't work. I'm not using any CSS but just plain html codes.
Here is my codes :
<table style="width: 100%;">
<tr>
<th style="width: 189px; height: 23px;">Full Name:</th>
<td style="width: 1910px; height: 23px;">
<asp:Label ID="lblFullName" runat="server" Text="" Text-Align="Left"></asp:Label>
</td>
<th style="width: 21px; height: 23px;">Contact:</th>
<td style="width: 684px; height: 23px">
<asp:Label ID="lblContact" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>
<asp:Label /> will generate an <span> HTML tag, which is inline, and text-align to it is undefined, otherwise, set text-align of the td:
<td style="width: 1910px; height: 23px; text-align: center;">
<asp:Label ID="lblFullName" runat="server" Text=""></asp:Label>
</td>
Or make your <asp:Label /> as a block element:
<asp:Label ID="lblFullName" runat="server" Text=""
style="display: block; text-align: center;"
></asp:Label>
Try this...
<table style="width: 100%;">
<tr>
<td style="width: 189px; height: 23px;">Full Name:</td>
<td style="width: 1910px; height: 23px;">
<asp:Label ID="lblFullName" runat="server" Text="" Text-Align="Left"></asp:Label>
</td>
</tr>
<tr>
<td style="width: 21px; height: 23px;">Contact:</td>
<td style="width: 684px; height: 23px">
<asp:Label ID="lblContact" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>
I have an asp.net page that I'm trying to have an image be in the center of a table cell and have that image be a link to another page. I'm not too good with CSS but I tried a couple of different things and here's a screenshot of my outcome:
As you can see, the link is beside the image...I'd like to have that link be in the center of that image, but also have the image be clickable (as part of the link), like so:
Here's my table (keep in mind that this is part of a ASPx GridView control so it gets repeated for each row in it's datasource):
<table style="text-align: left; border-collapse: collapse; width: 100%">
<tr>
<td style="width: 5%;"><strong>Request ID</strong></td>
<td class="field">Date</td>
<td class="field">Requestor</td>
<td class="field">Status</td>
</tr>
<tr>
<td rowspan="4" align="center" style="position:relative;">
<%# Eval("RequestID") %>
</td>
<td>
<dx:ASPxLabel ID="labelRequestDate" runat="server" Text='<%# Eval("RequestDate") %>'></dx:ASPxLabel>
</td>
<td>
<dx:ASPxLabel ID="labelICAO" runat="server" Text='<%# Eval("ICAO") %>'></dx:ASPxLabel>
</td>
<td>
<dx:ASPxLabel ID="labelStatus" runat="server" Text='<%# Eval("Status") %>'></dx:ASPxLabel>
</td>
</tr>
<tr>
<td class="field" colspan="4">Summary</td>
</tr>
<tr>
<td colspan="4" valign="top">
<dx:ASPxLabel ID="labelSummary" runat="server" Text='<%# Eval("Summary") %>'></dx:ASPxLabel>
</td>
</tr>
<tr>
<td colspan="4">
<strong>Description:</strong>
<br />
<%# Eval("Description") %>
<br />
<br />
<strong>Comments</strong>
<br />
<%# Eval("Comments") %>
</td>
</tr>
</table>
The class "field" simply makes the text bold and sets the width to 10%.
Please keep in mind that I need this to work in IE7 and above, Chrome, and Firefox as well.
Any help is appreciated!
How about using a background image for a div tag which is wrapped around using an a tag?
Demo (You can remove border, just used it for test purpose)
<div><span>495</span></div>
div {
background-image: url('http://i.stack.imgur.com/aNy9C.jpg');
height: 90px;
width: 75px;
background-repeat: no-repeat;
border: 1px solid #f00;
position: relative;
}
div span {
position: absolute;
font-family: Arial;
font-size: 24px;
top:35%;
left: 20%;
}
a {
color: black;
}
I am new to Html designing. There is a small section of page that I have to design using html and CSS.
I have the back ground image with the image of login button. How to develop the Html of this so that it looks the same form in the attached picture.
Till now I have tried this but it is looking distorted:
<div class="dvEmployee">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<br />
<span class="EmployeeLable">Enter your employee number to vote </span>
</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="txtEmpID" ValidationGroup="vdLog" CssClass="input"
Height="49px" Width="161px" /><br />
<asp:RequiredFieldValidator ID="rfgEmp" runat="server" ValidationGroup="vdLog" ControlToValidate="txtEmpID"
ErrorMessage="Please enter employee number!"></asp:RequiredFieldValidator>
<asp:Label runat="server" ID="lblError" Text="" CssClass="lblError"></asp:Label>
</td>
<td>
<asp:ImageButton ID="imgBtn" runat="server" ImageUrl="Images/log_in_button.png" ValidationGroup="vdLog"
AlternateText="Log In" OnClick="imgBtn_Click" />
</td>
</tr>
</table>
</div>
Css classes that I have made:
.dvEmployee
{
background-image: url('images/log_in_window.png');
background-repeat: no-repeat;
width: 466px;
height: 206px;
position: relative; /* padding: 100px 30px;*/
margin: 180px 107px;
z-index: 2000px;
}
.lblError
{
font: Arial Regular 12pt #000000;
}
.EmployeeLable
{
font-family: Arial regular;
font-size: 29pt;
color: #404040;
line-height: 17px;
}
Just to give all, following image is how it is currently looking:
use this srtuctuer :
<table>
<tr>
<td colspan="2">
<br />
<span class="EmployeeLable">Enter your employee number to vote </span>
</td>
</tr>
<tr>
<td class="center">
<asp:TextBox runat="server" ID="txtEmpID" ValidationGroup="vdLog" CssClass="input"
Height="49px" Width="161px" /><br />
<asp:RequiredFieldValidator ID="rfgEmp" runat="server" ValidationGroup="vdLog" ControlToValidate="txtEmpID"
ErrorMessage="Please enter employee number!"></asp:RequiredFieldValidator>
<asp:Label runat="server" ID="lblError" Text="" CssClass="lblError"></asp:Label>
</td>
<td class="center">
<asp:ImageButton ID="imgBtn" runat="server" ImageUrl="Images/log_in_button.png" ValidationGroup="vdLog"
AlternateText="Log In" OnClick="imgBtn_Click" />
</td>
</tr>
</table>
css :
.center{
text-align:center;
}