gpt4 book ai didi

CSS 图片库调整

转载 作者:太空宇宙 更新时间:2023-11-03 19:16:38 24 4
gpt4 key购买 nike

我需要一个简单的图片库,所以我决定完全在 CSS 上构建它,并尝试在网上找到合适的东西。我找到了一些非常接近我想要的东西,这里是应用的 CSS 样式:

<html>
<head>
<title>Gallery</title>
<style type="text/css">
body {
margin: 0 auto;
padding: 0;
width: 500px;
color: #000000;
font: normal 80%/120% Georgia, "Times New Roman", Times, serif;
}
a
{
color: #000000;
}

.gallery {
list-style: none;
margin: 0;
padding: 0;
}
.gallery li {
margin: 10px;
padding: 0;
float: left;
position: relative;
width: 120px;
height: 100px;
}
.gallery img {
background: #fff;
border: solid 1px #ccc;
padding: 4px;
width: 110;
height: 90;
}
.gallery span {
width: 77px;
height: 27px;
display: block;
position: absolute;
top: -12px;
left: 50px;
background: url(images/tape.png) no-repeat;
}
.gallery a:hover img {border: 1px solid #0000ff; width:400; height:300; overflow: auto}
</style>
</head>

<body>
<ul class="gallery">
<li><a href="#"><span></span><img src="image/8.jpg" alt="image" /></a></li>
<li><a href="#"><span></span><img src="image/9.jpg" alt="image" /></a></li>
<li><a href="#"><span></span><img src="image/4.jpg" alt="image" /></a></li>
<li><a href="#"><span></span><img src="image/7.jpg" alt="image" /></a></li>
<li><a href="#"><span></span><img src="image/5.jpg" alt="image" /></a></li>
<li><a href="#"><span></span><img src="image/6.jpg" alt="image" /></a></li>
<li><a href="#"><span></span><img src="image/3.jpg" alt="image" /></a></li>
<li><a href="#"><span></span><img src="image/1.jpg" alt="image" /></a></li>
<li><a href="#"><span></span><img src="image/2.jpg" alt="image" /></a></li>
</ul>
</body>
</html>

事实上我什至不知道为什么我需要 .gallery span{}(也许这里有一些提示)但主要问题是:图一:

enter image description here

这就是我的画廊的样子,我希望它看起来像那样,但是当我:将鼠标悬停并放大图片时,会发生这种情况

图2:

enter image description here

再放一张图说清楚

图3:

enter image description here

我需要,并且想要完成的是所有放大的图像看起来像这样:

图4:

enter image description here

但显然在缩略图前面。请提供任何帮助。

谢谢

莱伦

最佳答案

position: relative; 添加到你的 body 样式中,从 .gallery li 中删除 position: relative;,并添加 position: absolute;顶部:0; left: 0; to .gallery a:hover img.

你的最终 CSS 是:

    <style type="text/css">
body {
margin: 0 auto;
padding: 0;
width: 500px;
color: #000000;
font: normal 80%/120% Georgia, "Times New Roman", Times, serif;
position: relative;
}
a
{
color: #000000;
}

.gallery {
list-style: none;
margin: 0;
padding: 0;
}
.gallery li {
margin: 10px;
padding: 0;
float: left;
width: 120px;
height: 100px;
}
.gallery img {
background: #fff;
border: solid 1px #ccc;
padding: 4px;
width: 110;
height: 90;
}
.gallery span {
width: 77px;
height: 27px;
display: block;
position: absolute;
top: -12px;
left: 50px;
background: url(images/tape.png) no-repeat;
}
.gallery a:hover img {border: 1px solid #0000ff; width:400; height:300; overflow: auto; position: absolute; top: 0; left: 0;}
</style>

关于CSS 图片库调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6415693/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com