Page Support Problems

Source: Internet
Author: User

1. ensure a high proportion of the source image length and the maximum height or width is not exceeded.

Function initimg (parpic, maxwidth, maxheight)
{
VaR scale = maxwidth/maxheight;
VaR realscale = parpic. width/parpic. height;
If (parpic. width> maxwidth) | (parpic. Height> maxheight ))
{
If (realscale> scale)
{
Parpic. width = maxwidth;
}
Else
{
Parpic. Height = maxheight;
}
}
}

Call method:
The onload event in the image is as follows:

The value 165,176 indicates the maximum width and height.

II.
Script Language = "JavaScript">
<! --
VaR flag = false;
Function drawimage (imgd ){
VaR image = new image ();
Image. src = imgd. SRC;
If (image. width> 0 & image. Height> 0 ){
Flag = true;
If (image. width/image. Height & gt; = 180/110 ){
If (image. width> 180 ){
Imgd. width = 180;
Imgd. Height = (image. Height * 110)/image. width;
} Else {
Imgd. width = image. width;
Imgd. Height = image. height;
}
/* Imgd. Alt = "bigpic "*/
}
Else {
If (image. Height & gt; 110 ){
Imgd. Height = 110;
Imgd. width = (image. Width * 110)/image. height;
} Else {
Imgd. width = image. width;
Imgd. Height = image. height;
}
/* Imgd. Alt = "bigpic "*/
}
}
}

// -->
</SCRIPT>

Image usage:

Width = "180" Height = "110" note that it is best to limit it here. If you do not limit the size of the loaded graph, it will become larger and then narrow down. This process is ugly if the graph is larger. here is the width and height. In the previous JS, modify the width and height.

The graph will not be deformed. It will only be scaled down by the ratio column, rest assured

III.
This problem may occur when you add materials on the Production page. The table data provided by the customer is too wide to open the page. I also encountered this problem, when I try my best to lose weight on the table and find that I still cannot, I suddenly think of the overflow: auto attribute.

Set a div outside the big data table, class is box, page source code

<Div class = "box">
<Table>
......
</Table>
</Div>

Write CSS like this

. Box {width: 520px; overflow: auto ;}

CSS defines the overflow "Auto" attribute of the DIV, and also gives the div A width suitable for the page.

In this way, when the content width in "box" is greater than the width defined by CSS, a scroll bar will appear. The content can be a table or an image.

In the above issue of overflow: auto, I used

. Box {width: 520px; overflow: auto ;}

However, this will cause a problem, that is, both the horizontal and vertical scroll bars will appear, because if only overflow is defined, the vertical scroll bar will always appear because of the space occupied by the horizontal scroll bar, to hide the vertical scroll bar, I wrote

. Box {width: 520px; overflow: auto; overfolw-Y: hidden ;}

The vertical scroll bar is hidden. Although the problem is solved, you can think about it from another angle, instead of making it appear. After checking the Sushen light rain-style sheet Chinese manual, we found that you only need to define the overfolw-x attribute.

. Box {width: 520px; overfolw-X: auto ;}

If the width is not exceeded, the scroll bar is not displayed. If the width is exceeded, only the horizontal scroll bar is displayed. Because the vertical scroll overfolw-y is not defined, the vertical scroll bar is not displayed.

Syntax:

Overflow-X: visible | auto | hidden | scroll

Parameters:
Visible: Do not cut the content or add a scroll bar. If this default value is explicitly declared, the object is cut to the width of the window or frame containing the object.
Auto: the default value for the body object and textarea. Cut the content and add a scroll bar as needed
Hidden: Do not display content that exceeds the object width
Scroll: Always displays the horizontal scroll bar

Overfolw-y is similar to overflow-x above. If you want to fix the vertical height and a vertical scroll bar appears, you only need to define the attributes of the height and overfolw-y.

4.
When designing a webpage, we always encounter unpleasant things. The most common thing is to add content in the background before we find that the displayed page is opened, which leads to the extremely bad appearance of the webpage. In the past, we used to basically design tables. There were naturally many solutions on the Internet. Today, there are still standard designs for div + CSS, and few good solutions are available, now, Xiaoxiang online summarizes the methods used to prevent the table from being opened and shares them with you.

1. Set the image size directly on the webpage, such as the Code: , in this way, you can limit the image size, but you need to manually modify the image size before uploading the image, otherwise the uploaded image will be deformed.

2. Use the following code: 600} {This. resized = true; this. style. width = 600;} ">

This method will automatically scale down the image to the specified width in proportion when calling the image, without causing deformation of the image or breaking the table, but the disadvantage is that if the image is too large, during the image download process, that is, during the image display process, the image will be first displayed in the original size, then the table will be broken and the page will be ugly. 2. When the image is fully displayed, the image is automatically reduced.

3. We can restrict the size of table attributes to prevent them from being opened, for example, in <Table width = "600" border = "0" cellpadding = "0" cellspacing = "0">, add the code "style =" table-layout: fixed; word-wrap: Break-word; Word-break; break-all; "", where "table-layout: fixed;" is used to fix the table layout, this effectively prevents the table from being opened. "word-wrap: Break-word;" controls line breaks, that is, force line breaks, this should be used when there are many text content, especially when duplicate content appears. If no line breaks are executed, the table will be opened; and "word-break:
Break-all; "can solve the problem that the IE framework is opened in English (non-Asian text lines), but it does not force line breaks and only displays the content in the table width. Generally, you only need to use "style =" table-layout: fixed; Word-wrap: Break-word. Of course, the statements called above can be defined in CSS, such
Table {
Table-layout: fixed;
Word-wrap: Break-word;
}

4. Use CSS to control the adaptive image size. The Code is as follows:
IMG {
Max-width: 600px;
Width: expression (this. Width & gt; 600? "600px": This. width );
Overflow: hidden;
}
Max-width: 600px; the maximum width of other non-ie browsers such as IE7 and Firefox is 600px, but it is not valid in IE6; width: 600px; in all browsers, the image size is 600px. When the image size is greater than 600px, it is automatically reduced to 600px, which is valid in ie6. overflow: hidden: hides the part that exceeds the set size, to avoid the deformation caused by the failure of image size control.

5. Finally, summarize the most practical code:
For tables, use:
Table {
Table-layout: fixed;
Word-break: Break-all;
}
For the DIV layer, use:
Div {
Table-layout: fixed;
Word-wrap: Break-word;
Width: add the width;
Overflow: hidden .)
}

5.
This problem may occur when you add materials on the Production page. The table data provided by the customer is too wide to open the page. I also encountered this problem, when I try my best to lose weight on the table and find that I still cannot, I suddenly think of the overflow: auto attribute.

Set a div outside the big data table, class is box, page source code

<Div class = "box">
<Table>
......
</Table>
</Div>
Write CSS like this

. Box {width: 520px; overflow: auto ;}
CSS defines the overflow "Auto" attribute of the DIV, and also gives the div A width suitable for the page.

In this way, when the content width in "box" is greater than the width defined by CSS, a scroll bar will appear. The content can be a table or an image.

In the above issue of overflow: auto, I used

. Box {width: 520px; overflow: auto ;}
However, this will cause a problem, that is, both the horizontal and vertical scroll bars will appear, because if only overflow is defined, the vertical scroll bar will always appear because of the space occupied by the horizontal scroll bar, to hide the vertical scroll bar, I wrote

. Box {width: 520px; overflow: auto; overfolw-Y: hidden ;}
The vertical scroll bar is hidden. Although the problem is solved, you can think about it from another angle, instead of making it appear. After checking the Sushen light rain-style sheet Chinese manual, we found that you only need to define the overfolw-x attribute.

. Box {width: 520px; overfolw-X: auto ;}
If the width is not exceeded, the scroll bar is not displayed. If the width is exceeded, only the horizontal scroll bar is displayed. Because the vertical scroll overfolw-y is not defined, the vertical scroll bar is not displayed.

Syntax:

Overflow-X: visible | auto | hidden | scroll

Parameters:
Visible: Do not cut the content or add a scroll bar. If this default value is explicitly declared, the object is cut to the width of the window or frame containing the object.
Auto: the default value for the body object and textarea. Cut the content and add a scroll bar as needed
Hidden: Do not display content that exceeds the object width
Scroll: Always displays the horizontal scroll bar

Overfolw-y is similar to overflow-x above. If you want to fix the vertical height and a vertical scroll bar appears, you only need to define the attributes of the height and overfolw-y.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.