The use of CSS perfect way to achieve vertical center
CSS vertical center of the conditions:
1. Have a defined height of the container (such as <div>)
2. There is an unknown height of internal object (perhaps Backgrounds are dynamically generated text, on the other <div> Medium)
3. I want the object of the internal containers at a vertical center.
4. Do not use HTML tables (table elements), nor the use of Javascript.
CSS vertical center of the approach:
The biggest problem: IE Browser Bug.
Most browsers can understand CSS in the display: table form like the statement, but earlier versions of IE7 and below IE can not understand this statement.
Solution: Let the majority can understand display: table declaration browser uses vertical-align property to meet the vertical center, so that the following version of IE7 and use their high level of understanding to resolve the central problem Bug.
IE Bug:
Version of IE7 and below a high degree of understanding Bug: If a container has b object, a container and does not create a high value, if b has the actual contents of the object (such as language), it will be a high degree of understanding with the b equivalent. For b taken if relative positioning, b will be at a relative to the original location (the main use of the percentage of height).
eg: a defined height, b the height of 100px, to b relative positioning, as well as top: -50%
In such a case: standard browser because of the unknown a height, so b Acinetobacter. The version of IE7 and below will allow a relatively high degree of b (in fact, b of equal height) moved up 50%, which is 50px.
How to allow only the following versions of IE7 and understanding of their statement?
1.Pixy had invented , That is, at each Add a property before the underscore "_", this hack is specifically for versions of IE6 and below, that is to say IE7 can not understand. Such as: _position: absolute; so this hack on PASS!
2. At the former property add "#" is a statement can only allow the following version of IE7 and understanding of, and any other browsers can not understand this "#", so "#" after the statement will be ignored in other browsers. OK ~ ~ on this!
Compatibility:
Until now compatible IE8.x all IE browser, Gecko core browser (Mozilla, Firefox, Netscape 7), Opera 7, Webkit core browser (Safari and Google Chrome).
Code:
CSS part:
# outer (
display: table;
height: 400px;
# position: relative;
overflow: hidden;
)
# middle (
display: table-cell;
vertical-align: middle;
# position: absolute;
# top: 50%;
)
# inner (
# position: relative;
# top: -50%;
)
XHTML part:
<div"outer">
<div"middle">
<div"inner">
<! - Here is to the vertical center of the content ->
</ div>
</ div>
</ div>
(Demo at the source code for a number of additional modified Statement, everyone can be ignored)
After testing, the method also applies to the vertical middle picture, it is recommended the use of U.S. at the time the definition of the width of a good outer layer.
This article links:
Related Posts of The use of CSS perfect way to achieve vertical center
-
hibernate using c3p0 connection pooling
Private http://www.lifevv.com/tenyo/doc/20070605102040991.html c3p0 for open source's JDBC connection pool, with the release hibernate. This article describes how to use the hibernate configuration in c3p0. c3p0 connection pool configuration is v ...
-
Hibernate configuration parameters hibernate.hbm2ddl.auto
Hibernate in the configuration file: <properties> <property name="hibernate.hbm2ddl.auto" value="create" /> </ properties> Parameter Description: validate load hibernate, the authentication to create a database t ...
-
Build flex + spring + blazeds + hibernate application
Build flex + spring + blazeds + hibernate application First, set up the project blazeds 1, will blazeds.war extract to a directory, such as: myflex /; 2, set up java works were such as: MyFlex, in the orientation of selection create project from exis ...
-
Process migration from tomcat to websphere changes
Process migration from tomcat to websphere changes Because customers use the web application server software used by different what tomcat5, tomcat6, websphere5.1, websphere6.1, weblogic8, and so on, and the software used inconsistent standards, ibm& ...
-
Hibernate connection pool configuration
Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.1 ...
-
hibernate generic generic DAO
hibernate generic generic DAO
-
Struts2 + hibernate + spring problem user log in
dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q
-
Hibernate secondary cache
Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...
-
Hibernate's lazy strategy
hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...













Leave a Reply