CSS common skills and problem handling

Source: Internet
Author: User
Tags relative
css| Skills | questions 1. Solving the problem of not extending the background
<div id= "Content" ><div id= "main" > <div id= "maincol" ></div> <div id= "Xcol" ></div> </div><div id= "Subcol" ></div></div>

<style type= "Text/css" >
<!--
#content {width:700px background:url (img/bg.png) repeat-y;} #subcol {float:left; width:200px;} #main {width:500px; float:right;} #maincol {width:300px;float:left;} #xcol {width:200px; float:right;}
-->
</style>

The above problem, the adaptive height of the background does not inherit the height of the float, the solution:
Under all float plus <div style= "Clear:both;" ></div>

2. How to center the page?
body{Margin:0;padding:0;text-align:center;}
#container {width:760px;margin:0 auto;text-align:left;position:relative;}

Description: The body of the margin and padding set to 0, so that the body content with the edge of the browser close contact. Then text-align:center the contents of the body all centered, so that includes the #container also centered together. The first 0 of container's margin is up and down, and the second auto is around. Up and down for about 0 let its self-control. Plus positioning as relative, only the relative elements can be positioned to move!

3. Make the mouse through the image with CSS
With DW (DREAMWEAV) in the "Mouse through the image" when the speed is not too fast, the mouse after the picture has not been downloaded, see the phenomenon of Bai Tu, looks very beautiful. In fact, you can solve this problem with CSS, and very simple, download fast, do not appear after the mouse after the picture has not been downloaded this situation.

4. The use principle and skill of ID and class in structure
The use principle of ID and class
It is said that the consortium's ID and class setting is unique, and class is universal. IDs need to be unique and used as far as possible on the perimeter. Class is repeatable and is used within the structure as much as possible.
The use of ID and class skills
A. The name of the child that contains the part of the parent name begins. This facilitates a clear hierarchical relationship when writing CSS.
Children in B.class are best not with IDs. Of course special circumstances special treatment.
The naming of C.class is best named in case of capitalization. Newmovie this kind of writing and the first combination of the use of a clear relationship is most appropriate. It is important to note that browsers other than IE are sensitive to capitalization. There is the need to start with a letter.

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.