We advocate at all times as much as possible the use of CSS, so that we more likely to succeed. Now the browser support for CSS has been very good, certainly sufficient to allow you to control your page layout and typesetting. But, even so, or element will have some of the pages in different browsers under different performance.
If you do not understand one of the reasons, please do not worry, in-depth about the rules of CSS and look at This article.
If the article above does not help you, you can use the following 12 javascript solutions for one of them go to repair your problem, and your page looks across all browsers!
In this article, we will be in your web application development encountered in the most common CSS issues 12 javascript solutions.
You may have other related articles of interest to the CSS.
1. Set contour
Since we abandoned in order to form the basis of the layout of the way to create visual elements such as columns or blocks have become a challenge.
jQuery has a plug-in can set up a container with all the same height of the box model, but also can create a very simple grid - Of course, the extra performance overhead is minimal. from the usability and performance point of view, the use of a simple javascript to replace would be more suitable: equalHeights () This function Detect a container with all the brothers and the height of the element node, then set each element of the minimum height of these elements in a high value of the biggest.
How it works
equalHeights () cycle designated top-level sub-element node, and set their minimum height value is the highest of the high value of the node.
1.2
Another set of jQuery plug-ins such as
$ ( "# col1, # col2"). equalizeCols ();
Above code set # col1, # col2 out contour
$ ( "# col1, # col2"). equalizeCols ( "p, p");
Above code will set # col1, # col2 contour, and additional elements added to the space # col1 and # col2 of p elements go.
2. IE6 PNG image transparency support
IE6 and earlier versions do not support transparent png picture. While you can use some tips to make IE5.5 or IE6 transparent png support, but this is not the ideal way and difficult to use. Let us look at how to do something to support IE6 users, while the vast majority of site visitors to have full access to the benefits of transparency.
2.1
Dean Edwards are prepared by a javascript library, strengthened the MSIE (IE6, IE5) behavior so that it looks like the standard-compliant browser, like. It repaired under IE5 and IE6 lot of CSS questions and make png transparent to normal job. It also allows the use of advanced CSS selector.
2.2.
It fixes IE6 and earlier versions of the png image problem, including all picture elements and the use of CSS background image settings. This is the original jQuery plug-ins Plug-ins Improved version. Characteristics have: Repair designated picture or background element with questions *, support the use of the CSS background background-position property of the picture, but also to repair the IE absolute positioning problem. (Bottom:-1px | | bottom: 0px)
3.
This is a simple JavaScript function, which can change any element in the current document class. When to use CSS at run-time type of the style in place of hard-coded values to change the style, this function very useful.
Code:
function changeClass (oldClass, newClass) (
var elements = document.getElementsByTagName ("*");
for (i = 0; i <elements.length; i + +) (
if (elements [i]. className == oldClass) elements [i]. className = newClass;
)
)
function changeClass (oldClass, newClass) (var elements = document.getElementsByTagName ("*"); for (i = 0; i <elements.length; i + +) (if (elements [i]. className == oldClass) elements [i ]. className = newClass;))
4. CSS browser selector
Just imagine, you just type a special selector, you can now set up a browser-type elements were prepared by javascript code.
4.1
This is a very simple javascript code, it is dapper, can you use CSS selectors. Use it you can prepare in any special browser CSS code. You can set up your browser type the name of the Writing section of the element javascript code.
- .
Another option is the use of jQuery, it can let you use your browser's selector more convenient, you need to do is to introduce jQuery, then prepare the following code:
$ (document). ready (function () (
$ ( 'html'). addClass ($. browser);
));
Now you can prepare well. Msie,. Mozilla,. Opera,. Safari or. Other objectives of these rely on the style of a browser.
5. The largest / smallest high-wide support
CSS for the min-width, min-height, max-width, max-height, border-*- width, margin, and padding property at some browsers will not be supported by questions, jQuery provides a very good solution.
5.1
This jQuery plug-ins do not provide native support for min-width, max-width, min-height and max-height of these attributes add support for the browser.
5.2
This small plug-ins based on jQuery for CSS of the min-width, min-height, max-width, max-height, border-*- width, margin, there is padding to provide support property. In addition, it provides a check element whether the method can be seen. because all its methods and size are related to return value, so used to calculate the size of DOM elements are very safe.
Download examples demonstrated can use the method without return value chain.
jQuery (function ($) (
var myDiv = $ ( '# myDiv'); / / set margin-top to 100px and margin-bottom to 10em myDiv.margin ((top: 100, bottom:'10em ')); / / displays the size of the top border in pixels alert (myDiv.border (). top); / / displays true if the element is visible, false otherwise alert (myDiv.isVisible ()); / / set padding-right to 10px and margin-left to 15px using chaining myDiv.padding ((right: 10)). margin ((left: 15 });});
- .
6. Horizontal or vertical center elements
Maybe you have encountered this problem: horizontal or vertical center page element. At CSS vertical center is very difficult, especially if you want to support all mainstream browser. Very lucky, now have a solution, one of One way is from the height and width of elements obtained at the top of the left page margin value and divided by 2, is to get the middle element of the margin-left and margin-top. (to understand this sentence do not know if there are any problems)
6.1
The plug-ins can be any element in the middle page, use the horizontal and vertical margins on the minus approach.
$ ( "element"). center (); / / vertical and horizontal $ ( "element"). center ((horizontal: false / / only vertical));
6.2
In this video tutorial, Jeffrey Jordan Way will show you how to use CSS and jQuery combination of power center in the browser vertical picture.
7. In IE to display Q tag
The performance of quotation marks should be used rather than the blockquote tag Q tag. However, windows of IE do not support this tag, therefore, do not use a lot of the development of Q tags.
7.1
When you put this script into your web page document head, it can automatically put the page in quotation marks Q tag replaced (including the corresponding end of the quotation marks). If in the future to support the Q tag IE, you may want to modify it, together with the browser version of the judge.
8. Click on the objectives of increasing the scope for more direct switch
Of the annoying 'Read More ...' Say goodbye to your entire content block can click through to the target link!
9. Lazy loader
This is a jQuery plug-ins. It can make (the contents of long) page picture lazy loading. In the viewport (the visible part of the page) than the picture will not be loaded until the user drag the scroll bar to their time. This Are diametrically opposed.
10.
This jQuery plug-ins can easily solve the IE z-index problem.
11.
This jQuery plug-ins could be restored button elements in IE6 and IE7 under the strange behavior.
12.
The IE plug-ins under the level of repair spill problem. In particular, IE will automatically add elements to spill the scroll bar, if only his element, then the scroll bar will be covered at the above elements. The plug fill by adjusting the elements to repair the problem.







