The use of DIV for positioning is now more and more widely used.
When I was using DIV to position pictures recently, I found that DIV cannot directly set the vertical alignment of the picture.
I was really troubled for a while, and then I found many solutions on the Internet.
But it didn’t seem to work, and then I discovered Mencius Chapter E (I was super surprised at the breadth of knowledge in Mencius Chapter E)
In a post to answer other people’s questions
there is a solution that looks very authentic. As follows
< div id ="Layer1"
style ="position:absolute;
width:500px;
height:305px;
z-index:1 ;
background-color: #999999;
border: 1px none #000000;
padding-top:expression(this.style.top (this.offsetHeight-mxh.offsetHeight)/2)"
align =center >
< img src ="http://sz.luohuedu.net/xml/Images/logo.gif" id =mxh >
div >
After using it, I found that it still failed.
Then I checked the information and found that there are two problems in his method.
Based on the above two points, I made slight modifications to the method in Chapter E of Mencius and got the following method. I've tested it successfully.
The whole process took a lot of time, so I will post it here to share with everyone, so as to save everyone from making further detours, especially those who have not used expression yet.
< div id ="Layer1"
style ="
position:absolute;
left:261px;
top:50px;
wid th:251px;
Height:105px;
z-index:1;
overflow:hidden;
border: 1px solid #0066CC; expression
padding-top:((this.offsetHeight-myI mage.offsetHeight)/ 2);
" "
align ="center" >
< img src ="12.gif" width ="70" height ="76" align ="absmiddle" id ="myImage" >
div >
There is a key point to remind everyone that the picture must be given an ID before it can be calculated. Remember~
Thank you Mencius Chapter E for his erudition, hehehe
I am once again amazed by the breadth of knowledge in Mencius Chapter E.