gpt4 book ai didi

html - 如何将链接定位在宽度和高度的中心?

转载 作者:太空宇宙 更新时间:2023-11-04 04:59:12 24 4
gpt4 key购买 nike

我做了这个:jsfiddle Demo

我有这条线:

<div id="footer">
<h1><a class="link" href="http://www.centerwow.com">mysite</a></h1>
</div>

我怎样才能在 div footer 中将链接 mysite 居中?在中心。宽度和高度应该在 about(menu) 之下。我尝试放置绝对位置和相对位置,但不知何故我破坏了其他东西。感谢您的帮助。

我的代码:

body {
background: #CC3366 url(images/temp.png) center 130px no-repeat ;
overflow:hidden;
font-family: Arial;
font-size: 30px;
line-height: 32px;
}
#container {
width: 1000px;
overflow: hidden;
position: relative;
height: 450px;
margin: 0 auto;
}

#all_pages {
position: absolute;
left: 0;
top: 0;
width: 3000px;
}
.page {
width: 1000px;
height: 400px;
float: left;
text-align: center;
margin-top: 50px;
}
.page img {
margin-top: 50px;
}
#menu {
background: #000;
}
#menu ul {
list-style: none;
width: 457px;
height: 35px;
margin:auto;
}
#menu ul li {
float: left;
color: #888;
width: 150px;
line-height: 35px;
text-align: center;
cursor: pointer;
}
.active {
color: #fff !important;
}
h1 a {
color: #000000;
text-decoration: none;

}
#footer a{
position:absolute;
bottom:80px;
margin: 0 auto;
}
#footer{
position:relative;
background: #CC3366;
width:100%;
height:1000px;

}​

<h1><a class="link" style="position:absolute; left:30px; top:30px;" href="http://www.centerwow.com">portfolio</a></h1>
<div id="container">

<div id="all_pages">

<div class="page">
<h1>Home Page</h1>
<img src="images/home.png" width="300">
</div> <!-- page1 -->
<div class="page">
<h1>About Us Page</h1>
<img src="images/about.png" width="300">
</div> <!-- page2 -->
<div class="page">
<h1>Contact Us Page</h1>
<img src="images/contact.png" width="300">
</div> <!-- page2 -->

</div> <!-- #all_pages -->

</div> <!-- #container -->

<div id="menu">
<ul>
<li id="1" class="link CC3366 active">Home</li>
<li id="2" class="link 33FF66">About</li>
<li id="3" class="link FFFF33">Contact Us</li>
</ul>
</div> <!-- #menu -->
<div id="footer">
<h1><a class="link" href="http://www.centerwow.com">mysite</a></h1>
</div>

最佳答案

类似于this Fiddle你在找什么?

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

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