Cascading Style Sheets Tutorial

CSS Case Analysis and Display Visibility different attributes

  Most people will be very easy CSS attribute display and visibility confusion, they seem no different, but in fact their is a big difference. 
  Visibility attribute is used to determine the elemental display or hide, with visibility = "visible | hidden", said visible, hidden Hide said.    When visibility is set to "hidden", although hidden elements, but it continues to occupy its original position.    Example: 
  <script Language="JavaScript"> 
  Function toggleVisibility (me) ( 
  If (me.style.visibility == "hidden") ( 
  Me.style.visibility = "visible"; 
  ) 
  Else ( 
  Me.style.visibility = "hidden"; 
  ) 
  ) 
  </ Script> 
  <div Onclick="toggleVisibility(this)" style="position:relative"> 
  The first lines of text will trigger a "hidden" and "visible" property, pay attention to the second line changes.    </ Div> <div> elements will be retained because visibility position, the second line will not be mobile. </ Div> effect: 
  The first lines of text will trigger a "hidden" and "visible" property, pay attention to the second line changes. 
  Visibility because of the location of elements will be retained, the second line will not be mobile. Noted that when the element is hidden, can not be still harder received other incidents, so in the first paragraph of the code, when it is set to "hidden" , can no longer receive a response to the incident, and there is no through mouse clicks, the first paragraph of his text are displayed.    On the other hand, display attributes that are different.    Visibility attribute is hidden elements while maintaining the position of the floating element, and set up display is actually a floating element characteristics.    When the display is set to block (block), all of the elements of containers will be treated as a separate block, as <div> elements, it will be at that point Add to the page.    (In fact you can set the display <span>: block, it can be the same as <div> work. Display will be set inline, and it acts like inline elements - even if it is ordinary block elements such as < div>, it will be combination of imaging <span>, as the output stream. final display is set is: none, when in fact the elements were removed from the page, which lies below the element will be automatically follow on the filling. below to see me and effectiveness of the code examples: Example: <script language="JavaScript"> 
  Function toggleDisplay (me) ( 
  If (me.style.display == "block") ( 
  Me.style.display = "inline"; 
  Alert ( "Now is the text: 'inline'."); 
  ) 
  Else ( 
  If (me.style.display == "inline") ( 
  Me.style.display = "none"; 
  Alert ( "Now is the text: 'none'. Automatically after three seconds to show that."); 
  Window.setTimeout ( "blueText.style.display = 'block';", 3000, the "JavaScript"); 
  ) 
  Else ( 
  Me.style.display = "block"; 
  Alert ( "Now is the text: 'block'."); 
  ) 
  ) 
  ) 
  </ Script> 
  <div> In "span id =" blueText "onclick =" toggleDisplay (this) " 
  Style = "color: blue; position: relative; cursor: hand;"> blue </ span> Click on the text to see results. </ Div> 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • DotNetKicks
  • DZone

Tags: css attributes, css display, Display, div visibility, xhtml attributes

Releated Posts

  • Display: inline-block attributes
  • CSS in-depth understanding of the display: inline-block attributes
  • CSS Tutorial 13, the CSS display attributes [Translation Htmldog]
  • CSS display, in which visibility and distinction?
  • CSS achieve dynamic display by the five-pointed star-level results

This entry was posted on Thursday, December 13th, 2007 at 12:00 am and is filed under Css+Div Web Design. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

« Div + css layout examples
CSS attributes List »

Leave a Reply

  • Categories

    • CSS Properties (491)
    • CSS Tutorial (1154)
    • CSS Tutorial By Examples (1201)
    • Css+Div Web Design (3274)
    • Xhtml and Web Design (1797)
  • Archives

    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
    • September 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
    • April 2007
    • March 2007
    • February 2007
    • January 2007
  • Pages

    • About us

Cascading Style Sheets Tutorial