我提前为这个愚蠢的问题道歉,但几年前我只学了一些基本的 html。我不太记得了。
我想在横幅顶部创建一个带有 2 个按钮(图像 + 悬停)的廉价菜单,但它们不想水平对齐并位于横幅的绝对中心。
喜欢这个http://i.imgur.com/Kcff92Q.png .
我搜索并检查了示例网站,但无法弄清楚这个网站。
这是 html 和 css。
HTML
<html>
<head>
<meta charset="UTF-8">
<title>Generic Title</title>
<link rel="stylesheet" type="text/css" href="css.css">
</head>
<body>
<div id="bannerb">
<div id="buttoncenter">
<div id="button1"><a href="index.html"><img src="images/homebout.gif" onmouseover="this.src='images/homebin.gif'" onmouseout="this.src='images/homebout.gif'"></a></div>
<div id="button2"><a href="page2.html"><img src="images/p2out.gif" onmouseover="this.src='images/p2in.gif'" onmouseout="this.src='images/p2out.gif'"></a></div>
</div>
</div>
</body>
</html>
CSS
#bannerb {
background:transparent url("images/bannerb.gif");
background-position:center center;
background-repeat:no-repeat;
margin-left:auto;
margin-right:auto;
height:150px;
width:800px;
}
#buttoncenter {
width:800px;
height:50px;
margin-left:auto;
margin-right:auto;
}
#button1 {
width:200px;
height:50px;
margin-left:auto;
margin-right:auto;
}
#button2 {
width:200px;
height:50px;
margin-left:auto;
margin-right:auto;
float:right;
}
最佳答案
从 button2
的 css 定义中移除 float:right;
一切都会顺利进行
关于html - 在 HTML/CSS 中创建菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28322241/