Css condition annotation theory and practice source file

Source: Internet
Author: User

The browser's condition annotation theory is explained in the following example.

(X) HTML

The following code is used to test the effect of the condition comment statement in Microsoft's IE browser.

<! -- [If IE]>
<H1> you are using IE <! [Endif] -->
<! -- [If IE 5]>
<H1> Version 5 <! [Endif] -->
<! -- [If IE 5.0]>
<H1> Version 5.0 <! [Endif] -->
<! -- [If IE 5.5]>
<H1> Version 5.5 <! [Endif] -->
<! -- [If IE 6]>
<H1> Version 6 <! [Endif] -->
<! -- [If IE 7]>
<H1> Version 7 <! [Endif] -->

The following code is a condition comment for running in a non-IE browser

<! -- [If! IE]> <! -->
<H1> you are not using Internet Explorer <! -- <! [Endif] -->
It eventually works in non-IE and special IE browsers
(Or use lte lt or gt gte to determine, for example:
<! -- [If lte IE 6]>
Information displayed in IE 6
<! [Endif] -->
).

<! -- [If IE 6]> <! -->
<H1> you are using Internet Explorer version 6 <br/>
Or a non-IE browser <! -- <! [Endif] -->

From: cssplay. co. uk/menu/conditional.html "target =" _ blank "> http://www.cssplay.co.uk/menu/conditional.html

The condition annotation mentioned above is to determine the browser type and then define what content is displayed under the browser.

This dropmenu (drop-down menu) model comes from cssplay, which is made after many researches and repeated tests by the author. I want to use this model to illustrate the principle of conditional annotation.

First look at a simple model

Below is the xhtm
<Div class = "menu">
<Ul>
<Li> <a class = "drop" href = "../menu/index.html"> DEMOS
<! -- [If IE 7]> <! -->
</A>
<! -- <! [Endif] -->
<! -- Display in IE7 </a> label -->
<Table> <tr> <td>
<Ul>
<Li> <a href = "../menu/zero_dollars.html" title = "The zero dollar ads page"> zero dollars advertising page </a> </li>
<Li> <a href = "../menu/embed.html" title = "Wrapping text around images"> wrapping text around images </a> </li>
<Li> <a href = "../menu/form.html" title = "Styling forms"> styled form </a> </li>
<Li> <a href = "../menu/nodots.html" title = "Removing active/focus borders"> active focus </a> </li>
<Li> <a class = "drop" href = ".. /menu/hover_click.html "title =" Hover/click with no active/focus borders "> hover/click with no borders </li>
<Li class = "upone"> <a href = "../menu/shadow_boxing.html" title = "Multi-position drop shadow"> shadow boxing </a> </li>
<Li> <a href = "../menu/old_master.html" title = "Image Map for detailed information"> image map for detailed information </a> </li>
<Li> <a href = "../menu/bodies.html" title = "fun with background images"> fun with background images </a> </li>
<Li> <a href = "../menu/fade_scroll.html" title = "fade-out scrolling"> fade scrolling </a> </li>
<Li> <a href = "../menu/em_images.html" title = "em size images compared"> em image sizes compared </a> </li>
</Ul>
</Td> </tr> </table>

<! -- [If lte IE 6]>
</A>
<! [Endif] -->
</Li>
<! -- Display when IE6 </a> label -->
</Ul>
</Div>

CSS
<Link rel = "stylesheet" media = "all" type = "text/css" href = "final_drop.css"/>
<! -- [If lte IE 6]>
<Link rel = "stylesheet" media = "all" type = "text/css" href = "final_drop_ie.css"/>
<! [Endif] -->

Bytes

First, let's see how css is defined in non-ie.
. Menu ul li ul {
Display: none;
}
/* Specific to non IE browsers */
. Menu ul li: hover {
Color: # fff;
Background: # bd8d5e;
}
/* Define the mouse over style */
. Menu ul li: hover ul {
Display: block;
Position: absolute;
Top: 3em;
Margin-top: 1px;
Left: 0;
Width: 150px;
}

In non-IE mode, the ul contained in li is displayed when the mouse slides over, because these browsers support li: hover usage.

Css in IE
. Menu ul li a: hover {
Color: # fff;
Background: # bd8d5e;
}
/* Ul display included in li when the mouse slides */
. Menu ul li a: hover ul {
Display: block;
Position: absolute;
Top: 3em;
Left: 0;
Background: # fff;
Margin-top: 0;
Marg \ in-top: 1px;
}

The final_drop.css style of the inheritance class. When there is no mouse time, the ul contained by li is not displayed.
Because
<! -- [If lte IE 6]>
</A>
<! [Endif] -->
So when the mouse slides over IE6, a: hover is used to display the ul content.
In IE7, li: hover shows the same effect.

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.