gpt4 book ai didi

html - 如何将div定位在特定高度的中心

转载 作者:太空宇宙 更新时间:2023-11-03 18:10:33 32 4
gpt4 key购买 nike

我有一个 div,其中包含自动垂直滑动的图像。现在根据我的要求,我需要将此 div 定位到屏幕中心,距离顶部 78px 的高度,但我做不到。这是我的 HTML..

<div id="slideshow-carousel">               
<ul id="carousel" class="jcarousel jcarousel-skin-tango">
<li><a href="#" rel="p1"><img src="images/1.jpg" width="960" height="583" alt="#"/></a></li>
<li><a href="#" rel="p2"><img src="images/2.jpg" width="960" height="583" alt="#"/></a></li>
<li><a href="#" rel="p3"><img src="images/3.jpg" width="960" height="583" alt="#"/></a></li>
<li><a href="#" rel="p4"><img src="images/4.gif" width="960" height="583" alt="#"/></a></li>
<li><a href="#" rel="p5"><img src="images/5.gif" width="960" height="583" alt="#"/></a></li>
<li><a href="#" rel="p6"><img src="images/6.gif" width="960" height="583" alt="#"/></a></li>
<li><a href="#" rel="p7"><img src="images/7.gif" width="960" height="583" alt="#"/></a></li>
</ul>
</div>

这是我尝试添加的 CSS..

 <div id="slideshow-carousel" style="position:absolute;margin-top: 78px;align:center">

CSS..

        #slideshow-carousel {
float:left;
width:960px;
position:relative
}

#slideshow-carousel ul {
margin:0;
padding:0;
list-style:none;
}

#slideshow-carousel li {
background:#fff;
height:583px;
position:relative
}

#slideshow-carousel li .arrow {
left:3px;
top:28px;
position:absolute;
width:20px;
height:40px;
background:url(images/arrow_white.png) no-repeat 0 0;
display:block;
}

#slideshow-carousel li a {
background:#000;
display:block;
width:960px;
height:583px;
}

请帮帮我..

最佳答案

编写一个 css 类,并将其应用于您的 div。根据需要设置边距,或保持自动。

.center
{
margin-left:auto;
margin-right:auto;
width:70%;
background-color:#b0e0e6;
}

关于html - 如何将div定位在特定高度的中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23822045/

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