【发布时间】:2021-02-03 11:34:43
【问题描述】:
我是 HTML、CSS 和 Javascript 的新手。一段时间以来,我一直在寻找与Harvard school of design 相同的网站设计,但在互联网上进行了大量搜索后,我只能找到这个结果change links with images
$('#thumbs img').hover(function(){
$('#largeImage').attr('src',$(this).attr('src').replace('thumb','large'));
});
$('#thumbs2 a').hover(function(){
$('#largeImage2').attr('src',$(this).attr('href').replace('thumb','large'));
});
$('#thumbs3 a').hover(function(){
$('#largeImage3').attr('src',this.getAttribute('data-swap'));
});
#thumbs ,#thumbs2, #thumbs3 {overflow: hidden; }
#thumbs img, #largeImage, #largeImage2 ,#largeImage3
{ border: 1px solid gray; padding: 4px; background-color: white; cursor: pointer; }
#thumbs img ,#thumbs2 a ,#thumbs3 a{ float: left; margin-right: 6px; }
#panel { position: relative; }
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
//WITH IMAGE LINKS </br><hr></br>
<div id="gallery">
<div id="panel">
<img id="largeImage" src="http://placehold.it/100" />
<div id="description">main image with image links</div>
</div>
<div id="thumbs">
<img src="http://placehold.it/100/ee55ee" alt="1st image description" />
<img src="http://placehold.it/100/080" alt="2nd image description" />
<img src="http://placehold.it/100/ff6" alt="3rd image description" />
<img src="http://placehold.it/100/ff3322" alt="4th image description" />
</div>
</div>
</br><hr></br>
//WITH SIMPLE LIVE LINKS </br></br>
<div id="gallery2">
<div id="panel">
<img id="largeImage2" src="http://placehold.it/100/" />
<div id="description">main image with simple links</div>
</div>
<div id="thumbs2">
<a href="http://placehold.it/100/ff3322" >link1</a>
<a href="http://placehold.it/100/ffc5c5">link1</a>
<a href="http://placehold.it/100/eec777">link1</a>
<a href="http://placehold.it/100/887744">link1</a>
</div>
</div>
</br><hr></br>
//WITH SIMPLE [DISABLED] LINKS </br></br>
<div id="gallery3">
<div id="panel">
<img id="largeImage3" src="http://placehold.it/100/" />
<div id="description">main image with simple links</div>
</div>
<div id="thumbs3">
<a href="#" data-swap="http://placehold.it/100/ff3322" >link1</a>
<a href="#" data-swap="http://placehold.it/100/ffc5c5">link1</a>
<a href="#" data-swap="http://placehold.it/100/eec777">link1</a>
<a href="#" data-swap="http://placehold.it/100/ff88ee">link1</a>
</div>
</div>
这并不是很理想。我在this网站上得到的结果真的是我很期待。作为前端技术的新手,很难实现这一目标。非常感谢您的帮助。
【问题讨论】:
-
请详细说明,您想让它变得更好还是有些东西不起作用?
-
如上所述,我试图模仿这个网站的结果 www.pmob.co.uk/temp/gallery-hover-stay.htm 但由于缺乏前端技术的学科知识我做不到。
-
但是您的示例有效,您的意思是您想要一个有效的链接吗?
-
不,我正在尝试在pmob.co.uk/temp/gallery-hover-stay.htm 中构建相同的东西,并且在使用源代码时需要帮助。我上面提到的 jsfiddle 代码没有达到我的预期。
-
@YovchoKalev 或者只是一个简单的查询,是否可以在将鼠标悬停在不同文本上时更改特定位置的图像。只是在选择类别时gsd.harvard.edu 中发生的事情的一个示例。我应该如何复制它?
标签: javascript html css frontend web-frontend