css| Dynamic | Transformation by setting properties in CSS, we can define exactly the style of a page, such as color, font, border, and so on. Now we want to talk about the CSS positioning is mainly in the layout and control of the page to define, so that your page from both aspects of the show is very perfect, more dynamic.
In addition, before we explain, we first introduce two definitions: relative positioning and absolute positioning. The relative positioning is to allow offsets at the original location of the document. Absolute positioning allows arbitrary positioning.
The realization of CSS positioning ultimately depends on attributes. Let's take a look at the detailed list of positional attributes (see the figure below):
Let's take an example below with a bit of script content, and let's see how it's implemented dynamically. Let's take a look at the effect of this example before we explain it, please click here
See, through a simple CSS positioning to achieve a very dynamic effect. The code for this effect is as follows:
<title>dingwei css</title>
<style type= "Text/css" >
<!--
#container1 {position:absolute;top:100}
* Define Container1 as absolute position *//
#container2 {Position:absolute;top:100;visibility:hidden;}
* Define CONTAINER2 as absolute positioning, initial visibility as hidden (hidden) *//
p{font-size:12pt;}//* defines P's font *//
-->
</style>
<body>
<p style= "font-family: the line of calligraphy; Font-size:15pt;color: #cc33cc" >
Please select a picture: </p>//* set Font size, name, color *//
<div id= "Container1" >
<dd>
* Import a picture with an identifier of container1*//
<p style= "font-family: a line of calligraphy; color: #cc9933; font-size:12pt" >
Name: Desert </p>//* Set font name, color, size *//
</dd>
</div>
<div id= "Container2" >
<dd>
* Import another picture with an identifier of container2*//
<p style= "font-family: a line of calligraphy; color: #3366cc; font-size:12pt" >
Name: Sea </p>
</dd>
</div>
<form name= "MyForm" >//* defines two buttons *//
<p><input type= "button" value= "Desert"
onclick= "container1.style.visibility= ' visible";
container2.style.visibility= ' hidden ' ">
* Define mouse Click event Picture 1 is visible, picture 2 is not visible *//
<input type= "button" value= "Sea";
container1.style.visibility= ' hidden ';
onclick= "container2.style.visibility= ' visible";
container1.style.visibility= ' Hidden ' "></p>
* Define mouse Click event Picture 1 is not visible, picture 2 is visible *//
</form>
</body>
Although the code is a bit longer, but the structure is very simple, you just look at the comments, it is easy to understand. In the next section, I'll continue to introduce you to a CSS positioning example.