I want to show in my view list of all comments from database. But sometimes, comments ale very long. I tried to "break" them with word-wrap:break-word, but with no result - comments like this
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
extend my view..
and I want to show:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
How to do it? CSS Width property also don't work.
Here is my code:
<table style="width: 100%;">
#foreach (var comment in Model.commentList)
{
<tr style="border-bottom:1pt solid black;">
<td style="width: 30%;">
<br />
#comment.UserName<br /><br />
#comment.AddDate
</td>
<td style="word-wrap:break-word; width: 70%;">
<br />
#comment.Content
</td>
</tr>
}
</table>
Actually word-wrap: break-word doesn't seem to work normally in tables. There is a fix for it though. Try the following code (note the additional table-layout: fixed in the table tag).
<table style="table-layout: fixed; width: 100%;">
#foreach (var comment in Model.commentList)
{
<tr style="border-bottom:1pt solid black;">
<td style="width: 30%;">
<br />
#comment.UserName<br /><br />
#comment.AddDate
</td>
<td style="word-wrap:break-word; width: 70%;">
<br />
#comment.Content
</td>
</tr>
}
</table>
Related
Does anybody know how to get above and below the image, text in the table?
Now I have this:
This is my code:
Simply add the text before and after the <img>tags and add a linebreak.
You also have two closing </td> element after each image. Please see my code below for proper code.
The <br /> code you see stands for a line-break. It starts a new line. If you remove those codes the text and images would be next to eachother instead of below eachother.
Example:
/* ignore the CSS, it's mainly for looks */
table {
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
td {
padding-bottom: 20px;
}
img {
width: 100px;
height: 100px;
}
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>Text<br /><img src="image.jpg" /><br />Text</td>
<td>Text<br /><img src="image.jpg" /><br />Text</td>
<td>Text<br /><img src="image.jpg" /><br />Text</td>
</tr>
<tr>
<td>Text<br /><img src="image.jpg" /><br />Text</td>
<td>Text<br /><img src="image.jpg" /><br />Text</td>
<td>Text<br /><img src="image.jpg" /><br />Text</td>
</tr>
</table>
There are a couple of options. If you want it all very nice and clean I recommend more rows like this:
<table>
<tr>
<td>text above pic1</td>
<td>text above pic2</td>
<td>text above pic3</td>
</tr>
<tr>
<td>pic1</td>
<td>pic2</td>
<td>pic3</td>
</tr>
<tr>
<td>text below pic1</td>
<td>text below pic2</td>
<td>text below pic3</td>
</tr>
[...and so on...]
</table>
Add text before and after the img tag, and set "display:block" to the img tag. That solved the problem for me.
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.
I have the following html structure where I am displaying some details inside an html table.
<table cellspacing="15">
<tr>
<td>
<img src="Images/user1.png" />
<label>
User</label>
</td>
<td>
John
</td>
</tr>
<tr>
<td>
<img src="Images/version1.png" />
<label>
Old ID</label>
</td>
<td>
345345
</td>
</tr>
<tr>
<td>
<img src="Images/version3.png" />
<label>
New ID</label>
</td>
<td>
367976
</td>
</tr>
</table>
I want to add margin-top to the image so that the image will be shifted downward by some 3 or 4 pixel but the CSS is not having any effect. Please help.
Also I found that cellspacing is not a valid attribute in HTML5. Any alternate property to achieve the same effect.?
Adding a negative bottom margin to your image
(I generally avoid using negative margins as much as possible, but in this case it's a quick fix and won't effect the text next to it) :
td img {
margin-bottom:-4px;
}
Its working for me.. Anyhow you can try like this LINK, if you want to place img and text in same line
CSS:
td,td img {
line-height:28px;
vertical-align:middle;
}
Alternative for cellspacing is
table {
border-collapse: separate;
border-spacing: 15px;
}
Aligning image:
You can use vertical-align:middle.
See DEMO here.
Margin-top should work correctly, but it probably moves down tha label too.
Possible solution is to use positioning, so:
img {position: relative; top: 4px;}
you can do this.
Just remove <lable> tag & add valign="top" in <td>
<table cellspacing="15">
<tr>
<td valign="top">
<img src="Images/user1.png" />
User
</td>
<td>
John
</td>
</tr>
<tr>
<td valign="top">
<img src="Images/version1.png" />
Old ID
</td>
<td>
345345
</td>
</tr>
<tr>
<td valign="top">
<img src="Images/version3.png" />
New ID
</td>
<td>
367976
</td>
</tr>
</table>
I have to fix header of table when i scroll down i want to see column header till the end of records. i made this but i am facing a problem. i fetch data from database that's a dynamic data so when i display that in table the layout gets odd. because if there is a column with more than 1000 words that will change its width while i mention table cell width with percentage. how i can solve this problem that header remain on the top and the layout will not be disturbed what ever data is. i do not want to use jQuery
.gridScrollDiv
{
border:1px solid #CCCCCC;
height: 500px;
overflow: scroll;
overflow-x: hidden;
}
<div class="gridScrollDiv">
<table id="tblData" class="grid" style="width: 100%;" cellpadding="0">
<thead style="position:absolute;">
<tr>
<th style="width:40%;">
Code
</th>
<th style="width:40%;">
Description
</th>
<th style="width:20%;">
Date
</th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="rptLoation" runat="server">
<ItemTemplate>
<tr>
<td style="width:40%; word-wrap:breake-word;">
<%# DataBinder.Eval(Container.DataItem, "Code")%>
</td>
<td style="width:40%; word-wrap:breake-word;">
<%# DataBinder.Eval(Container.DataItem, "Description")%>
</td>
<td style="width:20%; word-wrap:breake-word;">
<%# DataBinder.Eval(Container.DataItem, "RegistrationDate")%>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
</div>
you can use code like below. I have modified css.
.gridScrollDiv
{
border: 1px solid #CCCCCC;
height: 500px;
overflow-y: scroll;
}
taking out the header from the repeater.
<table style="width: 100%;">
<tr style="font-weight: bold;">
<tr>
<td style="width: 40%; text-align: left">
Code
</td>
<td style="width: 40%; text-align: left">
Description
</td>
<td style="width: 20%; text-align: left">
Date
</td>
</tr>
</table>
<div class="gridScrollDiv">
<asp:Repeater ID="rptLoation" runat="server">
<HeaderTemplate>
<table style="width: 100%;">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="width: 40%; word-wrap: breake-word;">
<div style="width: 350px; overflow-x: scroll;">
<%# DataBinder.Eval(Container.DataItem, "Code")%>
</div>
</td>
<td style="width: 40%; word-wrap: breake-word;">
<div style="width: 350px; overflow-x: scroll;">
<%# DataBinder.Eval(Container.DataItem, "Description")%>
</div>
</td>
<td style="width: 20%; word-wrap: breake-word;">
<div style="width: 350px; overflow-x: scroll;">
<%# DataBinder.Eval(Container.DataItem, "RegistrationDate")%>
</div>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
this might resolve your purpose....
I want to get the Name and Description in the center of the columns..
I tried a lot but no luck... I know this is silly doubt but I am stuck...
Here is the .aspx code:
<!-- <table cellpadding="3" cellspacing="4" align="center"
style="width: 100%; height: 60%">
<tr>
<td bgcolor="#4F81BD" style="color: #FFFFFF" width="50%" align="center" >
Name</td>
<td bgcolor="#4F81BD" style="color: #FFFFFF" width="50%">
Description</td>
</tr>
as you can see I have also tried align.. it still does not work.
Try using the text-align CSS property:
<table cellpadding="3" cellspacing="4" align="center" style="width: 100%; height: 60%">
<tr>
<td bgcolor="#4F81BD" style="color: #FFFFFF; width:50%; text-align:center">
Name</td>
<td bgcolor="#4F81BD" style="color: #FFFFFF; width:50%; text-align:50%">
Description</td>
</tr>
In what way is it not working?
What you have done should be displaying 'Name' centered, if not then it's possibly being affected by your css and the inline style approach SLaks has shown will fix it.
If your problem is that you want all text in those columns to be centered then try.
<table>
<col align="center" />
<col align="center" />
<tr>