以下がソースです。
レスポンシブで正方形の枠と中の画像が大きさが変わる仕組みです。
縦長のハンバーグの画像は上手く真ん中ぞろえにはなりました。
問題は下のキツネの画像ですがfirefoxでは上下左右中央ぞろえになるものの
chromeでは下にくっついてしまいます。
コードを見て解決策がありましたらご教授いただきたいです。
<html> <head> <meta charset="utf-8"> <title>無題ドキュメント</title> </head> <body> <style> .aspectwrapper { position: relative; width:50%; background:#000000; } .aspectwrapper:after{ padding-top: 100%; display: block; content: “”; } .aspectwrapper > .pic_content{ position: absolute; top: 0px; left: 0px; bottom: 0px; right: 0px; } *::before, *::after { box-sizing: border-box; } .aspectwrapper-7::after,{ clear: both; content: ""; display: block; padding-top: 100%; } .aspectwrapper-7::after, .aspectwrapper-12::after { clear: both; content: ""; display: block; padding-top: 100%; } *::before, *::after { box-sizing: border-box; } .aspectwrapper-7, .aspectwrapper-gd-7, .aspectwrapper-pt-7, .aspectwrapper-slv-7, .aspectwrapper-7-2y, .aspectwrapper-gd-7-2y, .aspectwrapper-pt-7-2y, .aspectwrapper-slv-7-2y { width: calc(100% / 1); } .aspectwrapper-7, .aspectwrapper-7-2x,.aspectwrapper-7-2w, .aspectwrapper-8-2w, .aspectwrapper-9-2w, .aspectwrapper-10-2w, .aspectwrapper-11-2w, .aspectwrapper-12-2w, .aspectwrapper-gd-1-2w, .aspectwrapper-gd-2-2w, .aspectwrapper-gd-3-2w, .aspectwrapper-gd-4-2w, .aspectwrapper-gd-5-2w, .aspectwrapper-gd-6-2w, .aspectwrapper-pt-1-2w, .aspectwrapper-pt-2-2w, .aspectwrapper-pt-3-2w, .aspectwrapper-pt-4-2w, .aspectwrapper-pt-5-2w, .aspectwrapper-pt-6-2w, .aspectwrapper-pt-7-2w, .aspectwrapper-pt-8-2w, .aspectwrapper-pt-9-2w, .aspectwrapper-pt-10-2w, .aspectwrapper-pt-11-2w, .aspectwrapper-pt-12-2w, .aspectwrapper-slv-1-2w, .aspectwrapper-slv-2-2w, .aspectwrapper-slv-3-2w, .aspectwrapper-slv-4-2w, .aspectwrapper-slv-5-2w, .aspectwrapper-slv-6-2w, .aspectwrapper-slv-7-2w, .aspectwrapper-slv-8-2w, .aspectwrapper-slv-9-2w, .aspectwrapper-slv-10-2w, .aspectwrapper-slv-11-2w, .aspectwrapper-slv-12-2w, .aspectwrapper-1-2y, .aspectwrapper-2-2y, .aspectwrapper-3-2y, .aspectwrapper-4-2y, .aspectwrapper-5-2y, .aspectwrapper-6-2y, .aspectwrapper-7-2y, .aspectwrapper-8-2x, .aspectwrapper-9-2x, .aspectwrapper-10-2x, .aspectwrapper-11-2x, .aspectwrapper-12-2x, .aspectwrapper-gd-1-2y, .aspectwrapper-gd-2-2y, .aspectwrapper-gd-3-2y, .aspectwrapper-gd-4-2y, .aspectwrapper-gd-5-2y, .aspectwrapper-gd-6-2y, .aspectwrapper-gd-7-2y, .aspectwrapper-gd-8-2y, .aspectwrapper-gd-9-2y, .aspectwrapper-gd-10-2y, .aspectwrapper-gd-11-2y, .aspectwrapper-gd-12-2y, .aspectwrapper-pt-1-2y, .aspectwrapper-pt-2-2y, .aspectwrapper-pt-3-2y, .aspectwrapper-pt-4-2y, .aspectwrapper-pt-5-2y, .aspectwrapper-pt-6-2y, .aspectwrapper-pt-7-2y, .aspectwrapper-pt-8-2y, .aspectwrapper-pt-9-2y, .aspectwrapper-pt-10-2y, .aspectwrapper-pt-11-2y, .aspectwrapper-pt-12-2y, .aspectwrapper-slv-1-2y, .aspectwrapper-slv-2-2y, .aspectwrapper-slv-3-2y, .aspectwrapper-slv-4-2y, .aspectwrapper-slv-5-2y, .aspectwrapper-slv-6-2y, .aspectwrapper-slv-7-2y, .aspectwrapper-slv-8-2y, .aspectwrapper-slv-9-2y, .aspectwrapper-slv-10-2y, .aspectwrapper-slv-11-2y, .aspectwrapper-slv-12-2y { float: left; overflow: hidden; position: relative; } * { box-sizing: border-box; } *::-moz-selection { background: #fcc800 none repeat scroll 0 0; color: #fff; } *::-moz-selection { background: #fcc800 none repeat scroll 0 0; color: #fff; } *::before, *::after { box-sizing: border-box; } *::before, *::after { box-sizing: border-box; } .pic_content, .aspectwrapper-7 > .pic_content, .aspectwrapper-7-2x > .pic_content, .aspectwrapper-7-2y > .pic_content, .aspectwrapper-7-2w > .pic_content { bottom: 0; height: 100%; left: 0; position: absolute; right: 0; top: 0; transition: all 0.5s ease 0s; width: 100%; } * { box-sizing: border-box; } *::-moz-selection { background: #fcc800 none repeat scroll 0 0; color: #fff; } .pic_content { display: -webkit-box; display: -moz-box; display:box; -webkit-box-pack:center; -moz-box-pack:center; box-pack:center; -webkit-box-align:center; -moz-box-align:center; box-align:center; } .pic_content img{ max-height:100%; max-width:100%; position: relative; top: 50%; -webkit-transform: translateY(-50%); -ms-transform: translateY(-50%); transform: translateY(-50%); } </style> <div class="aspectwrapper-7" style="background:#ff0000;"> <div class="pic_content"> <img src="http://sokuup.net/img/soku_08804.jpg"/ style="max-width:100%; max-height:100%; margin:auto; vertical-align:middle;display: block; margin-left: auto;"> </div> </div> <div class="aspectwrapper-7" style="background:#ff0000;"> <div class="pic_content"> <img src="http://pds.exblog.jp/pds/1/201012/24/71/e0140171_18243710.jpg"/ style="max-width:100%; margin:auto; max-height:100%; vertical-align:middle;display: block; margin-left: auto;"> </div> </div> <div class="aspectwrapper-7" style="background:#ff0000;"> <div class="pic_content"> <img src="http://farm4.staticflickr.com/3636/3577220863_9394cfce18_n.jpg"/ style="max-width:100%; margin:auto; max-height:100%; vertical-align:middle;display: block; margin-left: auto;"> </div> </div> </div> </div> </body> </html>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/07/29 23:59