I created Div Over Image button css style postion is absolute
when i scroll the pages the div also scrolling down
how can i fix the dive over image button
#DamageDiv {
background-color:red;
position:absolute;
z-index:1000;/* heighest z-index show on top */
}
function DrawImage(e) {
var evt = e || window.event; // compliant with ie6
var posX = evt.clientX;
var posY = evt.clientY;
var iDiv = document.createElement('div');
iDiv.id = DamageType;
iDiv.style.top = posY + "px";
iDiv.style.left = posX + "px";
iDiv.style.width = "20px";
iDiv.style.height = "20px";
document.getElementsByTagName('body')[0].appendChild(iDiv);
}
Remove the position:absolute from your CSS - this makes the div stay in the same place on the screen when you scroll.
Read here:
Difference between style = "position:absolute" and style = "position:relative"
Related
I try to create a PdfFlowDocument with header and footer. The page from 1 to 3 in Portrait mode. Page 4 is in Landscape and the rest again in portrait. Following my code code snippet:
PdfFlowDocument flowDocument = new PdfFlowDocument();
//flowDocument.HeadersFooters.EvenPagesHeader = docHeader;
//flowDocument.HeadersFooters.EvenPagesFooter = docFooter;
Xfinium.Pdf.Core.PdfFile sourceFile = new Core.PdfFile(File.OpenRead(""));
Xfinium.Pdf.Graphics.PdfPageContent[] pageContents = sourceFile.ExtractPageContent(0, sourceFile.PageCount - 1);
foreach (Xfinium.Pdf.Graphics.PdfPageContent content in pageContents)
{
//content can be Portrait or Landscape
//How can I rotate the orientation?
//How can I scale the page?
var flowContent = new Xfinium.Pdf.FlowDocument.PdfFlowFormXObjectContent(content);
flowDocument.AddContent(flowContent);
}
You handle the PageCreated event and set the page rotation to 90 for landscape based on your specific condition.
PdfFlowDocument flowDocument = new PdfFlowDocument();
flowDocument.PageCreated += FlowDocument_PageCreated;
//flowDocument.HeadersFooters.EvenPagesHeader = docHeader;
//flowDocument.HeadersFooters.EvenPagesFooter = docFooter;
Xfinium.Pdf.Core.PdfFile sourceFile = new Core.PdfFile(File.OpenRead(""));
Xfinium.Pdf.Graphics.PdfPageContent[] pageContents = sourceFile.ExtractPageContent(0, sourceFile.PageCount - 1);
foreach (Xfinium.Pdf.Graphics.PdfPageContent content in pageContents)
{
//content can be Portrait or Landscape
//How can I rotate the orientation?
//How can I scale the page?
var flowContent = new Xfinium.Pdf.FlowDocument.PdfFlowFormXObjectContent(content);
flowContent.SizeIsRelativeToAvailableSpace = true;
flowContent.FormXObjectHeight = 100;
flowContent.FormXObjectWidth = 100;
flowDocument.AddContent(flowContent);
}
private void FlowDocument_PageCreated(object sender, PdfFlowPageCreatedEventArgs e)
{
if (yourConditionHere)
{
e.Page.Rotation = 90;
}
}
Update: you can set the flowContent.SizeIsRelativeToAvailableSpace property to true and flowContent.FormXObjectWidth and flowContent.FormXObjectHeight properties to 100. This means the content object will be scaled to take all available space (100%). It will also take care of the white page problem.
Disclaimer: I work for the company that develops the XFINIUM.PDF library.
I got a problem with white space surrounding the video, I've added margin: 0 which fixed the top white space. But now I still got white space on other positions. I also tried to resize the browser control to match the iframe. But when I resize, the same thing happends:
var embed = "<html><head>" +
"<meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge,chrome=1\"/>" +
"</head><body style=\"margin: 0\">" +
"<iframe width=\"560\" height=\"315\" src=\"{0}\"" +
"frameborder=\"1\" allow =\"autoplay; encrypted-media\" ></iframe>" +
"</body></html>";
var url = "https://www.youtube.com/embed/JvSZKB2WNKg?rel=0&showinfo=0";
webBrowser1.DocumentText = string.Format(embed, url);
You need to:
Set the size of the WebBrowser control same as the iframe
Turn off scrolling of body tag by setting scroll="no".
Turn off padding and margin for body tag, by setting style="padding:0px;margin:0px;".
Remove borders of iframe tag by setting style="border:0px;" for body.
So your code should be:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
int w = 560;
int h = 315;
this.webBrowser1.Width = w;
this.webBrowser1.Height = h;
var embed = "<html><head>" +
"<meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge,chrome=1\"/>" +
"</head><body scroll=\"no\" style=\"padding:0px;margin:0px;\">" +
"<iframe style=\"border: 0px;\" width=\"{1}\" height=\"{2}\" src=\"{0}\"" +
"allow =\"autoplay; encrypted-media\" ></iframe>" +
"</body></html>";
var url = "https://www.youtube.com/embed/JvSZKB2WNKg?rel=0&showinfo=0";
webBrowser1.DocumentText = string.Format(embed, url, w, h);
}
I've a panel with property AutoScroll = true.
By adding other controls dynamically to the panel without scrolling - all works fine!
void addControl(){
int top = 13 + ( this.Controls.Count * cmdSet.Height );
ucCommandSet cmdSet = new ucCommandSet() { Top = top };
this.Controls.Add( cmdSet );
}
But, if the scrollbar is inserted in a different position than TOP [0], the controls are added much further down.
What property do I need to include in the calculation?
regards raiserle
Solution by #LarsTech:
void addControl(){
int top = 13 + ( this.Controls.Count * cmdSet.Height ) + this.AutoScrollPosition.Y;
ucCommandSet cmdSet = new ucCommandSet() { Top = top };
this.Controls.Add( cmdSet );
}
I'm guessing you need to compensate for the scroll position:
{ Top = top + this.AutoScrollPosition.Y };
A FlowLayoutPanel does this for you, by the way.
I have a Devexpress MVC Menu in razor and I want to set the margins on the menu items so the menu will fit horizontally on the page. There is a setting.ControlStyle for padding but not margins.
Is there any way I can change the margins so it will fit across the page?
#Html.DevExpress().Menu(
settings =>
{
settings.Name = "mDataBinding";
settings.AllowSelectItem = true;
settings.Width = 1080;
settings.ControlStyle.Paddings.PaddingLeft = 0;
settings.ControlStyle.Paddings.PaddingRight = 0;
settings.ControlStyle.Font.Size = 9;
settings.ControlStyle.ItemSpacing = 1;
}).BindToSiteMap("~/Styles/SiteMaps/Main.sitemap", false).GetHtml()
Here is what it currently looks like
I recommend settings.Width = Unit.Percentage(100);
I got a problem in regards to autoscrolling of a system.windows.forms.panel. I have a panel that i fill with checkboxes, and if the height requirement of the total amount of checkboxes exceeds the height of the panel it should add a vertical scrollbar. My problem is that it is handles the vertical scrollbar as intended, but it also display a horizontal scrollbar wich is not needed. I adjust the width of the panel by adding System.Windows.Forms.SystemInformation.VerticalScrollBarWidth to the panel width.
int prevMainTop = 0;
int maxWidth = 0;
foreach (List<String> arr in folderArr)
{
if (arr[0].Length * 7 > maxWidth) { maxWidth = arr[0].Length * 7; }
}
foreach (List<String> arr in folderArr)
{
CheckBox cb = new CheckBox();
cb.BackColor = Color.Chocolate;
cb.Checked = true;
cb.AutoSize = false;
cb.Width = maxWidth;
cb.Name = arr[0];
cb.Text = arr[0];
cb.Tag = arr[1];
cb.Top = prevMainTop;
prevMainTop = prevMainTop + 25;
this.mainPanel.Controls.Add(cb);
}
this.mainPanel.Width = maxWidth + System.Windows.Forms.SystemInformation.VerticalScrollBarWidth;
Image showing the unwanted added space to the right of the checkboxes, color added to control background to illustrate the size of the control.
Check the AutoScrollMargin and AutoScrollMinSize properites of the panel. AutoScrollMargin should be (0,0) and you may need to also set AutoScrollMinSize to the maxWidth value.