[英]Implementing this with CSS and HTMl
這是我的CSS-
#nav {
position: relative;
background-color: #292929;
float: left;
width:960px;
margin-left:auto;
margin-right:auto;
}
#nav li {
float: left;
list-style: none;
width:auto;
}
#nav li a {
color: #e3e3e3;
position: relative;
z-index: 2;
float: left;
}
ul, li {
margin:0;
padding: 0;
}
#blob {
position: absolute;
top: 0;
z-index : 1;
background: #0b2b61;
background-repeat:repeat;
}
我想將此對象放在中間。 我怎么做。 我也希望背景適合頁面。 我嘗試了很多,但是沒有用。
<ul id="nav">
<li><a href="home.php">Home</a></li>
</ul>
將對象放置在中心:CSS:
.Center1
{
position:relative;
text-align:center;
}
.Center2
{
position:relative;
margin-left:auto;
margin-right:auto;
width:1024px;
height:800px;
text-align:left;
}
標記:
<body class="body">
<div class="Center1">
<div class="Center2">
<!-- Your content -->
您想將<li>
放置在中心位置,對嗎?
根據您當前的標記,最簡單的方法是應用固定width
並添加margin: 0 auto;
給你李
該解決方案的語義確實很差,但我想您並不在乎。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.