Shrink to fit not fitting for the whole A4 page width - html

I have a HTML file in which the coding for the 'page' part is as below:
#page { margin: 2% 0% 0% 2%;}
.page { BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; WIDTH: 0px; BORDER-BOTTOM: 0px;}
.pageBreak{ page-break-before: always;position:relative; WIDTH: 0px; }
.page1 { BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; WIDTH: 675px; HEIGHT:900px; BORDER-BOTTOM: 0px;}
<table class="page1">
<tr>
<td colspan="2">
<div
style="z-index: 10; top: 10px; left: 14px; width: 730px; height: 1015px; border-color: #000000; border-style: solid; border-width: 1px;">
<table width="730px" height="1015px">
<tr>
<td> </td>
</tr>
</table>
</div>
//some code here......
</table>
<table class="page">
<tr>
<td colspan="2">
<div
style="z-index: 10; top: 10px; left: 14px; width: 730px; height: 1015px; border-color: #000000; border-style: solid; border-width: 1px;">
<table width="730px" height="1015px">
<tr>
<td> </td>
</tr>
</table>
</div>
//some code here......
</table>
Our client requirement is that when print option is selected as 'Shrink to Fit',the print preview and the print is displaying the page which is not getting fit to the A4 size width and height.It is leaving a lot of space at the right border and bottom. So,please suggest as what can be made to meet the requirement i.e. selecting the page with 'Shrink to Fit' should result in page occupying the 90% of whole A4 sheet leaving the other 10% for borders. The issue is observed for all the browser versions of IE and FF. Chrome is not in our scope.

Related

Double border for table

I am not very familiar with HTML. Just trying to debug an existing code.
This works fine in IE but not in any other browser like Chrome or Firefox.
<table style="text-align: center;
width: 98%;
left: 0px;
top: 5px;
background-color: #9b9bce;
border: medium double #9b9bce;
border-width: 1px;
bgcolor: #FFFFFF;
background-repeat: no-repeat;
background: #FFFFFF;
padding: 10px 10px 10px 10px;
margin: 10px 10px 10px 10px;">
<tr>
<td td align="left" style="color : white; font: 30 px; font-weight: bold;">
Test
</td>
</tr>
</table>
Does that mean that these are not supported anymore with newer browsers?
I can get this working the same way in all browsers including IE and Chrome.
<table style="text-align: center;
width: 98%;
left: 0px;
top: 5px;
background-color: #9b9bce;
border-top: 2px solid #f38e23;
border-left:2px solid #f38e23;
border-right:2px solid #f38e23;
border-bottom:2px solid #f38e23;
bgcolor: #FFFFFF;
padding: 10px 10px 10px 10px;
margin: 10px 10px 10px 10px;
">
<tr>
<td td align="left" style="color: white; font: 30 px; font-weight: bold;">
Test
</td>
</tr>
</table>
I cant get the double border thing working that is there in the first one.
Any suggestions?
I believe you need a border width of at least 3px when setting it as double. (1px for each border plus 1px space between)
Do you need this thing?
P.S. There is few examples http://htmlbook.ru/css/border-style
.dbl-border {
border: 3px double blue;
width: 300px;
height: 100px;
}
<div class="dbl-border"> </div>
A nice trick for adding multiple borders to any HTML element is by using box-shadow since it can get multiple comma separated shadows.
<table style="text-align: center;
width: 94%;
left: 0px;
top: 5px;
background-color: #9b9bce;
border: 2px solid #f38e23;
padding: 10px;
margin: 20px;
box-shadow: 0px 0px 0px 5px #0f0, 0px 0px 0px 10px #f00, 0px 0px 0px 15px #00f;">
<tr>
<td td align="left" style="color: white; font: 30 px; font-weight: bold;">
Test
</td>
</tr>
</table>
With that much CSS, you will not want to set that all inline. I would recommend setting a style block in an external file and link it to the html file, or set the style block in the head of the html.
The double border does work, however, it is every narrow. If you zoom, you can see the 2 border styles.
For a stronger effect, I would review pseudo-elements and utilize ":before option to give you more control.
I built a sample codepen for you to view a demo. https://codepen.io/ckroll17/pen/LjPGaj
<style type="text/css">
.myBorder{
border: 3px solid blue;
background-color: #ea4421;
color: #ffffff;
margin: 8% auto;
padding: 15px;
position: relative;
}
.myBorder:before{
background: none;
border: 4px solid black;
content: "";
position: absolute;
top: -10px;
left: -10px;
right: -10px;
bottom: -10px;
}
</style>
<table class="myBorder">
<tr>
<td>
Lorem ipsum dolor sit amet
</td>
</tr>
<tr>
<td>consectetur adipiscing elit</td>
<td>sed do eiusmod tempor</td>
<td>Ut enim ad</td>
<td>adipisci velit</td>
</tr>
<tr>
<td>aspernatur aut odit</td>
<td>quae ab</td>
<td>magnam aliquam quaerat voluptatem</td>
<td>consequatur</td>
<td>laboriosam, nisi ut aliquid</td>
<td>Quis autem vel eum iure</td>
<td>reprehenderit qui in ea</td>
<td>Ut enim ad minima</td>
</tr>
</table>
Thanks a lot for all the suggestions. I think I can use this:
<!DOCTYPE html>
<html>
<head>
<style>
.bordered {
width: 98%;
padding: 1px;
border: 5px double #9b9bce;
}
.tablestyle {
background-color: #9b9bce;
width: 100%;
}
</style>
</head>
<body>
<div class="bordered">
<table class="tablestyle">
<tr>
<td style="text-align:left; font-size: 23pt; font-weight: bold;">
Box with a border
</td>
<td style="text-align:right; font-weight: bold;">
SOMETEXT
<br>
Time Here
</td>
</tr>
</table>
</div>
</body>
</html>

css borders with equal spacing

I'm sure that there is a very basic way to fix my problem. Unfortunately, I'm really inexperienced in front-end development, but I have to fix my problem. Briefly, there are some dynamic border boxes in my table but it should be some spaces between every border box.
Now it looks like below image
However, it should be like below image
My code is below. How can I do this with changing the CSS?
.bg {
width: 100%;
padding-left: 2px;
padding-right: 2px;
}
.chart {
border: solid 1px #e31515;
color: #e31515;
width: 100%;
position: absolute;
overflow: hidden;
}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<span style="overflow: hidden;left: 550px; height: 150px; width: 250px; position: absolute; "> <div >
<table cellpadding="2" border="1">
<tbody>
<tr>
<td style="overflow: hidden; border-top: #e9e8e8 1px solid; border-right: 0px; width: 1%; white-space: nowrap; border-bottom: #e9e8e8 1px solid; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px; background-color: transparent">
<div class="bg" style="height: 129px">
<div class="chart" style="height: 14px; margin-top: 115px"></div>
</div>
</td>
<td style="overflow: hidden; border-top: #e9e8e8 1px solid; border-right: 0px; width: 1%; white-space: nowrap; border-bottom: #e9e8e8 1px solid; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px; background-color: transparent">
<div class="bg" style="height: 129px">
<div class="chart" style=" height: 14px; margin-top: 115px"></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</span>
<span style="overflow: hidden;left: 150px; height: 150px; width: 250px; position: absolute; ">
<div >
<table cellpadding="2" border="1">
<tbody>
<tr>
<td style="overflow: hidden; border-top: #e9e8e8 1px solid; border-right: 0px; width: 1%; white-space: nowrap; border-bottom: #e9e8e8 1px solid; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px; background-color: transparent" >
<div class="bg" style="height: 129px">
<div class="chart" style="height: 14px; margin-top: 115px"></div>
</div>
</td>
<td style="overflow: hidden; border-top: #e9e8e8 1px solid; border-right: 0px; width: 1%; white-space: nowrap; border-bottom: #e9e8e8 1px solid; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px; background-color: transparent" >
<div class="bg" style="height: 129px">
<div class="chart" style="height: 14px; margin-top: 115px"></div>
</div>
</td>
<td style="overflow: hidden; border-top: #e9e8e8 1px solid; border-right: 0px; width: 1%; white-space: nowrap; border-bottom: #e9e8e8 1px solid; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px; background-color: transparent" >
<div class="bg" style="height: 129px">
<div class="chart" style="height: 14px; margin-top: 115px"></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</span>
You are using padding. Instead, you need to use margin property. In box model, the padding is used for aligning the inside contents of a box. However, since you are applying the style to the , you need to mention margin-right property of each . Simply replace padding with margin property in bg style.
.bg {
width: 100%;
margin-left: 2px;
margin-right: 2px;
}
Hope this helps. If you find this solution correct, mark it as the answer.
CSS border-spacing property does what you need.
table{
border-collapse: separate;
border-spacing: 10px;
}
Example here: http://www.w3schools.com/csSref/tryit.asp?filename=trycss_table_border-spacing

table border showing underneath a div

I have a table with a div placed into it. The div is superimposed on top of several of the table cells (by design). But the border is still visible through the div, even though the div isn't transparent at all. Here is what it looks like:
Why is the border visible through the div? How would one go about preventing the border from showing through the div, and making the div completely transparent?
Here's a jsfiddle demonstrating it, and here's my html and css:
html:
<table class="mytable">
<tr>
<td>
<div style='height:64px' class='mydiv'>
</div>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
css:
.mytable tr:nth-child(4n + 2) {
background-color: #9f9f9f;
}
.mytable th {
font-size: 10px;
height: 25px;
font-family: arial, tahoma;
font-weight: bold;
vertical-align: top;
text-align: center;
border-width: 1px;
border-color: #000000;
border-style: solid;
padding: 0px;
}
.mytable td {
height: 8px;
width: 80px;
border-bottom-style: dashed;
border-right-style: solid;
border-bottom-color: #666666;
border-right-color: #666666;
border-width: 1px;
padding: 0px;
margin-right: 1px;
position: relative;
}
.mydiv {
background-color: #FFFFFF;
border-style: solid;
border-color: #000000;
border-width: 1px;
text-align: center;
vertical-align: middle;
font-family: tahoma, arial;
font-size: 10px;
position: absolute;
top: 0px;
left: 0px;
width: inherit;
}
Just givez-index: 1; to .mydiv
Demo: http://jsfiddle.net/ffjpnv3b/4/

How to fit CSS buttons into table cells?

I would like to put CSS buttons into several tables. Ideally, each button should fill the corresponding table cell. This presents a problem because if I hard-code the button width in CSS, I would need a separate class for each table dimension.
Is there a way to have the buttons fit into the table cells?
HTML:
<center>
<table border="1" width="90%" class="buttons">
<tr>
<td width="25%">Link1 goes here</td>
<td width="25%">Link2<br>goes<br>here</td>
<td width="25%">Link3<br>goes<br>here</td>
<td width="25%">Link4<br>goes<br>here</td>
</tr>
</table>
<p>
<table border="1" width="90%" class="buttons">
<tr>
<td width="20%">Link1 goes here</td>
<td width="20%">Link2<br>goes<br>here</td>
<td width="20%">Link3<br>goes<br>here</td>
<td width="20%">Link4<br>goes<br>here</td>
<td width="20%">Link5<br>goes<br>here</td>
</table>
</center>
CSS:
.buttons
{
overflow:auto;
text-align: center;
font-size: 1.0em;
font-weight: bold;
line-height: 200%;
}
.buttons a
{
display: inline-block;
width: 18em;
height: 6em;
margin-bottom: 0.5em;
padding-top: .6em;
padding-bottom: .6em;
color: #fff;
background-color: #aaabbb;
border-radius: 5px;
border: solid #cccccc 1px;
box-shadow: 2px 2px 1px #888888;
clear:right;
float:right;
}
.buttons a:active
{
box-shadow: 1px 1px 0px #888888;
}
Play with the code:
http://codepen.io/anon/pen/bIEtC
You should try to set height and width 100%. Like this:
.buttons a
{
display: inline-block;
width: 100%; /* set to 100% */
height: 100%; /* set to 100% */
margin-bottom: 0.5em;
padding-top: .6em;
padding-bottom: .6em;
color: #fff;
background-color: #aaabbb;
border-radius: 5px;
border: solid #cccccc 1px;
box-shadow: 2px 2px 1px #888888;
clear:right;
float:right;
}
Try not to hard code CSS into the HTML... it leads to a mess of trouble!
Taking the inline styling out of the html seems to fix most problems. Then, just like #ArmanVirdi said, add the width and the height of the link to be 100%.
The <center> tags don't seem to be doing anything, so those are removed in the below HTML, as well as an unclosed <p> tag.
HTML
<table class="buttons width-25">
<tr>
<td>Link1 goes here
</td>
<td>Link2<br>goes<br>here
</td>
<td>Link3<br>goes<br>here
</td>
<td>Link4<br>goes<br>here
</td>
</tr>
</table>
<table class="buttons width-20">
<tr>
<td>Link1 goes here
</td>
<td>Link2<br>goes<br>here
</td>
<td>Link3<br>goes<br>here
</td>
<td>Link4<br>goes<br>here
</td>
<td>Link5<br>goes<br>here
</td>
</table>
CSS
table {
width: 100%;
}
.width-20 td {
width: 20%;
}
.width-25 td {
width: 25%;
}
.buttons {
text-align: center;
font-size: 1.0em;
font-weight: bold;
line-height: 200%;
}
.buttons a {
display: inline-block;
height: 100%;
width: 100%;
margin-bottom: 0.5em;
padding-top: .6em;
padding-bottom: .6em;
color: #fff;
background-color: #aaabbb;
border-radius: 5px;
border: solid #cccccc 1px;
box-shadow: 2px 2px 1px #888888;
}
.buttons a:active {
box-shadow: 1px 1px 0px #888888;
}
JSFiddle for reference
Add to .buttons:
width:0;
Resut:

Fit image to table cell

I read trough a lot of the posts here but those solutions don't seem to work for me.
I have a problem with the row because it should fit the image without those white spacings ont top:
#popuptable table, th, td, tr
table.popuptable {
border-width: 1px;
border-spacing: 2px;
border-style: outset;
border-color: #2778AF !important;
border-collapse: collapse;
background-color: white;
}
table.popuptable th {
margin-left: 20px !important;
border-width: 0px;
padding: 2px;
border-style: ;
border-color: #2778AF !important;
background-color: white;
-moz-border-radius: ;
}
table.popuptable td {
border-width: 0px;
padding: 2px;
border-style: ;
border-color: #2778AF !important;
background-color: white;
-moz-border-radius: ;
}
table.popuptable tr {
border-width: 0px;
padding: 2px;
border-style: ;
border-color: #2778AF !important;
background-color: white;
-moz-border-radius: ;
}
Where is my problem? I tried all combinations of height I could think of..
Update Html for the popup:
<div id="hidden-BE" style="display:none;" class="popuptable">
<table border="0" width="400">
<tbody><tr>
<th colspan="2"> Kanton BE </th>
</tr>
<tr>
<td width="125px"><img src="http://www.personnes-histoirerurale.ch/pimages/ch/be.gif" width="125"></td>
<td valign="top">
<b>Auswahl (Total: 4)</b><br>
<ul>
<li>Laur, Ernst Ferdinand (1871-1964)</li>
<li>Landis, Jakob (1926-)</li>
<li>Lampert, Octave</li>
<li>Laur-Schaffner, Sophie (1875-1960)</li>
</ul>
</td>
</tr>
</tbody></table>
</div>
Here is one way of adjusting the layout to get a good image fit.
For the HTML, add valign="top" to the table cell holding the image:
<table border="0" width="400" class="popuptable">
<tbody>
<tr>
<th colspan="2">Kanton BE</th>
</tr>
<tr>
<td width="125px" valign="top">
<img src="http://www.personnes-histoirerurale.ch/pimages/ch/be.gif" width="125">
</td>
<td valign="top">
<b>Auswahl (Total: 4)</b>
<br>
<ul>
<li>Laur, Ernst Ferdinand (1871-1964)</li>
<li>Landis, Jakob (1926-)</li>
<li>Lampert, Octave</li>
<li>Laur-Schaffner, Sophie (1875-1960)</li>
</ul>
</td>
</tr>
</tbody>
</table>
For the CSS, make the following modifications:
table.popuptable td {
border-width: 1px;
padding: 0px; /* adds spacing above image, so remove... */
border-style: solid;
border-color: #2778AF !important;
background-color: white;
-moz-border-radius: ;
}
table.popuptable img {
display: block;
}
table.popuptable ul {
border: 1px dashed red;
margin: 0 ;
}
Use display: block on the img to get rid of the extra space below the baseline that gets inserted with inline elements.
You also have 2px padding in the table cells, which you may want to remove or keep as needed.
Finally, the default margins on the ul may cause the height of the text block to be higher than the image, so adjust those as necessary.
See fiddle: http://jsfiddle.net/audetwebdesign/HqQWY/
use the set of properties to make the image fit
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
Ditch the tables, do the pop-up with divs, set the image as background image for the div:
<div class="flag"></div>
And set background-size: cover;
http://www.w3schools.com/cssref/css3_pr_background-size.asp