作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我只是想知道,因为我没有这样做,所以,我是否在促销框中的表格内获得了导航菜单,并在空白区域的顶部居中,并且在顶部中心框/td/单元格上没有边框帮助会很好,因为它很重要。
<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>
最佳答案
如果没有jsfiddle,你的问题就很模糊例子。请在 jsfiddle 上向我们展示现场示例.
如果您在菜单顶部的表格中出现空白,请像这样在表格标签上设置 cellspacing="0"
<table cellspacing="0">
要使您的菜单位于表格的中央,请在 ul#navmenu li
和 ul#navmenu a 上使用
而不是 float 并将 display: inline-block;
text-align: center;
放在 ul#navmenu 上
float 元素不能以 margin: auto 或 text-align: center 居中,这就是为什么我们必须将元素行为更改为 display: inline-block 以使每个元素彼此相邻并使其成为父元素的中心。
关于html - 导航菜单在表格的 td 内对齐且无边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23178332/
我是一名优秀的程序员,十分优秀!