Javascript fixes headaches in browsers

Source: Internet
Author: User

[Document of the fire School of website construction] we advocate the use of CSS whenever possible, so that we are more likely to succeed. the support for CSS in the browser is already very good. It must be enough for you to control your webpage layout and layout. however, even so, some page elements may behave differently in different browsers.

If you do not understand the reason, do not worry. go deep into the CSS rules and read the Using CSS to Fix Anything: 20 + Common Bugs and Fixes article.

If the previous article does not help you, you can use one of the following 12 javascript solutions to fix your problem and make your page look across all browsers!

In this article, we will provide 12 javascript solutions for the most common CSS problems encountered in web application development.

You may be interested in other CSS-related articles.

  • Using CSS to Do Anything: 50 + Creative Examples and Tutorials
  • Using CSS to Fix Anything: 20 + Common Bugs and Fixes

1. High Setting

Since we abandoned the table-based layout, Creating visually high columns or content blocks has become a challenge.

1.1 Use jquery to set height levels

JQuery has a plug-in that can set the height of all the box models in the same container to be equal, and a very concise grid can be created-of course, the extra performance overhead is also minimal. from the perspective of availability and performance, it is more suitable to use a simple javascript alternative: The javasheights () function checks the height of all the sibling node elements in the same container, then, set the minimum height of each element to the one with the highest height.

How to operate

The equalHeights () loop specifies the top-level subnodes of the element, and sets their minimum height value to the height value of the highest node.

  • View demo

1.2 use jQuery to set high-level Columns

Another high-profile jQuery plug-in

$ ("# Col1, # col2"). equalizeCols ();

The code above sets the # col1, # col2 column height

$ ("# Col1, # col2"). equalizeCols ("p, p ");

The above Code sets the # col1, # col2, and adds the elements with extra space to the p elements under # col1 and # col2.

  • Four pages in total:
  • Previous Page
  • 1
  • 2
  • 3
  • 4
  • Next Page

Related Article

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.