Javascript 如何使漂亮的照片布局固定大小?
我有一个在我的网站实现。我的问题是,根据图像的大小,布局总是变化。我想使它成为一个固定的大小。 我已经尝试将链接的Javascript 如何使漂亮的照片布局固定大小?,javascript,html,css,prettyphoto,Javascript,Html,Css,Prettyphoto,我有一个在我的网站实现。我的问题是,根据图像的大小,布局总是变化。我想使它成为一个固定的大小。 我已经尝试将链接的href设置为特定大小的图像。但它不起作用。 我试过的代码 <a class="zoom" id="zoom-image" height="290" width="267" href="/images/imagehandler.ashx?path=/product-images/334.jpg" > <img id="large-image" src="/
href
设置为特定大小的图像。但它不起作用。
我试过的代码
<a class="zoom" id="zoom-image" height="290" width="267" href="/images/imagehandler.ashx?path=/product-images/334.jpg" >
<img id="large-image" src="/images/imagehandler.ashx?path=/product-images/334.jpg&width=267&height=290">
</a>
在样式表中添加此css
#large-image{ width: 267px; height: 290px}
从标记中删除高度和宽度请尝试此操作
<a class="zoom" id="zoom-image" href="/images/imagehandler.ashx?path=/product-images/334.jpg">
<img height="290" width="267" id="large-image" src="/images/imagehandler.ashx?path=/product-images/334.jpg&width=267&height=290" alt="">
</a>
我将宽度和高度属性从a链接(这不起作用)移动到image元素(我还添加了alt属性以使其为100%)。在prettypto.js脚本中更改代码
pp_dimensions = _fitToViewport(imgPreloader.width,imgPreloader.height);
根据本守则—
pp_dimensions = _fitToViewport(800, 800);
应用@soheil解决方案: pp_尺寸=_fitToViewport(700550) 这会固定宽度,但当您在幻灯片中导航时,它会在右边距上显示一个糟糕的动画,它会在一秒钟内收缩并扩展20像素 解决方案是更改_showContent函数,从:
$pp_pic_holder.animate({
'top': projectedTop,
'left': ((windowWidth/2) - (pp_dimensions['containerWidth']/2) < 0) ? 0 : (windowWidth/2) - (pp_dimensions['containerWidth']/2)
,width:pp_dimensions['containerWidth']
},...
我希望这会有帮助。只需在img标签中添加高度和宽度属性
@dholakiyaankit它不起作用:(你能提供小提琴吗?这个东西起作用,但我想使外部布局只保持静态。这使整个图片大小也保持静态。这意味着图像适合布局..这使图像更适合布局
$pp_pic_holder.css('width', pp_dimensions['containerWidth']);
// Resize picture the holder
$pp_pic_holder.animate({
'top': projectedTop,
'left': ((windowWidth/2) - (pp_dimensions['containerWidth']/2) < 0) ? 0 : (windowWidth/2) - (pp_dimensions['containerWidth']/2)
/*,width:pp_dimensions['containerWidth']*/
.pp_content {min-height: 400px;}
.pp_content_container .pp_details {
margin-top: 5px;
text-align: center;
position: absolute!important;/*this positions the navigation bar in the same place on the bottom*/
bottom: 10px;
}
@media all and (min-width:480px) and (max-width:700px)
{
div.pp_pic_holder {width: 80%!important;}
.pp_content {
width: 100%!important;
height: 70%!important;
}
#pp_full_res {zoom:0.8;}
.pp_content_container .pp_details {
width: 100%!important;
}
}
@media all and (max-width:480px)
{
div.pp_pic_holder {width: 80%!important;}
.pp_content {
width: 100%!important;
height: 80%!important;
}
#pp_full_res {zoom:0.7;}
.pp_content_container .pp_details {
width: 100%!important;
}
}