javascript - 照片库缩略图调整大小

标签 javascript jquery html css

我有一个包含 8 个不同部分和下面 8 个链接的照片库。单击时的每个链接都会显示一个画廊,并隐藏使用 javascript 显示的每个链接。但是,由于我在单击默认画廊以外的任何画廊时实现了此隐藏/显示脚本,因此缩略图被切成两半。知道为什么会这样吗?

这是画廊的链接:http://www.searchtransparency.net/stackoverflow/photo-gallery-test.html

谢谢。

显示/隐藏代码:

    <script>
    var gal=jQuery;
    gal.noConflict();
    gal(document).ready(
        function (){
            gal("#lobby").PikaChoose({carousel:true});
            gal("#apartment-interiors").PikaChoose({carousel:true});
            gal("#penthouse").PikaChoose({carousel:true});
            gal("#roofdeck").PikaChoose({carousel:true});
            gal("#health-club").PikaChoose({carousel:true});
            gal("#garage").PikaChoose({carousel:true});
            gal("#galleria").PikaChoose({carousel:true});
            gal("#the-views").PikaChoose({carousel:true});
        });
</script>
<script>
function lobby()
{
  document.getElementById('gallery-lobby').style.display = 'block';
  document.getElementById('gallery-apartment-interiors').style.display = 'none';
  document.getElementById('gallery-penthouse').style.display = 'none';
  document.getElementById('gallery-roofdeck').style.display = 'none';
  document.getElementById('gallery-health-club').style.display = 'none';
  document.getElementById('gallery-garage').style.display = 'none';
  document.getElementById('gallery-galleria').style.display = 'none';
  document.getElementById('gallery-the-views').style.display = 'none';
}
function apartmentinteriors()
{
  document.getElementById('gallery-lobby').style.display = 'none';
  document.getElementById('gallery-apartment-interiors').style.display = 'block';
  document.getElementById('gallery-penthouse').style.display = 'none';
  document.getElementById('gallery-roofdeck').style.display = 'none';
  document.getElementById('gallery-health-club').style.display = 'none';
  document.getElementById('gallery-garage').style.display = 'none';
  document.getElementById('gallery-galleria').style.display = 'none';
  document.getElementById('gallery-the-views').style.display = 'none';
}
function penthouse()
{
  document.getElementById('gallery-lobby').style.display = 'none';
  document.getElementById('gallery-apartment-interiors').style.display = 'none';
  document.getElementById('gallery-penthouse').style.display = 'block';
  document.getElementById('gallery-roofdeck').style.display = 'none';
  document.getElementById('gallery-health-club').style.display = 'none';
  document.getElementById('gallery-garage').style.display = 'none';
  document.getElementById('gallery-galleria').style.display = 'none';
  document.getElementById('gallery-the-views').style.display = 'none';
}
function roofdeck()
{
  document.getElementById('gallery-lobby').style.display = 'none';
  document.getElementById('gallery-apartment-interiors').style.display = 'none';
  document.getElementById('gallery-penthouse').style.display = 'none';
  document.getElementById('gallery-roofdeck').style.display = 'block';
  document.getElementById('gallery-health-club').style.display = 'none';
  document.getElementById('gallery-garage').style.display = 'none';
  document.getElementById('gallery-galleria').style.display = 'none';
  document.getElementById('gallery-the-views').style.display = 'none';
}
function healthclub()
{
  document.getElementById('gallery-lobby').style.display = 'none';
  document.getElementById('gallery-apartment-interiors').style.display = 'none';
  document.getElementById('gallery-penthouse').style.display = 'none';
  document.getElementById('gallery-roofdeck').style.display = 'none';
  document.getElementById('gallery-health-club').style.display = 'block';
  document.getElementById('gallery-garage').style.display = 'none';
  document.getElementById('gallery-galleria').style.display = 'none';
  document.getElementById('gallery-the-views').style.display = 'none';
}
function garage()
{
  document.getElementById('gallery-lobby').style.display = 'none';
  document.getElementById('gallery-apartment-interiors').style.display = 'none';
  document.getElementById('gallery-penthouse').style.display = 'none';
  document.getElementById('gallery-roofdeck').style.display = 'none';
  document.getElementById('gallery-health-club').style.display = 'none';
  document.getElementById('gallery-garage').style.display = 'block';
  document.getElementById('gallery-galleria').style.display = 'none';
  document.getElementById('gallery-the-views').style.display = 'none';
}
function galleria()
{
  document.getElementById('gallery-lobby').style.display = 'none';
  document.getElementById('gallery-apartment-interiors').style.display = 'none';
  document.getElementById('gallery-penthouse').style.display = 'none';
  document.getElementById('gallery-roofdeck').style.display = 'none';
  document.getElementById('gallery-health-club').style.display = 'none';
  document.getElementById('gallery-garage').style.display = 'none';
  document.getElementById('gallery-galleria').style.display = 'block';
  document.getElementById('gallery-the-views').style.display = 'none';
}
function theviews()
{
  document.getElementById('gallery-lobby').style.display = 'none';
  document.getElementById('gallery-apartment-interiors').style.display = 'none';
  document.getElementById('gallery-penthouse').style.display = 'none';
  document.getElementById('gallery-roofdeck').style.display = 'none';
  document.getElementById('gallery-health-club').style.display = 'none';
  document.getElementById('gallery-garage').style.display = 'none';
  document.getElementById('gallery-galleria').style.display = 'none';
  document.getElementById('gallery-the-views').style.display = 'block';
}
</script>

画廊代码:

<div id="gallery-lobby">
                <ul id="lobby">
                    <li><a href="#"><img src="images/gallery/lobby/1.jpg" width="1000" height="600" alt="Photo 1"></a></li>
                    <li><a href="#"><img src="images/gallery/lobby/2.jpg" width="1000" height="600" alt="Photo 2"></a></li>
                    <li><a href="#"><img src="images/gallery/lobby/3.jpg" width="1000" height="600" alt="Photo 3"></a></li>
                </ul>
            </div>

            <div id="gallery-apartment-interiors" style="display:none;">
                <ul id="apartment-interiors">
                    <li><a href="#"><img src="images/gallery/apartment-interiors/1.jpg" width="1000" height="600" alt="Photo 1"></a></li>
                    <li><a href="#"><img src="images/gallery/apartment-interiors/2.jpg" width="1000" height="600" alt="Photo 2"></a></li>
                    <li><a href="#"><img src="images/gallery/apartment-interiors/3.jpg" width="1000" height="600" alt="Photo 3"></a></li>
                    <li><a href="#"><img src="images/gallery/apartment-interiors/4.jpg" width="1000" height="600" alt="Photo 4"></a></li>
                    <li><a href="#"><img src="images/gallery/apartment-interiors/5.jpg" width="1000" height="600" alt="Photo 5"></a></li>
                </ul>
            </div>

            <div id="gallery-penthouse" style="display:none;">
                <ul id="penthouse">
                    <li><a href="#"><img src="images/gallery/penthouse/1.jpg" width="1000" height="600" alt="Photo 1"></a></li>
                    <li><a href="#"><img src="images/gallery/penthouse/2.jpg" width="1000" height="600" alt="Photo 2"></a></li>
                    <li><a href="#"><img src="images/gallery/penthouse/3.jpg" width="1000" height="600" alt="Photo 3"></a></li>
                </ul>
            </div>

            <div id="gallery-roofdeck" style="display:none;">
                <ul id="roofdeck">
                    <li><a href="#"><img src="images/gallery/roofdeck/1.jpg" width="1000" height="600" alt="Photo 1"></a></li>
                    <li><a href="#"><img src="images/gallery/roofdeck/2.jpg" width="1000" height="600" alt="Photo 2"></a></li>
                    <li><a href="#"><img src="images/gallery/roofdeck/3.jpg" width="1000" height="600" alt="Photo 3"></a></li>
                    <li><a href="#"><img src="images/gallery/roofdeck/4.jpg" width="1000" height="600" alt="Photo 4"></a></li>
                    <li><a href="#"><img src="images/gallery/roofdeck/5.jpg" width="1000" height="600" alt="Photo 5"></a></li>
                    <li><a href="#"><img src="images/gallery/roofdeck/6.jpg" width="1000" height="600" alt="Photo 6"></a></li>
                    <li><a href="#"><img src="images/gallery/roofdeck/7.jpg" width="1000" height="600" alt="Photo 7"></a></li>
                </ul>
            </div>

            <div id="gallery-health-club" style="display:none;">
                <ul id="health-club">
                    <li><a href="#"><img src="images/gallery/health-club/1.jpg" width="1000" height="600" alt="Photo 1"></a></li>
                    <li><a href="#"><img src="images/gallery/health-club/2.jpg" width="1000" height="600" alt="Photo 2"></a></li>
                </ul>
            </div>

            <div id="gallery-garage" style="display:none;">
                <ul id="garage">
                    <li><a href="#"><img src="images/gallery/garage/1.jpg" width="1000" height="600" alt="Photo 1"></a></li>
                    <li><a href="#"><img src="images/gallery/garage/2.jpg" width="1000" height="600" alt="Photo 2"></a></li>
                    <li><a href="#"><img src="images/gallery/garage/3.jpg" width="1000" height="600" alt="Photo 3"></a></li>
                    <li><a href="#"><img src="images/gallery/garage/4.jpg" width="1000" height="600" alt="Photo 4"></a></li>
                    <li><a href="#"><img src="images/gallery/garage/5.jpg" width="1000" height="600" alt="Photo 5"></a></li>
                </ul>
            </div>

            <div id="gallery-galleria" style="display:none;">
                <ul id="galleria">
                    <li><a href="#"><img src="images/gallery/galleria/1.jpg" width="1000" height="600" alt="Photo 1"></a></li>
                    <li><a href="#"><img src="images/gallery/galleria/2.jpg" width="1000" height="600" alt="Photo 2"></a></li>
                    <li><a href="#"><img src="images/gallery/galleria/3.jpg" width="1000" height="600" alt="Photo 3"></a></li>
                </ul>
            </div>

            <div id="gallery-the-views" style="display:none;">
                <ul id="the-views">
                    <li><a href="#"><img src="images/gallery/the-views/1.jpg" width="1000" height="600" alt="Photo 1"></a></li>
                    <li><a href="#"><img src="images/gallery/the-views/2.jpg" width="1000" height="600" alt="Photo 2"></a></li>
                    <li><a href="#"><img src="images/gallery/the-views/3.jpg" width="1000" height="600" alt="Photo 3"></a></li>
                    <li><a href="#"><img src="images/gallery/the-views/4.jpg" width="1000" height="600" alt="Photo 4"></a></li>
                    <li><a href="#"><img src="images/gallery/the-views/5.jpg" width="1000" height="600" alt="Photo 5"></a></li>
                    <li><a href="#"><img src="images/gallery/the-views/6.jpg" width="1000" height="600" alt="Photo 6"></a></li>
                </ul>
            </div>

            <br>

            <p align="center"><a onClick="lobby()" href="#">Lobby</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="apartmentinteriors()" href="#">Apartment Interiors</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="penthouse()" href="#">Penthouse</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="roofdeck()" href="#">Roofdeck</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="healthclub()" href="#">Health Club</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="garage()" href="#">Garage</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="galleria()" href="#">Galleria</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onClick="theviews()" href="#">The Views</a></p>

最佳答案

看起来您使用的任何 CSS 都在您的“缩略图”上放置了一个 -83 像素的左定位。尝试删除该 CSS 条目。此外,看起来您正在使用 1000 x 600 像素的图像,我不知道这是否只是暂时的,但从长远来看可能不是最好的主意。

或者尝试:

.clip img{
  left: 0px;
}

关于javascript - 照片库缩略图调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21297028/

相关文章:

javascript - 覆盖 HTML DOM 元素方法 JS

javascript - 如何暂停音轨?

javascript - 使用 jquery 检查从第一次单击到第二次单击的多个复选框

javascript - 使用 JSON 和 Javascript 时表格未正确显示在行上

javascript - 获取表单值仅在 IE 中返回未定义

javascript - 由于缺少 bson 模块,node.js 教程失败

javascript - 如何在php中从mysql数据库获取最后插入的id?

javascript - Bootstrap : modal. js v3.2.0 嵌套弹窗

javascript - jQuery 检索哈希并将其用作 ID

javascript - 是否可以在 CkEditor 或 TinyMce 中从编辑器中拆分工具栏或菜单栏?