Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the behavior attribute in CSS

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "how to use behavior attributes in CSS". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use the behavior attribute in CSS.

CSS attribute behavior syntax

In the CSS page layout, we are accustomed to using cookie when refreshing to retain the contents of the form, but it is really troublesome to do so, and behavior in css solves this problem for us. Today I will introduce you to the syntax of the CSS attribute behavior.

Behavior attribute syntax:

ExampleSourceCode

Behavior:url (url) | url (# objID) | url (# default#behaviorName)

Value:

Url (url): specify the DHTML behavior component (.htc) with an absolute or relative url address

Url (# objID): the behavior of using binaries (as ActiveX ®controls). Where # objID is the value of the id attribute of the object object

Url (# default#behaviorName): the default behavior of IE. Specified by the name identification of the behavior (# behaviorName)

Description: sets or retrieves the DHTML behavior of an object. Multiple behaviors are separated by spaces.

When multiple behaviors attached to the same feature conflict, the result depends on the order in which the behavior is applied to the feature. The priority of the latter behavior is higher than that of the previous one. The same rules apply to name conflicts between properties, events, and methods provided by different behaviors.

You can use the addBehavior method to dynamically attach a behavior to an object.

This property is read-only to the currentStyle object. It is readable and writable to other objects.

It is important to note that behaviors defined inline using the behavior property of the style sheet (CSS) or attached using the addBehavior method are not automatically detached when objects are removed from the document tree. The behavior defined by the stylesheet rules in the document is automatically separated when the object is removed from the document tree.

The corresponding script feature is behavior.

Example:

ExampleSourceCode

P {behavior:url (# default#download);} div {behavior:url (fly.htc) url (shy.htc);} div {behavior:url (# myObject);}

◆ application 1: refresh also retains the text in the input box

ExampleSourceCode

.sHistory {} {behavior:url (# default#savehistory);}

◆ Application 2: call script

ExampleSourceCode

H2 {behavior:url (behave.htc)} put the mouse here 52css.com behave.htc functionhig_lite () {element.style.color=255} functionlow_lite () {element.style.color=0}

Note: try to avoid using Behaviors technology when CSS

At this point, I believe you have a deeper understanding of "how to use the behavior attribute in CSS". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report