Today to modify the project encountered a problem, the mobile side click on the small picture, open a large picture display; Since the proportions of this large picture are uncertain, how to display them becomes a problem.
The initial feature was to set a CSS3 property, and then something went wrong on the Android phone,
-webkit-align-self:center;-ms-flex-item-align:center;align-self:center;
Then I checked this property:
Some Android machines are not able to use this property because of the version.
I looked for the center of the display of information, looked at the image of Baidu image display method, found that they are each image to do the calculation size, and then display; If you want to go, you can only use JS.
The first way to use table is enough to make the picture centered.
<Divclass= "box"> <Divclass= "Table"> <Divclass= "TD"> <imgsrc= "Dmn.png"alt=""> </Div> </Div></Div>
*{margin:0px;padding:0px;}. Box{width:300px;Height:300px;Border:2px solid #ccc;}. Table{Display:Table;width:100%;Height:100%;}. TD{Display:Table-cell;vertical-align:Middle;text-align:Center;}
Next on the phone display, think big picture in small screen mobile phone can also display completely, and according to the aspect ratio display complete, need JS to judge a bit.
//determine the size of the picture-the display of different picture sizes on different screens varW = $ (". Box"). width (); varH = $ (". Box"). Height (); $(". Box img"). each (function(){ varIMGW = $ ( This). width (); varIMGH = $ ( This). Height (); if(Imgh/imgw > h/w && imgh>=h) { $( This). Height (h); }Else if(IMGH/IMGW <= h/w && imgw>=W) {$ ( This). Width (w); } })
With JQ written, go to the public Library of Baidu (http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js) load a good, very convenient.
The technology is limited, the thing is very simple, mainly is holding the exchange mentality, also hoped can give the novice friend to provide some ideas.
Welcome to criticize, have a better idea of more exchanges ~
About the big Picture Center display ~ Adapt to the mobile side