Primefaces: Not able to center align p:chart - css

My xhtml code is
<p:outputPanel id="topperchartcont">
<p:outputPanel rendered="#{performanceStaffController.reportType == 'TP'}">
<table style="width: 100%">
<tr>
<td style="width: 10%">
</td>
<td style="width: 80%; text-align:center">
<h:panelGrid column="1">
<h:panelGroup style="width:80%; display:block; text-align:center">
<table style="border:1px solid #D8D8D8">
<tr>
<td style="text-align:center">
<p:chart type="bar" model="#{performanceStaffController.topperChartModel}"
rendered="#{performanceStaffController.topperChartModel != null}"
style="#{performanceStaffController.perfBean.chartWidth}"/>
</td>
</tr>
</table>
</h:panelGroup>
</h:panelGrid>
</td>
<td style="width: 10%">
</td>
</tr>
</table>
</p:outputPanel>
</p:outputPanel>
I also tried without the PanelGrid/PanelGroup
<p:outputPanel id="topperchartcont">
<p:outputPanel rendered="#{performanceStaffController.reportType == 'TP'}">
<table style="width: 100%">
<tr>
<td style="width: 10%">
</td>
<td style="width: 80%; text-align:center">
<table style="border:1px solid #D8D8D8">
<tr>
<td style="text-align:center">
<p:chart type="bar" model="#{performanceStaffController.topperChartModel}"
rendered="#{performanceStaffController.topperChartModel != null}"
style="#{performanceStaffController.perfBean.chartWidth}"/>
</td>
</tr>
</table>
</td>
<td style="width: 10%">
</td>
</tr>
</table>
</p:outputPanel>
</p:outputPanel>
I even tried other options like using div etc. but I am no way able to center align the p:chart inside that table-data, it is always left aligned. Please suggest how to center align it.
Note that there is no other problem with any of the components and the chart renders perfectly.

Try .center-block to make <p:chart> element's position center and .text-center to make inside text/elements center if any.
.center-block {
display:block;
margin-right:auto;
margin-left:auto;
}
.text-center {text-align:center}

Related

how to align html5 video tag and image tag

I tried to align the html video tag and image in html table. But did not succeeded. Seems like video tag align more bottom instead of top.
Picture is attached how its look.
Css
.newsImage {
width: 354px;
height: 204px;
vertical-align: top;
text-align: left;
}
HTML:
<table cellpadding="0" cellspacing="0" class="auto-style1" align="center">
<tr>
<td colspan="5" style="height: 80px; margin-bottom: 20px;">
<h2>NYHETER</h2>
</td>
</tr>
<tr>
<td class="newsImage">
<span id="Content_lbImageNews1"><video width="354" height="240" controls="controls" preload="metadata"><source src="https://bokning.7a.se/Media/newsImages/11332241297A-v5.mp4#t=0.5" type="video/mp4">Your browser does not support the video tag.</video></span>
</td>
<td> </td>
<td class="newsImage">
<span id="Content_lbImageNews2"><img src="https://bokning.7a.se/Media/newsImages/1142145490news3.png" Height="204" Width="354"></span>
</td>
<td> </td>
<td class="newsImage">
<span id="Content_lbImageNews3"><img src="https://bokning.7a.se/Media/newsImages/279096911logga.jpg" Height="204" Width="354"></span>
</tr>
</table>
In your inline height value you set it to be 240 instead of 204 which matches your other elements:
<video width="354" height="240" controls="controls" preload="metadata">
Change that back and you should have to mess with any other code.
.newsImage {
min-width: 354px;
min-height: 204px;
vertical-align: top;
text-align: left;
}
<table cellpadding="0" cellspacing="0" class="auto-style1" align="center">
<tr>
<td colspan="5" style="height: 80px; margin-bottom: 20px;">
<h2>NYHETER</h2>
</td>
</tr>
<tr>
<td class="newsImage">
<span id="Content_lbImageNews1"><video width="354" height="204" controls="controls" preload="metadata"><source src="https://bokning.7a.se/Media/newsImages/11332241297A-v5.mp4#t=0.5" type="video/mp4">Your browser does not support the video tag.</video></span>
</td>
<td> </td>
<td class="newsImage">
<span id="Content_lbImageNews2"><img src="https://bokning.7a.se/Media/newsImages/1142145490news3.png" Height="204" Width="354"></span>
</td>
<td> </td>
<td class="newsImage">
<span id="Content_lbImageNews3"><img src="https://bokning.7a.se/Media/newsImages/279096911logga.jpg" Height="204" Width="354"></span>
</tr>
</table>
Have you try this to the css file
.newsImage {
vertical-align:top;
}
.newsImage {
vertical-align:top;
}
<html>
</html>
<body>
<table cellpadding="0" cellspacing="0" class="auto-style1" align="center">
<tr>
<td colspan="5" style="height: 80px; margin-bottom: 20px;">
<h2>NYHETER</h2>
</td>
</tr>
<tr>
<td class="newsImage">
<span id="Content_lbImageNews1"><div class="videoWrapper"><video width="100%" height="100%" controls="controls" preload="metadata"><source src="https://bokning.7a.se/Media/newsImages/11332241297A-v5.mp4#t=0.5" type="video/mp4">Your browser does not support the video tag.</video></div></span>
</td>
<td> </td>
<td class="newsImage">
<span id="Content_lbImageNews2"><img src="https://bokning.7a.se/Media/newsImages/1142145490news3.png" Height="204" Width="354"></span>
</td>
<td> </td>
<td class="newsImage">
<span id="Content_lbImageNews3"><img src="https://bokning.7a.se/Media/newsImages/279096911logga.jpg" Height="204" Width="354"></span>
</tr>
</table>
</body

Double scrollbar when displaying PDF in Telerik RadWindow

I have a page that displays a pdf report in a RadWindow via javascript, but for some reason it has two sets of vertical scrollbars: one created by Internet Explorer and one in the PDF itself.
I am displaying other PDF reports in the exact same fashion, the only difference between this one that I can see is that the report is loaded from a different domain(just different port in the development environment, still the same physical server either way).
This does not happen on Chrome, only on IE. And I can't even seem to get either of the scrollbars removed even using the DOM editor in IE's development tools.
I've tried giving the radwindow a CSS class which set overflow to hidden and display inline, the report page itself also has html and body with those settings.
Here is the javascript code I use to open the radwindow:
function showRadWindowSupply(url, title) {
var oWnd = $find("<%=_rwInvoice.ClientID%>");
oWnd.setUrl(url);
oWnd.set_title(title);
oWnd.show();
sizeRadWindowSupply(oWnd, 70, 80);
return false;
}
function sizeRadWindowSupply(oWnd, width, height) {
var browserWidth = $telerik.$(window).width();
var browserHeight = $telerik.$(window).height();
oWnd.setSize(Math.ceil(browserWidth * width / 100), Math.ceil(browserHeight * height / 100));
oWnd.center();
}
Here is the RadWindow markup used on the aspx page:
<telerik:RadWindowManager id="_rwm1" runat="server">
<Windows>
<telerik:RadWindow ID="_rwInvoice" runat="server" Behaviors="Close,Maximize" CssClass="holdsSplitter" AutoSize="false" VisibleStatusbar="false" Modal="true" ></telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>
And here is the HTML that is generated for the RadWindow:
<div class="RadWindow RadWindow_Telerik rwNormalWindow rwTransparentWindow holdsSplitter" id="RadWindowWrapper_ctl00_ContentPlaceHolder1__rwInvoice" style="left: 204px; top: 58px; width: 957px; height: 472px; visibility: visible; position: absolute; z-index: 3001; -ms-touch-action: none; transform: none; backface-visibility: visible;" unselectable="on">
<table class="rwTable" style="height: 433px;" cellspacing="0" cellpadding="0">
<tbody>
<tr class="rwTitleRow">
<td class="rwCorner rwTopLeft"> </td>
<td class="rwTitlebar">
<div class="rwTopResize">
<!-- / -->
</div>
<table align="left" class="rwTitlebarControls" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 16px;"><a class="rwIcon"></a></td>
<td><em style="width: 847px;" unselectable="on">Supply Orders Invoice</em></td>
<td nowrap="" style="white-space: nowrap;">
<ul class="rwControlButtons" style="width: 62px;">
<li><a title="Maximize" class="rwMaximizeButton" href="javascript:void(0);"><span>Maximize</span></a></li>
<li><a title="Close" class="rwCloseButton" href="javascript:void(0);"><span>Close</span></a></li>
</ul>
</td>
</tr>
</tbody>
</table>
</td>
<td class="rwCorner rwTopRight"> </td>
</tr>
<tr class="rwContentRow">
<td class="rwCorner rwBodyLeft"> </td>
<td class="rwWindowContent rwExternalContent" valign="top">
<iframe name="_rwInvoice" src="http://devsvr:87/Reports/StaticReports/OrderHistoryDetail.aspx?ID=1748" frameborder="0" style="border: 0px currentColor; width: 100%; height: 100%;"></iframe>
</td>
<td class="rwCorner rwBodyRight"> </td>
</tr>
<tr class="rwStatusbarRow" style="display: none;">
<td class="rwCorner rwBodyLeft"> </td>
<td class="rwStatusbar">
<table align="left" style="width: 100%;" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 100%;">
<input tabindex="-1" class="rwLoading" id="ctl00_ContentPlaceHolder1__rwInvoice_status" readonly="" unselectable="on"><label style="display: none;" for="ctl00_ContentPlaceHolder1__rwInvoice_status">status label</label></td>
</tr>
</tbody>
</table>
</td>
<td class="rwCorner rwBodyRight"> </td>
</tr>
<tr class="rwFooterRow">
<td class="rwCorner rwFooterLeft"> </td>
<td class="rwFooterCenter"> </td>
<td class="rwCorner rwFooterRight"> </td>
</tr>
</tbody>
</table>
</div>
Any suggestions are greatly appreciated.

Non-Standard Free Width Height HTML Table

I'm trying to get an HTML markup that represents the following table layout:
I tried this but it's not working:
<table border="1">
<tr>
<td style="height: 800px">
1
</td>
<td style="width: 300px; height: 400px">
2
</td>
</tr>
<tr>
<td style="height: 200px">
<p>3</p>
</td>
<td style="height: 600px">
4
</td>
</tr>
</table>
This looks pretty close to the image you provided. It's a little tricky because it actually requires 3 rows, but once you get your head wrapped around rowspan, then it makes sense.
<table border="1">
<tr style="height: 200px;">
<td style="width: 400px;" rowspan="2">
1
</td>
<td style="width: 200px;">
2
</td>
</tr>
<tr style="height: 200px;">
<td rowspan="2">
4
</td>
</tr>
<tr style="height: 50px;">
<td>
<p>3</p>
</td>
</tr>
</table>
You just need to add another row and add rowspans:
<table border="1">
<tr>
<td style="width: 300px; height: 400px" rowspan="2">
1
</td>
<td style="width: 300px; height: 200px">
2
</td>
</tr>
<tr>
<td style="height: 200px" rowspan="2">
4
</td>
</tr>
<tr>
<td style="height: 100px">
3
</td>
</tr>
</table>
See jsfiddle: http://jsfiddle.net/mt009cha/
EDIT
Do you have to use tables? This seems more like a layout and divs might be more appropriate.
Html:
<div class="container">
<div class="left">
<div style="height: 498px">1</div>
<div style="height: 98px">3</div>
</div>
<div class="right">
<div style="height: 298px">2</div>
<div style="height: 298px">4</div>
</div>
</div>
CSS:
div {
border: 1px solid black;
}
.container {
width: 600px;
height: 600px;
}
.left {
width: 398px;
height: 100%;
float: left;
}
.right {
width: 198px;
height: 100%;
float: right;
}
See jsfiddle: http://jsfiddle.net/zynt5j7e/
FIDDL
If you must use tables:
<table class="tbl">
<tr>
<td>
<table>
<tr>
<td style="height: 800px">
<p>top left</p>
</td>
</tr>
<tr>
<td style="height: 200px">
<p>bottom left</p>
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td style="height: 400px">
<p>top left</p>
</td>
</tr>
<tr>
<td style="height: 600px">
<p>bottom left</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
Some CSS:
.tbl, .tbl table { border-collapse: collapse; width:100%; }
.tbl td, .tbl table td{ border:1px solid black; padding:0; margin: 0; }

How to place a div on right side of cascading tables - CSS

I have 3 tables, cascading one after the other. I have a div, that I want to place on right side of these tables. The height of div may vary according to text inside. Currently the div is displayed below tables, like the image below;
<table class="class1" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell1</td>
<td class="cell2">Cell2</td>
</tr>
<tr>
<td class="cell1">Cell3</td>
<td class="cell2">Cell4</td>
</tr>
</table>
<table class="class2" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell5</td>
<td class="cell2">Cell6</td>
</tr>
<tr>
<td class="cell1">Cell7</td>
<td class="cell2">Cell8</td>
</tr>
</table>
<table class="class3" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell9</td>
<td class="cell2">Cell10</td>
</tr>
<tr>
<td class="cell1">Cell11</td>
<td class="cell2">Cell12</td>
</tr>
</table>
<div class="mydiv">mydiv</div>
But I want to place the div next to tables, so that it can extend downwards.
Here is the working fiddle http://jsfiddle.net/ZHVuf/1/
You should add a container around you table like this :
Html
<div id="container">
<!-- Your table -->
</div>
And make him float left, like your div #myDiv
Css
#container {
float:left;
}
see updated fiddle.
On this second updated fiddle, I added a wrapper with a clearfix !
insertusernamehere commented that you could use overflow:hidden instead of the clearfix, see here for a new working way to do this with less code.
Apply float:left; to all the table and add clear:both; to second and third table.
now you already has float:left; for div just add position:relative;top:0; and see.
OR
create two divs and add tables in one with left floating and you already have second div.
<div class="tableContainerDiv" style="float:left;">
<table><tr><td></td></tr></table>
<table><tr><td></td></tr></table>
<table><tr><td></td></tr></table>
</div>
<div class="yourDiv" style="float:left;"></div>
html
<div class="cl">
<div style="float: left">
your tables
</div>
<div class="mydiv" style="float: left">mydiv</div>
</div>
css
.cl:after{ content: " "; display: block; height: 0px; clear: both; visibility: hidden;}
.cl {display: inline-block;}
/* Hides from IE-mac \\*/
* html .cl {height: 1%;}
.cl {display: block;}
/* End hide from IE-mac */
move tables inside another div , float to left;
HTML
<div class="table-wrap">
<table class="class1" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell1</td>
<td class="cell2">Cell2</td>
</tr>
<tr>
<td class="cell1">Cell3</td>
<td class="cell2">Cell4</td>
</tr>
</table>
<table class="class2" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell5</td>
<td class="cell2">Cell6</td>
</tr>
<tr>
<td class="cell1">Cell7</td>
<td class="cell2">Cell8</td>
</tr>
</table>
<table class="class3" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell9</td>
<td class="cell2">Cell10</td>
</tr>
<tr>
<td class="cell1">Cell11</td>
<td class="cell2">Cell12</td>
</tr>
</table>
</div>
<div class="mydiv">mydiv</div>
CSS
.class1{
width: 100px;
height: 100px;
background: orange;
}
.class2{
width: 100px;
height: 100px;
background: green;
}
.class3{
width: 100px;
height: 100px;
background: gray;
}
.mydiv{
width: 200px;
background: blue;
float: left
}
.table-wrap{float:left;}
<table>
<tr><td>
<table class="class1" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell1</td>
<td class="cell2">Cell2</td>
</tr>
<tr>
<td class="cell1">Cell3</td>
<td class="cell2">Cell4</td>
</tr>
</table>enter code here
<table class="class2" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell5</td>
<td class="cell2">Cell6</td>
</tr>
<tr>
<td class="cell1">Cell7</td>
<td class="cell2">Cell8</td>
</tr>
</table>
<table class="class3" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell9</td>
<td class="cell2">Cell10</td>
</tr>
<tr>
<td class="cell1">Cell11</td>
<td class="cell2">Cell12</td>
</tr>
</table>
</td>
<td>
<div class="mydiv">mydiv</div>
</td>
</tr>
</table>

Placing image on bottom right corner of table cell does not work in Firefox and Safari

I have the following table structure in my aspx page. I need to place the image at bottom right corner of a table cell. The code below works fine for IE and Chrome. But in Firefox and Safari, the image is displayed at the bottom right corner of the row, and not the cell.
<table style="width:100%">
<tr>
<td valign="top" style="width:20%; position:relative">
<div>
//some controls here
</div>
<img src="~/images/Index.JPG" runat="server" style="position:absolute; right:0; bottom:0"/>
</td>
<td valign="top" style="width:80%">
<div>
//control here
</div>
</td>
</tr>
<tr>
<td align="center" colspan="1" style="width: 20%">
//control here
</td>
<td align="center" colspan="2" style="width: 80%">
</td>
</tr>
<tr>
<td align="center" style="width:100%" colspan="2">
//control here
</td>
</tr>
</table>
Please help with this!!
Thanks.
I solved this problem by adding another row for the image and setting its alignment.
<tr>
<td style="width: 20%;" align="right" valign="bottom">
<asp:Image ID="Img1" runat="server" />
</td>
</tr>
I think you need to remove the position:relative of the parent td for this image as the absolute of the images is done relative to the td that has the position:relative
<table style="width:100%">
<tr>
<td valign="top" style="width:20%;">
<div>
//some controls here
</div>
<img src="~/images/Index.JPG" runat="server" style="position:absolute; right:0; bottom:0"/>
</td>
<td valign="top" style="width:80%">
<div>
//control here
</div>
</td>
</tr>
<tr>
<td align="center" colspan="1" style="width: 20%">
//control here
</td>
<td align="center" colspan="2" style="width: 80%">
</td>
</tr>
<tr>
<td align="center" style="width:100%" colspan="2">
//control here
</td>
</tr>
</table>

Resources