Center link text over image - html

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;
}

Related

How to change position of a specfic <td> element inside a HTML table

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>

Keeping size fixed even If td has large content inside it

In the Calendar Widget for the fourth row there is large text so its not fitting in single line so its size is increasing & View All button is also overlapping the edge of the widget. the number of row is fixed that means it can show maximum 5 rows at a time but the content of each row may have larger text. so when its not fitting in single line its giving me the trouble. i have tried few css trick but did not work. i need help to fix the size of its content so the designs works well.I am dot net developer but not a designer so not so much expert with css design. Please help me .
This is my aspx Code.
<table style="border: 0px; width: 500px;">
<tr>
<td style="width: 55px;"><img alt="" src="/Images/DeptIcons/Administration.png" /></td>
<td class="deptHeader">Calendar Editor</td>
</tr>
</table>
<hr style="border-top: 1px solid #79767b; margin-bottom: 20px;" />
<div style="position: relative;"><img alt="" src="/Images/ctnrTop.png" /></div>
<div style="background-image: url('/Images/ctnrBG.gif'); position: relative; margin-top: -5px; padding: 15px 0px 0px 15px;" class="cntrFont">
<table width="927" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnRebind" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Button UseSubmitBehavior="false" ID="btnRebind" runat="server" Style="display: none; width: 0px; height: 0px;
border: none; font-size: 0px; line-height: 0px;" OnClick="btnRebind_Click" />
<table cellpadding="4" cellspacing="0">
<tr>
<td colspan="4" align="right"><input type="button" onclick="addResult()" value="Add Calendar Event" class="fancyButton" /></td>
</tr>
<tr>
<td style="width: 30px; text-align: center;"></td>
<td style="width: 180px;"><b>Event Name</b></td>
<td style="width: 160px;"><b>Event Date</b></td>
<td></td>
</tr>
<asp:Repeater ID="rptEvents" runat="server">
<ItemTemplate>
<tr>
<td style="width: 30px; text-align: center;"><img src="../Images/icoStar.png" style="width: 15px; height: 15px; margin-top: 4px;" alt="Event" /></td>
<td><a class="calendarName" href="javascript:void(0);" onclick='showSearchResult(<%#Eval("CalID")%>,1);'><%# DataBinder.Eval(Container.DataItem, "calEvent")%></a></td>
<td><%# Convert.ToDateTime(Eval("calEventDate").ToString()).ToString("MMMM dd yyyy") %></td>
<td></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</td>
</tr>
</table>
</div>
<table style="border: 0px; width: 500px;">
<tr>
<td style="width: 55px;"><img alt="" src="/Images/DeptIcons/Administration.png" /></td>
<td class="deptHeader">Calendar Editor</td>
</tr>
</table>
<hr style="border-top: 1px solid #79767b; margin-bottom: 20px;" />
<div style="position: relative;"><img alt="" src="/Images/ctnrTop.png" /></div>
<div style="background-image: url('/Images/ctnrBG.gif'); position: relative; margin-top: -5px; padding: 15px 0px 0px 15px;" class="cntrFont">
<table width="927" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnRebind" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Button UseSubmitBehavior="false" ID="btnRebind" runat="server" Style="display: none; width: 0px; height: 0px;
border: none; font-size: 0px; line-height: 0px;" OnClick="btnRebind_Click" />
<table cellpadding="4" cellspacing="0">
<tr>
<td colspan="4" align="right"><input type="button" onclick="addResult()" value="Add Calendar Event" class="fancyButton" /></td>
</tr>
<tr>
<td style="width: 30px; text-align: center;"></td>
<td style="width: 180px;"><b>Event Name</b></td>
<td style="width: 160px;"><b>Event Date</b></td>
<td></td>
</tr>
<asp:Repeater ID="rptEvents" runat="server">
<ItemTemplate>
<tr>
<td style="width: 30px; text-align: center;"><img src="../Images/icoStar.png" style="width: 15px; height: 15px; margin-top: 4px;" alt="Event" /></td>
<td> <div title="<%# DataBinder.Eval(Container.DataItem, "calEvent")%>" style="width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis"><a class="calendarName" href="javascript:void(0);" onclick='showSearchResult(<%#Eval("CalID")%>,1);'><%# DataBinder.Eval(Container.DataItem, "calEvent")%></a></div></td>
<td><%# Convert.ToDateTime(Eval("calEventDate").ToString()).ToString("MMMM dd yyyy") %></td>
<td></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</td>
</tr>
</table>
</div>
You may want to take a look at combining the text-overflow: ellipsis css rule with overflow: hidden. For this to work, the cell must also have a fixed width, and the whitespace: nowrap tells it not to wrap long text. This will show there's more text, and you can set the cell title to the full text content so a mouseover will hint the name of the entry. Please use external css files. I just put this inline as an example.
<asp:Repeater ID="rptEvents" runat="server">
<ItemTemplate>
<tr>
<td style="width: 30px; text-align: center;"><img src="../Images/icoStar.png" style="width: 15px; height: 15px; margin-top: 4px;" alt="Event" /></td>
<td title="<%# DataBinder.Eval(Container.DataItem, "calEvent")%>" style="width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis"><a class="calendarName" href="javascript:void(0);" onclick='showSearchResult(<%#Eval("CalID")%>,1);'><%# DataBinder.Eval(Container.DataItem, "calEvent")%></a></td>
<td><%# Convert.ToDateTime(Eval("calEventDate").ToString()).ToString("MMMM dd yyyy") %></td>
<td></td>
</tr>
</ItemTemplate>
</asp:Repeater>
EDIT: Sorry, My mistake... those css rules won't apply to a <td>. You may want to start considering dropping tables entirely in favour of <div>s, or insert a <div> into the cell, like below:
table {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
}
td {
padding: 5px;
border: 1px solid;
margin: 0;
}
td:first-of-type {
width: 30px;
}
.event-name {
max-width: 200px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
</head>
<body>
<table>
<tr>
<td><i class="fa fa-star"></i></td>
<td><div title="This is a very loooooooong text! There can be nothing longer than it" class="event-name">This is a very loooooooong text! There can be nothing longer than it</div></td>
<td>Friday, August 19, 2016</td>
<td></td>
</tr>
</table>
</body>
</html>

remove client table spacing between rows

I have the following table:
For some reason, When I render this there is an enormous space between each row! I have searched everywhere and I just don't know how to eliminate the space. I tried manually setting the height of each row but that still did not prove useful, the default huge space overrides everything i throw at it. Any suggestions?
<table style="display:block;">
<tr>
<td class="auto-style1"><p>תעודת זהות</p></td>
<td><telerik:RadTextBox runat="server" id="txtId" Skin="Metro"/></td>
</tr>
<tr>
<td class="auto-style1"><p>סיסמא</p></td>
<td>
<telerik:RadTextBox ID="txtPassword" runat="server" Skin="Metro" />
</td>
</tr>
<tr>
<td class="auto-style1"><p>שם פרטי</p></td>
<td>
<telerik:RadTextBox ID="txtfName" runat="server" Skin="Metro" />
</td>
</tr>
<tr>
<td class="auto-style1"><p>שם משפחה</p></td>
<td>
<telerik:RadTextBox ID="txtlName" runat="server" Skin="Metro" />
</td>
</tr>
<tr>
<td class="auto-style1"><p>מספר טלפון</p></td>
<td>
<telerik:RadTextBox ID="txtmPhone" runat="server" Skin="Metro" />
</td>
</tr>
<tr>
<td class="auto-style1"><p>כתובת</p></td>
<td>
<telerik:RadTextBox ID="txtAddress" runat="server" Skin="Metro" />
</td>
</tr>
<tr>
<td class="auto-style1"><p>אימייל</p></td>
<td>
<telerik:RadTextBox ID="txtEmail" runat="server" Skin="Metro" />
</td>
</tr>
</table>
style:
<style type="text/css">
.auto-style1 {
width: 126px;
}
table tr td p {
font-family: Arial;
}
</style>
NOTE: In the design view of visual studio there is no spacing, it looks fine. only when rendering it comes out this way.
Try
<style type="text/css">
tr, td, p {
margin: 0px;
padding: 0px;
}
</style>`
A table always has a padding. So add to your CSS padding: 0;
<style type="text/css">
.auto-style1 {
width: 126px;
}
table tr td p {
font-family: Arial;
padding: 0;
}
</style>

td data not aligning properly

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;
}

IE8 Not Rendering Properly In IE8 Standards Compliant Mode

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