0
我有這個形象,介紹了什麼是我需要,我已經試過幾件事情,就像如何中心圖像,並保持比例
vertical-align: middle;
text-align: center;
我想有自己的設計在他們原來的大小,但centerd,並保持它們的比例。
CSS:使用此
.imgBanner1
{
max-width: 400px;
max-height: 233px;
}
.imgBanner2 {
max-width: 400px;
max-height: 233px;
}
.imgBanner2:hover {
opacity: 0.8;
cursor: pointer;
}
.imgBanner3 {
width: 190px;
height: 233px;
}
.imgBanner4 {
position: relative;
z-index: -1;
width: 250px;
height: 224px;
margin-top: -4px;
}
.imgBanner5 {
width: 250px;
height: 224px;
margin-top: -4px;
}
.imgBanner6 {
width: 295px;
height: 224px;
margin-top: -4px;
}
.imgBanner7 {
width: 195px;
height: 224px;
margin-top: -4px;
}
我加載圖片:
function buildBanner(json) {
var images = "";
//total of images in the json object
var totalImages = 0;
totalImages = json.length;
for (var i = 0; i < totalImages; i++) {
images += "<div class='imgBanner" + (i+1) + "' style='overflow: hidden; display:inline-block; text-align: center;'><img src='" + json[i].img + "' /></div>";
}
$("div#receiveBanner").append("<div id='bannerBuilt' style='width: 992px; height: 459px; overflow: hidden'></div>");
$("div#bannerBuilt").hide().append(images).fadeIn("slow");
};
你可以做一個[小提琴](http://www.jsfiddle.net)? –