我只是想知道,因为我没有这样做,我是否在促销箱中的桌子内获得了navmenu并且在白色空间的顶部居中并且在顶部中心框/ td / cell上没有边框 帮助会很重要,因为它很重要。
<html>
<head>
<style>
* {
margin: 0px; padding: 0px; border: 0px;
}
#container {
width: 100%; height: 1000px;
max-width: 1440px; min-width: 1024px;
margin: 0px auto;
text-align: center;
}
.bigbox {
height: 1000px;
background-image: url(images/photos/landscape-1440.jpg);
background-position: 50% 50%;
}
.promobox {
width: 25%;
height: 1000px;
float: left;
background-position: 50% 0%;
margin: 0px;
padding: 0px;
vertical-align: top;
}
.promobox div {
height: 200px;
border-color: #FFF;
border-style: none;
}
div {
text-align: center;
position: relative;
}
div a {
position: absolute;
bottom: 10px; right: 10px;
color: #FFF;
text-shadow: 1px 1px 1px #000;
}
#pb1 {width: 25%;
background-color: #E51837;
}
#pb2 {width: 50%;
background-color: white;
}
#pb3 {width: 25%;
background-color: #E51837;
}
h1 {
text-align: center;
margin-bottom: 50px;
}
ul#navmenu, ul.sub1, ul.sub2 {
list-style-type: none;
font-size: 9pt;
}
ul#navmenu li {
width: 96.6px;
text-align: center;
position: relative;
margin-right: 0px;
float: left;
}
#navmenu ul {
display: inline-block;
list-style-type: none;
}
ul#navmenu a {
text-decoration: none;
display: block;
width: 96.6px;
height: 25px;
line-height: 25px;
background-color: #2E2E2E;
border: 1px solid #777777;
border-top: 2px solid #777777;
color: white;
font-family: Arial, sans-serif;
font-weight: bold;
font-face: Arial;
float: left;
text-align: center;
}
ul#navmenu .sub1 li {
}
ul#navmenu .sub1 a {
margin-top: 0px;
}
ul#navmenu .sub2 a {
margin-left: 0px;
}
ul#navmenu li:hover > a {
background-color: grey;
}
ul#navmenu li:hover a:hover {
background-color: red;
}
ul#navmenu ul.sub1 {
display: none;
position: absolute;
top: 26px;
left: 0px;
}
ul#navmenu ul.sub2 {
display: none;
position: absolute;
top: 0px;
left: 97.6px;
}
ul#navmenu li:hover .sub1 {
display: block;
}
ul#navmenu .sub1 li:hover .sub2 {
display: block;
}
.darrow {
font-size: 11pt;
position: absolute;
top: 5px;
right: 4px;
}
#navmenu {
display: inline-block;
text-align: center;
list-style-type: none;
margin: 0px auto;
padding: 0px;
position: relative;
}
.rarrow {
font-size: 13pt;
position: absolute;
top: 6px;
right: 4px;
}
#page1 .link1{
color: grey;
border-top: 2px solid red;
}
#page2 .link2{
color: grey;
border-top: 2px solid red;
}
#page3 .link3{
color: grey;
border-top: 2px solid red;
}
#page1 {text-align:center;}h1 {
text-align: center;
margin-bottom: 0px;
}
ul#navmenu, ul.sub1, ul.sub2 {
list-style-type: none;
font-size: 9pt;
}
ul#navmenu li {
width: 96.6px;
text-align: center;
position: relative;
float: left;
margin-right: 0px;
display: inline;
}
ul#navmenu a {
text-decoration: none;
display: block;
width: 96.6px;
height: 25px;
line-height: 25px;
background-color: #2E2E2E;
border: 2px solid #777777;
color: white;
font-family: Arial, sans-serif;
font-weight: bold;
font-face: Arial;
display: inline-block;
}
ul#navmenu .sub1 li {
}
ul#navmenu .sub1 a {
margin-top: 0px;
}
ul#navmenu .sub2 a {
margin-left: 0px;
}
ul#navmenu li:hover > a {
background-color: grey;
}
ul#navmenu li:hover a:hover {
background-color: red;
}
ul#navmenu ul.sub1 {
display: none;
position: absolute;
top: 26px;
left: 0px;
}
ul#navmenu ul.sub2 {
display: none;
position: absolute;
top: 0px;
left: 96.6px;
}
ul#navmenu li:hover .sub1 {
display: block;
}
ul#navmenu .sub1 li:hover .sub2 {
display: block;
}
.darrow {
font-size: 11pt;
position: absolute;
top: 5px;
right: 4px;
}
#navmenu {
display: inline-block;
text-align: center;
list-style: none;
margin: 0px;
padding: 0px;
}
.rarrow {
font-size: 13pt;
position: absolute;
top: 6px;
right: 4px;
}
#page1 .link1{
color: grey;
border-top: 2px solid red;
}
#page2 .link2{
color: grey;
border-top: 2px solid red;
}
#page3 .link3{
color: grey;
border-top: 2px solid red;
}
</style>
</head>
<body>
<div id="container">
<div class="bigbox">
<div class="promobox" id="pb1"> </div>
<div class="promobox" id="pb2"><table padding="0" spacing="0" width="557px" height="100px">
<tr><td align="center" valign="middle" bgcolor="#E51837"><img src="#" width="481px" height="187px"><br><img src="#" width="418px" height="96px">
</td></tr><tr><td><br></br><div id="page1">
<ul id="navmenu">
<li><a href="dropdown1.html" class="link1">hyperlink 1</a></li>
<li><a href="dropdown2.html" class="link2">hyperlink 2</a><font color="white"><span class="darrow">▼</font></span>
<ul class="sub1">
<li><a href="#">hyperlink 2.1</a></li>
<li><a href="#">hyperlink 2.2</a></li>
<li><a href="#">hyperlink 2.3</a></li>
</ul>
</li>
<li><a href="#">hyperlink 3</a></li>
<li><a href="#">hyperlink 4</a><span class="darrow"><font color="white">▼</font></span>
<ul class="sub1">
<li><a href="#">hyperlink 4.1</a></li>
<li><a href="#">hyperlink 4.2</a></li>
<li><a href="#">hyperlink 4.3</a><span class="rarrow"><font color="white">▶</font></span>
<ul class="sub2">
<li><a href="#">hyperlink 4.3.1</a></li>
<li><a href="#">hyperlink 4.3.2</a></li>
<li><a href="dropdown3.html" class="link3">hyperlink 4.3.3</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">hyperlink 5</a></li>
</ul></div></td></tr>
</table>
</div>
<div class="promobox" id="pb3"> </div>
</div>
</div>
</body>
</html>
答案 0 :(得分:0)
如果没有jsfiddle示例,您的问题就会模糊不清。请在jsfiddle上向我们展示实时示例。
如果您在菜单顶部的表格中获得空格,请在表格标签上设置cellspacing =“0”
<table cellspacing="0">
要让您的菜单位于表格中间,请使用display: inline-block;
上的ul#navmenu li
和ul#navmenu a
代替浮点数,并将text-align: center;
放在ul#navmenu上
浮点元素不能以margin为中心:auto或text-align:center这就是我们必须更改要显示的元素行为的原因:inline-block将每个元素放在一起,并使其成为父元素的中心。< / p>