gpt4 book ai didi

css - 将两个 div 彼此相邻放置(在另一个 div 内)

转载 作者:行者123 更新时间:2023-11-28 13:13:58 25 4
gpt4 key购买 nike

所以我基本上想把这个站点的所有内容都包含在一个 div 中。这是成功的。我的菜单栏位于主菜单内的 on div 中。通过重新排列代码和修改 CSS,我将图片库 div 放在了正确的位置。但是,这对其他分辨率有效吗?有没有更简单的方法让我的画廊显示在我的菜单栏旁边?该网站的现场演示可以在 accessorizewithstyle.tk 找到。 .任何帮助,将不胜感激。我正在尝试使该站点动态缩放,以便无论使用哪种浏览器/分辨率查看它,它看起来都不错。

代码:

<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Accessorize With Style | Index</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function() {
// create the image rotator
setInterval("rotateImages()", 2000);
});

function rotateImages() {
var oCurPhoto = $('#gallery div.current');
var oNxtPhoto = oCurPhoto.next();
if (oNxtPhoto.length == 0)
oNxtPhoto = $('#gallery div:first');

oCurPhoto.removeClass('current').addClass('previous');
oNxtPhoto.css({ opacity: 0.0 }).addClass('current').animate({ opacity: 1.0 }, 1000,
function() {
oCurPhoto.removeClass('previous');
});
}
</script>
<style type="text/css">
body {
overflow:hidden;
}
img.background {
position:absolute;
top:0;
left:0;
width: 100%;
z-index:-3;
}
img.background {
width:auto\9;
max-width:100%;
}
.menu{
margin:0;
padding:0;
width:300px;
list-style:none;
background:rgb(255,255,255);
}
.menu li{
padding:0;
margin:0 0 1px 0;
height:40px;
display:block;
}
.menu li a{
text-align:left;
height:40px;
padding:0px 25px;
font:16px Verdana, Arial, Helvetica, sans-serif;
color:rgb(255,255,255);
display:block;
background:url('images/verMenuImages.png') 0px 0px no-repeat;
text-decoration:none;
}
.menu li a:hover{
background:url('images/verMenuImages.png') 0px -40px no-repeat;
color:rgb(0,0,0);
}
.menu li a.active, .menu li a.active:hover{
background:url('images/verMenuImages.png') 0px -80px no-repeat;
color:rgb(255,255,255);
}
.menu li a span{
line-height:40px;
}
#site {
width:85%;
margin:0 auto;
}
#menubar {
position: relative;
left: 0px;
}
#gallery {
position: absolute;
left: 35%;
height:400px;
width:400px;
}
#gallery div {
position:absolute;
z-index: 0;
}
#gallery div.previous {
z-index: 1;
}
#gallery div.current {
z-index: 2;
}
</style>
</head>

<body>
<img src="images/background.jpg" class="background" />
<div id="site">
<P><center><img src="images/logo.png" class="logo" /></center></P>
<div id="menubar">
<div id="gallery" align="center">
<div class="current">
<img src="http://i.istockimg.com/file_thumbview_approve/1459298/2/stock-photo-1459298-jewllery-2.jpg" alt="Photo Gallery" width="400" height="400" class="gallery" />
</div>
<div>
<img src="http://i.istockimg.com/file_thumbview_approve/3480966/2/stock-photo-3480966-bracelet.jpg" alt="Photo Gallery" width="400" height="400" class="gallery" />
</div>
<div>
<img src="http://i.istockimg.com/file_thumbview_approve/14879331/2/stock-photo-14879331-earrings.jpg" alt="Photo Gallery" width="400" height="400" class="gallery" />
</div>
<div>
<img src="http://i.istockimg.com/file_thumbview_approve/2741073/2/stock-photo-2741073-wedding-rings.jpg" alt="Photo Gallery" width="400" height="400" class="gallery" />
</div>
<div>
<img src="http://i.istockimg.com/file_thumbview_approve/15490304/2/stock-photo-15490304-scarf.jpg" alt="Photo Gallery" width="400" height="400" class="gallery" />
</div>
</div>
<ul class="menu">
<li><a href="index.html" class="active"><span>Home</span></a></li>
<li><a href="about.html"><span>About</span></a></li>
<li><a href="necklaces.html"><span>Necklaces</span></a></li>
<li><a href="bracelets.html"><span>Bracelets</span></a></li>
<li><a href="earings.html"><span>Earings</span></a></li>
<li><a href="rings.html"><span>Rings</span></a></li>
<li><a href="scarves.html"><span>Scarves</span></a></li>
<li><a href="contact.html"><span>Contact</span></a></li>
</ul>
</div>

</div>
</body>
</html>

最佳答案

我能否建议您仔细研究一下 Matthew James Taylor 为流式布局设计的出色 css 设计。

设计(并且有很多)不仅是流动的(自动调整大小以适应浏览器的任何大小)而且它们对 SEO 也非常友好

http://matthewjamestaylor.com/blog/perfect-multi-column-liquid-layouts

关于css - 将两个 div 彼此相邻放置(在另一个 div 内),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18222902/

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