Parse the use of CSS in j2_m3. (1)

Source: Internet
Author: User

This article briefly introduces the use of CSS in j2s. First, let's take a look at the concept of j2s. The Java2 Platform is specially designed for Household Electrical Products and embedded devices, the Java virtual machines and APIs that make up j2's match those running environments for home appliances and embedded products.

CSS parsing in J2EE

I recently worked on the CSS module in the mobile browser project. I have a general understanding of parsing CSS. The following is a summary:

First, we will briefly introduce CSS:

CSS refers to the CascadingStyleSheets)

CSS syntax consists of three parts: selector, attribute, and value: selector {property: value}

Selector is usually the HTML element or tag you want to define. property is the attribute you want to change and each attribute has a value. The attribute and value are separated by colons and surrounded by curly brackets, forming a complete style declaration ):

 
 
  1. body{color:blue}  
  2.  

The above line of code defines the text color in the body element as blue. In the above example, the body is the selector, and the part included in the curly brackets is the declaration. The Declaration is composed of two parts: attribute and value, color is attribute, and blue is value.

CSS can be studied from the ID selector and class selector:

I. id Selector

The id selector can specify a specific style for HTML elements labeled with a specific id. The id selector is defined. The following two id selectors can be used to define the color of the first element as red, and the color of the second element as Green:

 
 
  1. #red{color:red;}  
  2. #green{color:green;} 

In the following HTML code, the p element whose id attribute is red is displayed in red, while the p element whose id attribute is green is displayed in green.

 
 
  1. <Pidpid = "red"> the paragraph is red. </P>
  2. <Pidpid = "green"> This section is green. </P>

In modern la S, the id selector is often used to create a derived selector.

 
 
  1. #sidebarp{  
  2. font-style:italic;  
  3. text-align:right;  
  4. margin-top:0.5em;  

The above style will only apply to paragraphs that appear in the element where id is sidebar. This element is probably a div or a table unit.

Ii. class selector

In CSS, the class selector is displayed with a dot:
. Center {text-align: center}
In the preceding example, all HTML elements with the center class are centered.

1. class derived selector: 

 
 
  1. .fancytd{  
  2. color:#f60;  
  3. background:#666;  

In the above example, the table cells inside the larger element of the class named fancy will display orange text with a gray background. A bigger element named fancy may be a table or div)

Elements can also be selected based on their classes:

 
 
  1. td.fancy{  
  2. color:#f60;  
  3. background:#666;  

In the above example, the table unit named fancy will be orange with a gray background.
<Tdclass = "fancy">


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.