Now resolved and updated. The primary issue was a css clash.
I have made a table that displays images and the images change in the center div based on mouse enter with JQ but i cannot seem to get the image to fit the main cell.
The desired result is as each image appears in the center, it should fit into the space perfectly, but i noticed when using fixed pixel sizing there is an issue with browser compatibility and the layout varies. When i tried with percentages it again does not seem to work as intended.
I have tried using css % and fixed pixel h/w but neither work as intended.
Am i approaching the desired result in the incorrect manner?
All advice appreciated, thanks!
http://www.digitalterrorrecords.com/home/featureTable.php << example of the below code
The html
<div>
<table>
<tr>
<td>
<? // Stacked Left BEGIN ?>
<table class=''>
<tr>
<td class='smallbox'><img class='small_feat' src='<? echo $ft_img_1 ;?>'></img></td> <!-- Artwork 1 -->
</tr>
<tr>
<td class='smallbox'><img class='small_feat' src='<? echo $ft_img_2 ;?>'></img></td> <!-- Artwork 2 -->
</tr>
<tr>
<td class='smallbox'><img class='small_feat' src='<? echo $ft_img_3 ;?>'></img></td> <!-- Artwork 3 -->
</tr>
<tr>
<td class='smallbox'><img class='small_feat' src='<? echo $ft_img_4 ;?>'></img></td> <!-- Artwork 4 -->
</tr>
</table>
<? // Stacked Left END ?>
</td>
<td>
<? // Main feature BEGIN ?>
<table>
<tr>
<td class='mainbox'>
<div>
<!--
<div> <? // LOAD BACKGROUND ?>
<img src='<? echo $ft_img_bg ;?>'></img>
</div>
-->
<div id='lf_1' class='messagepop'> <? // LOAD SELECTIONAL DIVS ?>
<img class='large_feat' src='<? echo $ft_fs_img_1 ;?>'></img>
</div>
<div id='lf_2' class='messagepop'> <? // LOAD SELECTIONAL DIVS ?>
<img class='large_feat' src='<? echo $ft_fs_img_2 ;?>'></img>
</div>
<div id='lf_3' class='messagepop'> <? // LOAD SELECTIONAL DIVS ?>
<img class='large_feat' src='<? echo $ft_fs_img_3 ;?>'></img>
</div>
<div id='lf_4' class='messagepop'> <? // LOAD SELECTIONAL DIVS ?>
<img class='large_feat' src='<? echo $ft_fs_img_4 ;?>'></img>
</div>
<div id='lf_5' class='messagepop'> <? // LOAD SELECTIONAL DIVS ?>
<img class='large_feat' src='<? echo $ft_fs_img_5 ;?>'></img>
</div>
<div id='lf_6' class='messagepop'> <? // LOAD SELECTIONAL DIVS ?>
<img class='large_feat' src='<? echo $ft_fs_img_6 ;?>'></img>
</div>
<div id='lf_7' class='messagepop'> <? // LOAD SELECTIONAL DIVS ?>
<img class='large_feat' src='<? echo $ft_fs_img_7 ;?>'></img>
</div>
<div id='lf_8' class='messagepop'> <? // LOAD SELECTIONAL DIVS ?>
<img class='large_feat' src='<? echo $ft_fs_img_8 ;?>'></img>
</div>
`</div>
</td>
</tr>
</table>
<? // Main feature END?>
</td>
<? // Stacked Right BEGIN ?>
<td>
<table>
<tr>
<td class='smallbox'><img class='small_feat' src='<? echo $ft_img_5 ;?>'></img></td> <!-- Artwork 5 -->
</tr>
<tr>
<td class='smallbox'><img class='small_feat' src='<? echo $ft_img_6 ;?>'></img></td> <!-- Artwork 6 -->
<tr>
<td class='smallbox'><img class='small_feat' src='<? echo $ft_img_7 ;?>'></img></td> <!-- Artwork 7 -->
</tr>
<tr>
<td class='smallbox'><img class='small_feat' src='<? echo $ft_img_8 ;?>'></img></td> <!-- Artwork 8 -->
</tr>
</table>
</td><? // Stacked Right END?>
</tr>
</table>
</div>
The css
td div {
height: 100%;
}
.small_feat {
width: 200px;
height: 200px;
border: solid 2px #ffffff;
}
.large_feat {
width: 800px;
height: 800px;
}
a.selected {
background-color:#1F75CC;
color:white;
z-index:100;
}
.messagepop {
background-color:#FFFFFF;
cursor:default;
display:none;
position:absolute;
z-index:50;
}
.smallbox {
width: 200px;
height: 200px;
}
The JQ
$.fn.slideFadeToggle = function (easing, callback) {
return this.animate({
opacity: 'toggle',
width: 'toggle'
}, "fast", easing, callback);
};
$(function () {
function select($link) {
$('.contact').each(function(index, l) {
var $pane = $($(l).attr('href'));
if ($pane.is(':visible')) {
$pane.slideFadeToggle();
}
});
$('.contact').removeClass('selected');
$link.addClass('selected');
$($link.attr('href')).slideFadeToggle();
}
function deselect($link) {
$($link.attr('href')).slideFadeToggle(function () {
$link.removeClass('selected');
});
}
$('.contact').mouseenter(function () {
var $link = $(this);
if ($link.hasClass('selected')) {
deselect($link);
} else {
select($link);
}
return false;
});
$('.close').live('click', function () {
deselect();
return false;
});
});
This is probably be the last possible answer... Check this out !
.messagepop {
background-color:#FFFFFF;
cursor:default;
display:none;
position:relative;
z-index:50;
width:100%;
}
To fix your styling issue remove the absolute positioning style from the messagepop class in your CSS. When you use absolute positioning it takes the element out of the natural flow of the page and it will no longer respect the height and width constraints of the parent element.
.messagepop {
background-color:#FFFFFF;
cursor:default;
display:none;
z-index:50;
}
i have looked at your page source and you have
.large_feat
{
width: 100%;
}
.large_feat_main
{
width: 800px;
}
however, you don't have a class .large_feat_main applied anywhere.
you have the .large_feat applied so it is stretching the image 100%,
change the width to 800px or change the class.
thanks
Check this out. As mentioned earlier, position:absolute was the problem.
.messagepop {
background-color:#FFFFFF;
cursor:default;
display:none;
position:relative;
z-index:50;
width:100%;
}
Related
I created a CRUD system and am trying to customize it to make it look better using Bootstrap.
Currently I have the table striped with the "table-striped" class, however, I am trying to change the thead to a different color as I am not a fan of the options given, dark or light.
I also tried using CSS to customize it, but the browser doesn't seem to be loading the CSS even though it says it is linked in the sources.
<table class="table bg-light table-striped table-bordered table-hover rounded">
<thead>
<tr>
<th>ID</th>
<th>PO Number</th>
<th>Site Name</th>
<th>Date Created</th>
<th>Last Updated</th>
<th> </th>
</tr>
</thead>
<tbody>
<?php foreach($data['records'] as $row): ?>
<?php if(isset($data['flash']['id']) && (int) $row['id'] === $data['flash']['id']): ?>
<tr class="table-success">
<?php else: ?>
<tr>
<?php endif; ?>
<td>
<?= $row['id'] ?>
</td>
<td>
<?= $row['poNum'] ?>
</td>
<td>
<?= $row['site_name'] ?>
</td>
<td>
<?= $row['created_at'] ? (new DateTime($row['created_at']))->format('Y-m-d H:i:s') : '' ?>
</td>
<td>
<?= $row['updated_at'] ? (new DateTime($row['created_at']))->format('Y-m-d H:i:s') : '' ?>
</td>
<td>
<img src="img/pencil-square.svg" title="edit" alt="edit" />
<?php if ($_SESSION['userRole'] === 'ADMIN'): ?>
<a onclick="return confirm_delete(<?= $row['id'] ?>);" href="delete.php?id=<?= $row['id'] ?>&page=<?= $data['currentPage'] ?>"><img src="img/trash.svg" class="spacer" title="delete" alt="delete" /></a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
You can use this style:
th {
background-color: blue;
color: white;
}
I don't know how you test the CSS, but make sure it works by first using the CSS Internal. Put this code in the <head> tag and test if your CSS code works.
<style type="text/css">
th {
background-color: blue;
color: white;
}
</style>
After you make sure that it works, just transfer the code to an external CSS file.
If the CSS doesn't take effect, try to figure out if it's not overwritten by another CSS somewhere by looking in the browser's developer console.
So you can try this:
.rounded th {
background-color: blue;
color: white;
}
You can also use !important but it's a good practice to not use this !important keyword as it may cause some conflicts somewhere else.
th {
background-color: blue !important;
color: white;
}
I am trying to print the page using window.print(). but when the row entry is multiplies and it is being shown in the other page, the header of the other page's table is devided between both of the pages. Here is the screenshot of what i am getting.
Here is my all code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>atop</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assests/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assests/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assests/css/bootstrap-theme.css">
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assests/css/bootstrap-theme.min.css">
<script src="<?php echo base_url();?>assests/js/jquery.min.js"></script>
<script src="<?php echo base_url();?>assests/js/bootstrap.min.js"></script>
<script src="<?php echo base_url();?>assests/datatables/jquery.dataTables.min.js"></script>
<script src="<?php echo base_url();?>assests/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" language="javascript" src="<?php echo base_url();?>assests/js/livejquery.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>assests/js/json2.js"></script>
<style type="text/css">
body {
background-color: #fff7b3;
/*font-size: 20px;*/
}
#border_setting {
border-style: solid;
border-color: #847259;
border-radius: 20px;
padding-bottom: 9px;
padding-right: 20px;
}
#font_white {
color: #ffffff;
}
#logo_setting{
padding-left: 50px;
}
#personal_table {
margin-top:25px;
padding-top:25px;
}
table, td, th {
border: 1px solid #847259;
text-align: left;
}
table {
border-collapse: collapse;
width: 100%;
position: relative;
}
th, td {
padding: 15px;
}
#media print {
thead {
page-break-inside:avoid;
/*page-break-inside:always;*/
/*page-break-before: avoid;*/
/*page-break-after: avoid;*/
/*position:initial;*/
}
}
/*table { page-break-inside:always; page-break-after:always; }*/
/* div { page-break-inside:avoid; }*/ /* This is the key */
/*tr { page-break-inside:always; page-break-after:always; }
td { page-break-inside:always; page-break-after:always; }
*/
/*thead { display:table-header-group; }
tfoot { display:table-footer-group; }*/
#invoice_border {
border-radius: 25px;
border-color: black;
background-repeat: repeat;
}
</style>
</head>
<body onload="window.print();">
<!-- <div class="wrapper">
-->
<!-- Content Wrapper. Contains page content -->
<!-- <div class="content-wrapper"> -->
<!-- Main content --> <!-- title row -->
<!--
<div class="row">
<div class="col-md-1">
<img src="../../image/GURUKRUPA-LOGO-transparent-512 x 512.png" width="100px" height="100px">
<h1>Hello</h1>
</div>
<div class="col-md-11">
<h1>Hello</h1>
</div>
</div>
-->
<!--<div class="row invoice-info">
<div class="col-xs-2 invoice-col">
-->
<!--</div>
<div class="col-xs-10 invoice-col">
<h1>GuruKrupa Offset</h1>
</div>table
</div>
-->
<!-- /.col -->
<!-- info row -->
<div class="row">
<img src="<?php echo base_url();?>assests/images/atop logo.png">
<br>
<br><br>
<div class="col-xs-10 invoice-col">
To ,
<address>
<strong><?php echo $customer_name;?></strong>
<br><?php echo $address;?>
<br><b>Phone: </b><?php echo $mobile;?>
<br><b>Tin No.:</b><?php echo $tin;?>
</address>
</div>
<!-- /.col -->
<div class="pull-right invoice-col" id="invoice_border">
<b>Invoice : <?php echo $bil_no;?></b><br>
<b>Date :</b> <?php echo date('d-m-Y', strtotime($date));?>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
<!-- Table row -->
<!-- <div class="row">
<div class="col-xs-12"> -->
<table class="table table-striped">
<thead>
<tr>
<th>Date</th>
<th>DC. No.</th>
<th>Description</th>
<th>Size</th>
<th>Set</th>
<th>Color</th>
<th>Plate</th>
<th>Rate</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<?php foreach($total as $object)
{ ?>
<tr>
<td width="110px"><?php echo date('d-m-Y', strtotime($object['adate']));?></td>
<td><?php echo $object['id'];?></td>
<td width="25%"><?php echo $object['details'];?></td>
<td width="6%"><?php echo $object['plate_size'];?></td>
<td><?php echo $object['plate_set'];?></td>
<td><?php echo $object['color'];?></td>
<td width="6%"><?php echo $object['quantity'];?></td>
<td><?php echo $object['rate'];?></td>
<td><?php echo $object['amount'];?></td>
</tr>
<?php } ?>
</tbody>
</table>
<!-- </div> -->
<!-- /.col -->
<!-- </div> -->
<!-- /.row -->
<div class="row">
<div class="col-xs-6"></div>
<div class="col-xs-6">
<div class="table-responsive" style="margin-left:100px">
<table class="table">
<tr>
<th style="width:68%">Grass Total</th>
<td><?php echo $total[0]['sum'];?></td>
</tr>
<tr>
<th>Vat (4%)</th>
<td><?php echo $total[0]['vat'];?></td>
</tr>
<tr>
<th>Tax (1%)</th>
<td><?php echo $total[0]['tax'];?></td>
</tr>
<tr>
<th>Total:</th>
<td><?php echo $total[0]['total_amount'];?></td>
</tr>
</table>
<br>
</div>
</div>
<!-- /.col -->
</div>
<div class="row">
<div class="col-xs-4" style="margin-top:50px">
<h4><b>Rules</b></h4>
<p>1. Payment should be made with in 30 days otherwise.</p>
<p>2. 18% interest will be chenged extra.</p>
<p>3. All taxes will be collected as abd when levide.</p>
<p>4. Subject to Ahmedabad Jurisdiction.</p>
</div>
<div class="col-xs-4" style="margin-top:220px">
<br>
<br>
<h6><b>E.&O.E.</b></h6>
</div>
<div class="col-xs-4" style="margin-top:140px">
<h5><b>For, ATOP</b></h5>
<br>
<br>
<h6>Autho. Signature</h6>
</div>
</div>
<!-- /.row -->
<!-- this row will not appear when printing -->
<!-- /.content -->
<!-- </div> -->
<!-- /.content-wrapper -->
<!-- </div> -->
<!-- ./wrapper -->
<!-- AdminLTE App -->
<script src="<?php base_url();?>dist/js/app.min.js"></script>
</body>
</html>
I have tried this code in mozilla and its working properly but not in chrome.
I have used page-break-inside: avoid; successfully in the past. I would recommend you trying it.
In #media print block add few next rules
tr, th, td{
page-break-inside:avoid !important;
page-break-after:auto;
}
I cannot apply the CSS in the table. For example I want the table to be displayed in the middle and to change the font color and size as well. But I can't. Should I use the tbody tag since I have the body one? Also I generate the table data from database.
<?php
include 'connect.php';
$year = $_POST['year'];
$lecturer = $_POST['lecturer'];
$years = array(
2005,
2006,
2007
);
$lecturers = array(
'lec1',
'lec2',
'lec3',
'lec4'
);
if (in_array($lecturer, $lecturers) && in_array($year, $years)) {
$sql = "SELECT unit_name,a1,a2,a3,l1,l2,r1,r2,u1,u2,u3 FROM $lecturer WHERE year=$year";
$result = mysql_query($sql);
}
else {
echo "No data found";
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../statistics/style.css">
</head>
<body>
<div id="mytable">
<table width="900" border="1" cellspacing="1">
<tr>
<tbody>
<td>Unit Name</td>
<td>A1 </td>
<td>A2 </td>
<td>A3 </td>
<td>L1 </td>
<td>L2 </td>
<td>R1 </td>
<td>R2 </td>
<td>U1 </td>
<td>U2 </td>
<td>U3 </td>
</tbody>
</tr>
<?php
while($unit=mysql_fetch_assoc($result)){
echo "<tr>";
echo "<td>".$unit['unit_name']."</td>";
echo "<td>".$unit['a1']."</td>";
echo "<td>".$unit['a2']."</td>";
echo "<td>".$unit['a3']."</td>";
echo "<td>".$unit['l1']."</td>";
echo "<td>".$unit['l2']."</td>";
echo "<td>".$unit['r1']."</td>";
echo "<td>".$unit['r2']."</td>";
echo "<td>".$unit['u1']."</td>";
echo "<td>".$unit['u2']."</td>";
echo "<td>".$unit['u3']."</td>";
echo "</tr>";
}
?>
</table>
</div>
</body>
</html>
css:
<!-- principalLecturers
-->
#body{
color:white;
padding-bottom: 20px;
}
#table{
margin:0;
border-collapse: collapse;
color:#b50a1e;
font-family:verdana,arial,sans-serif;
font-size:10px;
}
#table#mytable{
display: table-row-group;
vertical-align: middle;
border-color: inherit
}
I can't see anywhere in your table <table id="table"...>. That's why the styles for #table {...} does not apply.
I am just starting with PHP and having trouble of getting my page result to print right. I call the page below from index.php. It looks ok if I displayed the page on a monitor but when I print the page and it is more than one page, the section at the end of the page got cut off and continue on the second page. I am looking for a way so that when I print the page, it will look if the section (each item number) will fit the whole section (repair desc, common cause, etc) in that page. If it does not then just print on the next page.
I also included the CSS file. Basically what it does is forcing the width of page to fit a letter-size paper. Thank you in advance.
<?php include_once $_SERVER['DOCUMENT_ROOT'] .
'/fms/includes/helpers.inc.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Print Repair Form</title>
<link rel='stylesheet' type='text/css' href='/fms/css/letter-size.css' />
</head>
<body>
<div id="page-wrap">
<table>
<tr>
<td rowspan = "3" id="logo"><img src="/fms/images/flex_no_address_256.jpg" /></td>
<td rowspan = "3" id="address">Address<br />
City, State Zipcode <br />
Phone number <br />
website address
</td>
<td>
<table>
<tr>
<td id="repairinfo" class="theading" colspan = "2">Repair Detail</td>
</tr>
<tr>
<td><?php htmlout($custno); ?></td>
<td width="100px">WO: <?php htmlout($wonum); ?></td>
</tr>
<tr>
<td><?php htmlout($custname); ?></td>
<td></td>
</tr>
</table>
</td>
</tr>
</table>
<br />
<?php foreach($items as $item): ?>
<table border ="1">
<tr>
<td class="theading">Type of Repair</td>
<td class="theading">Repair ID</td>
<td class="theading">Fault Picture</td>
</tr>
<tr>
<td class="tablepadding"><?php htmlout($item['repairtype']); ?></td>
<td class="tablepadding"><?php htmlout($item['itemno']); ?></td>
<td rowspan="7" align="center">
<img src="/fms/images/wo_items/<?php htmlout($item['filename']); ?>" width="256" />
</td>
</tr>
<tr>
<td class="theading" colspan="2">Repair Description</td>
</tr>
<tr>
<td class="tablepadding" colspan="2"><?php htmlout($item['repairdesc']); ?>
</td>
</tr>
<tr>
<td class="theading" colspan="2">Common Causes</td>
</tr>
<tr>
<td class="tablepadding" colspan="2"><?php htmlout($item['commoncause']); ?>
</td>
</tr>
<tr>
<td class="theading" colspan="2">Preventive Measures and Maintenance</td>
</tr>
<tr>
<td class="tablepadding" colspan="2"><?php htmlout($item['maintenance']); ?>
</td>
</tr>
</table>
<br />
<?php endforeach; ?>
</div>
</body>
</html>
CSS:
* { margin: 0; padding: 0;}
body {
font: 12px/1.4 Georgia, serif;
}
a img {
border: none;
}
#page-wrap {
width: 800px;
margin: 0 auto;
}
table {
width:100%;
}
#logo {
width: 256px;
}
#address {
width: 170px;
}
#repairinfo {
border-bottom: solid 1px;
text-align: center;
}
.theading {
font-weight: bold;
padding: 3px;
}
table tr td.tablepadding {
padding: 3px;
}
It should be achieved through CSS and no PHP, although you can use php as well as a workaround, google for css media.
There are some tricks for the CSS of your printing: http://slodive.com/web-development/css-print-page-tricks/
Can't give you specific details because I haven't worked too much with printings but it all comes to testing the total height that fits on the paper, and looking for a measure in php (maybe lines?) so if the size is bigger than the one you set, it creates another Table.
You could also use Javascript as you can detect element's (for example a table's) height, and call some function when the max height is reached.
Also I want to suggest you not using tables if it's not totally necesary, It's a very old-school approach and troublesome to modify, with more different behaviour across browsers, and with a lot more of unnecesary code.
Your issue is not with PHP but with CSS.
You need to include a print specific stylesheet as this will be different to your computer monitor styles.
Here's a good blog post about print CSS
http://www.webcredible.co.uk/user-friendly-resources/css/print-stylesheet.shtml
In your html the print stylesheet <link> element will need a media="print" attribute
Then in your print stylesheet you can specify a width
* RESOLVED BY INTENSE RESEARCHING *
[DOWNLOAD CODE, NO COPYRIGHT =)] .rar file ( always scan before opening .rar - F4LLCON
Problem is that without text the boxes are placed 2 on each row, but with text the boxes
appear under each other with spacing. To get the text in the boxes I used <style> in <head>.
How can I FIX this annoying problem?
IMAGE:
Without the p and h3, both echo text will appear under the box and not in the box
Code:
<style>
p {
position:relative;
top:-240px;
left:180px;
}
h3 {
position:relative;
top:-270px;
left:30px;
}
</style>
and
<div class="offers">
<div class="content_box">
<?php
while($products = mysql_fetch_array($result)) {
echo '<img src="includes/images/content_box.png" border=0/>';
// echo "<h3>" . $products['products'] . "</h3>";
// echo "<p>" . $products['description'] . "</p>";
}
?>
</div>
</div>
RESOLVED BY DOING:
<STYLE TYPE="text/css">
#title{color:red; padding-bottom: 240px; padding-left: 25px;}
#desc{color:blue; padding-bottom: 135px; padding-left: 5px;}
</STYLE>
</head>
and
<div>
<?php while($products = mysql_fetch_array($result)) {?>
<table align="left" background="includes/images/box.gif" width="473" height="285">
<tr>
<td width="35%" height="100%" id="title">
<?php echo $products['products'] . " "; ?>
</td>
<td width="70%" height="100%" id="desc">
<?php echo $products['description'];?>
</td>
</tr>
</table>
<?php
}
?>
</div>
</body>
This might be easy for some, but I'm new to this.
Now working correctly.
Thank you for giving me directions and Thank you Google and Stackoverflow for so much help =)
I am asuming that content_box.png is the background for the box right?
instead of including it in a create it in the background of a div with a class like this
CSS:
.product_box {
bacground:url(includes/images/content_box.png);
width:xxxpx; /* the width of conrent_box.png */
height:xxxpx; /* the height of conrent_box.png */
position:relative;
float:left;
}
php:
<?php
while($products = mysql_fetch_array($result)) {
echo '<div class="product_box">';
// echo '<img src="includes/images/content_box.png" border=0/>';
echo "<h3>" . $products['products'] . "</h3>";
echo "<p>" . $products['description'] . "</p>";
echo '</div>';
}
?>
Hope it helps!