商品を中央に配置した画像でウェブページを作ろうとしています。しかし、製品が途切れてしまい、画像全体を見るために下にスクロールする必要があります.
画像が中央になるようにロードするにはどうすればよいですか?
体内で
<img alt="The Argan Tree Product Line" src="images/products2.jpg" id="bgimage" class="mainimage"/>
要素のCSS
#bgimage{
z-index: -999;
width: auto;
height: 100%;
top: 0;
left: 0;
position: relative;
min-width:960px;
min-height:720px;
}
このjqueryを使用して、ブラウザのサイズが異なる場合に画像のサイズを変更しています
$(document).ready(function()
{
if ($(document).height() < (.75 * $(document).width())){
var wide = $(document).width();
if (wide>960){
$("#bgimage").css("min-width", wide + "px");
var high = .75 * $(document).width();
$("#bgimage").css("min-height", high + "px");
$("#content-wrapper").css("width", wide +"px");
$("#content-wrapper").css("height", high +"px");
}
}
if ($(document).height() >= (.75 * $(document).width())){
var high = $(document).height();
if (high>720){
var wide = 1.33 * high;
$("#content-wrapper").css("width", wide +"px");
$("#content-wrapper").css("height", high +"px");
}
効果をクリックするための追加のコードはこちら (この質問では削除してください...コードが多すぎます!)
}
$(window).resize(function()
{
if ($(window).height() < (.75 * $(window).width())){
var wide = $(window).width();
if (wide>960){
$("#bgimage").css("min-width", wide + "px");
var high = .75 * wide;
$("#bgimage").css("min-height", high + "px");
$("#content-wrapper").css("width", wide +"px");
$("#content-wrapper").css("height", high +"px");
}
}
if ($(document).height() >= (.75 * $(document).width())){
var high = $(document).height();
if (high>720){
var wide = 1.33 * high;
$("#content-wrapper").css("width", wide +"px");
$("#content-wrapper").css("height", high +"px");
}
}
});
ありがとうございました!!!:)