I'm trying to create a table containing images in a gallery along with their names right below them. I'd like to center the images vertically in each column, and have the names aligned at the bottom of the <td>, but I can't seem to get it to work. This is my code so far:
table.gallery {
width:100%;
text-align: center;
table-layout: fixed;
}
table.gallery td {
padding: 10px 10px 10px 10px;
width:33%;
overflow: hidden;
}
table.gallery td img{
vertical-align: middle;
}
table.gallery td span.desc {
vertical-align: bottom;
}
And my Php code to display the table:
<table border="0" class="gallery"><tr>
<?php
$curtd = -1;
foreach ($img_arr as $item) {
$curtd++;
if ($curtd >= 3){
echo '</tr><tr>';
$curtd = 0;
}
echo '<td><center><img src="'.$item['thumb'].'" /></center>
<span class="desc">'.$item['title'].'</span></td>';
}
?>
</tr></table>
My images appear to center vertically with no problems, but the names still appear directly under the images, rather than at the bottom of the cell. How can I fix this?
EDIT: Here's the HTML generated by the Php code (removed URLs and stuff just for the sake of saving space):
<table border="0" class="gallery"><tr>
<td>
<center><img src="[URL]" /></center>
<span class="desc">[name]</span>
</td>
<td>
<center><img src="[URL]" /></center>
<span class="desc">[name]</span>
</td>
<td>
<center><img src="[URL]" /></center>
<span class="desc">[name]</span>
</td>
</tr><tr>
<td>
<center><img src="[URL]" /></center>
<span class="desc">[name]</span>
</td>
<td>
<center><img src="[URL]" /></center>
<span class="desc">[name]</span>
</td>
<td>
<center><img src="[URL]" /></center>
<span class="desc">[name]</span>
</td>
</tr></table>
Please try this:
Use two tr tags and in first - image - , next - name -
Related
I'm stuck with a problem. I need to print the page with the logo but the problem is that the logo is shown in the browser but in the print preview (CTRL P) the logo is not displayed.
For any guidance I would be very thankful.
This is the html code and css media print code
/* ## removed here since they are specific to ASP.NET MVC */
#media print {
#page {
size: A4 landscape;
max-height: 100%;
max-width: 100%;
position: fixed;
}
.prints {
height: 19.2cm;
page-break-after: avoid;
border: black 1px solid;
}
.row {
page-break-after: avoid;
}
}
/*! Generated by Font Squirrel (https://www.fontsquirrel.com) on July 30, 2018 */
label {
font: c
}
<table align="center" style="padding-left:10px;">
<tbody>
<tr>
<td colspan="3">
<h4 style="text-align:center;padding-left:25px; font-family:Calibri"><b> CHALLAN FORM </b></h4>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td>
<div>
<label style="padding-left:10px;width:145px;">
<span style="line-height:1; width: 135px; font-size:26px; font-family:'Chursaechsische Fraktur';"><strong>Baitul Huda</strong></span>
<span style="line-height:1;border:0px; width:100px; font-size:12px; font-family:'Adobe Devanagari';">High School For Girls</span>
</label>
</div>
</td>
<td rowspan="2" style="width:30px;padding-right:0px; padding-left: 10px;">
<img src="~/images/nku_02.png" height="70" width="70" alt="Bail ul huda logo" />
</td>
<td style="padding-left:10px;">
<div style="padding-left:5px;">
<label style="width:120px;padding-top:0px;padding-bottom:0px;">
<span style="line-height:0; width: 160px; font-size:26px; font-family:'UL Sajid Heading';">بیت الھدیٰ</span>
<span style="line-height:1; width:100px;padding-left:10px; font-size:16px; font-family:'Al Qalam Quran 2A';"> ھایئ سکول فارگرلز</span>
</label>
</div>
</td>
</tr>
</tbody>
</table>
I Found the solution
Img is not coming in print view because there is a missing of a div
<td rowspan="2">
<div style="padding-left:10px;width:80px;height:50px">
<img src="/images/offical_Logo_Baitul_Huda.jpeg" class="img-responsive" style="height:50px ; width:100px" alt="">
</div>
</td>
As i add the div the logo start displayed in print view
I'm running into a problem in my HTML code. I am trying to display a button when you hover over a row in a table. Right now the button only displays when you hover near it but I need it to show when you hover over anywhere on that row. Can anyone help explain how to do this?
.button {
opacity: 0;
}
.button:hover {
display: inline-block;
opacity: 1;
}
<table>
<tr>
<div class="button">
</div>
<td><img src="/app/images/todo/todos_incomplete_blue.svg" /></td>
<td>Make a To Do List</td>
<td>Me Myself and I</td>
<td>Whenever I want</td>
<td>69%</td>
<td>
<div class="button">
<img src="/app/images/master/actions_btn.svg" />
</div>
</td>
</tr>
</table>
Right now, a button will only show when you over it directly. In order to show a button when its table row is hovered, set your CSS definition to target buttons that are inside of hovered rows:
tr:hover .button { ... }
Also:
<div> elements that are inside <tr> but not <td> are invalid, per the permitted content of <tr> elements. I have removed them, but you could wrap them in <td> elements if you need them.
I took the liberty of putting the .button images inside their <a> elements, although I'm not sure that's what you intended.
I noticed that the hover effect doesn't work over spaces between cells, which causes gaps in the hover area. So I set border-collapse:collapse; and padding the cells individually.
table {
border-collapse: collapse;
}
td {
padding: 5px;
}
.button {
opacity: 0;
}
tr:hover .button {
opacity: 1;
}
<table>
<tr>
<td><img src="//lorempixel.com/20/20/abstract/1/" width="20" height="20" /></td>
<td>Make a To Do List</td>
<td>Me Myself and I</td>
<td>Whenever I want</td>
<td>69%</td>
<td>
<div class="button">
<a href="#">
<img src="//lorempixel.com/20/20/abstract/1/" width="20" height="20" />
</a>
</div>
</td>
</tr>
<tr>
<td><img src="//lorempixel.com/20/20/abstract/2/" width="20" height="20" /></td>
<td>Make a To Do List</td>
<td>Me Myself and I</td>
<td>Whenever I want</td>
<td>69%</td>
<td>
<div class="button">
<a href="#">
<img src="//lorempixel.com/20/20/abstract/2/" width="20" height="20" />
</a>
</div>
</td>
</tr>
</table>
It's my understanding that from explanation
I am trying to display a button
that initially it is hidden? If so, just trigger hover over a button with jQuery.
So, lets say wee add ID to : <tr id="myrow"> and in <div class="button"> we also add ID: <div class="button" id="mybtn">
Then in jQuery we have:
$("#myrow").mouseover(function() {
$("#mybtn").show() // if it was hidden show it
$("#mybtn").trigger("mouseover"); // trigger as if mybtn was mouseovered
});
I am trying to make the following working the way I want it to. I want to have an Input element changing its width to the provided cell's width. Here is code:
<table style="margin-top:10px;width:80.5%;font-size:14px">
<tr>
<td style="text-align:left;width:5%">
<span translate>CaseNumber</span>:
</td>
<td style="text-align:left;width:5%">
<span>
<input easyui-textboxreadonly readonly ng-model="caseid" style="width:80px;height:32px;background-color:#72A4D2"/>
</span>
</td>
<td style="text-align:left;width:2%">
<span translate>Title</span>:
</td>
<td style="width:88%">
<div style="width:100%">
<input easyui-textbox data-options="required:true" ng-model="title" style="height:32px;"/>
</div>
</td>
</tr>
</table>
I want the input in the last cell to take all the width of the cell it's in.
Unless I provide a width of the input it's not happening.
Put width: 100% on the input element itself, not on a div surrounding it (you can get rid of that div altogether in fact).
Demo: http://jsfiddle.net/1qda1jpx/2/
table {
border: 1px solid blue;
}
td {
border: 1px solid lightgray;
}
input {
width: 100%;
}
<table style="margin-top:10px;width:80.5%;font-size:14px">
<tr>
<td style="text-align:left;width:5%">
<span translate>CaseNumber</span>:
</td>
<td style="text-align:left;width:5%">
<span>
<input easyui-textboxreadonly readonly ng-model="caseid" style="width:80px;height:32px;background-color:#72A4D2"/>
</span>
</td>
<td style="text-align:left;width:2%">
<span translate>Title</span>:
</td>
<td style="width:88%">
<input easyui-textbox data-options="required:true" ng-model="title" style="height:32px;"/>
</td>
</tr>
</table>
You need to set width: 100% for that input element. Otherwise it wont happen.
I have this JSFiddle: Click here
<table class="findus-main-table">
<tr>
<td>
<img class="static-map" onClick="swap();" id="static-map-id" />
</td>
<td style="text-align: center; vertical-align:bottom; position: relative;">
<span style="font-size: 22px; font-weight: bold;">The address I want here</span>
<!-- the inner table for location and distance and phone number -->
<table style="text-align:left;" cellspacing="10">
<tr>
<td style="vertical-align:top">
<div>
<div>Phone: (613)-123-1234</div>
<div>Distance: 0.123km</div>
</div>
</td>
<td>
<div><b>Store Hours</b>
</div>
<div>Mon - Fri: 8am - 2am</div>
<div>Sat & Sun: 10am - 12am</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
What I want is to position the address to the top while the phone number and hours stays at the bottom. I tried using absolute but it wraps the text of the address which i really dont want.
How can I do it?
besides the fact that you shouldn't be using inline styling, is this what you're looking for?
<span style="font-size: 22px; font-weight: bold;position: absolute;top: 0;left: 0;right: 0;">
FIDDLE
instead of using position:absolute witch should be the last thing anyone should try ,I use vertical-align:top
here is a fiddle.and here is my css :
.address{
text-align:center;
font-size:22px;
text-align: center;
font-size: 22px;
height: 78px;
padding: 0;
vertical-align: top;
}
How can entire table cell be hyperlinked in html without javascript or jquery?
I tried to put href in td tag itself but its not working at least in chrome 18
<td href='http://www.m-w.com/dictionary/' style="cursor:pointer">
Try this:
HTML:
<table width="200" border="1" class="table">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
CSS:
.table a
{
display:block;
text-decoration:none;
}
I hope it will work fine.
Try this way:
<td> </td>
Easy with onclick-function and a javascript link:
<td onclick="location.href='yourpage.html'">go to yourpage</td>
Why not combine the onclick method with the <a> element inside the <td> for backup for non-JS? Seems to work great.
<td onclick="location.href='yourpage.html'">Link</td>
Here is my solution:
<td>
<div class="item-container">
<img class="icon" src="/iconURL" />
<p class="name">
SomeText
</p>
</div>
</td>
(LESS)
td {
padding: 1%;
vertical-align: bottom;
position:relative;
a {
height: 100%;
display: block;
position: absolute;
top:0;
bottom:0;
right:0;
left:0;
}
.item-container {
/*...*/
}
}
Like this you can still benefit from some table cell properties like vertical-align.(Tested on Chrome)
Problems:
(User: Kamal) It's a good way, but you forgot the vertical align problem! using this way, we can't put the link exactly at the center of the TD element! even with vertical-align:middle;
(User: Christ) Your answer is the best answer, because there is no any align problem and also today JavaScript is necessary for every one... it's in every where even in an old smart phone... and it's enable by default...
My Suggestion to complete answer of (User: Christ):
HTML:
<td style="cursor:pointer" onclick="location.href='mylink.html'"><a class="LN1 LN2 LN3 LN4 LN5" href="mylink.html" target="_top">link</a></td>
CSS:
a.LN1 {
font-style:normal;
font-weight:bold;
font-size:1.0em;
}
a.LN2:link {
color:#A4DCF5;
text-decoration:none;
}
a.LN3:visited {
color:#A4DCF5;
text-decoration:none;
}
a.LN4:hover {
color:#A4DCF5;
text-decoration:none;
}
a.LN5:active {
color:#A4DCF5;
text-decoration:none;
}
you can give an <a> tag the visual behavior of a table cell:
HTML:
<table>
<tr>
Cell 1
<td>Cell 2</td>
</tr>
</table>
CSS:
tr > a {
display: table-cell;
}
I have seen this before when people are trying to build a calendar. You want the cell linked but do not want to mess with anything else inside of it, try this and it might solve your problem.
<tr>
<td onClick="location.href='http://www.stackoverflow.com';">
Cell content goes here
</td>
</tr>
Not exactly making the cell a link, but the table itself. I use this as a button in e-mails, giving me div-like controls.
<a href="https://www.foo.bar" target="_blank" style="color: white; font-weight: bolder; text-decoration: none;">
<table style="margin-left: auto; margin-right: auto;" align="center">
<tr>
<td style="padding: 20px; height: 60px;" bgcolor="#00b389">Go to Foo Bar</td>
</tr>
</table>
</a>
If you want use this way in php Do the following
<?php
echo ("
<script type = 'text/javascript'>
function href() {
location.href='http://localhost/dept';
}
</script>
<tr onclick='href()'>
<td>$id</td>
<td>$deptValue</td>
<td> $month </td>
<td>100%</td>
</tr>
");
?>