html - 在 HTML/CSS 中创建菜单

标签 html css list menu html-lists

我提前为这个愚蠢的问题道歉,但几年前我只学了一些基本的 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/

相关文章:

css - 以字间距和背景图像居中文本

javascript - anchor 标记不起作用

python - 如何输入参数以列表或元组的形式运行?

html - CSS List - 将列表元素完美地对齐宽度,它们之间的间距相等

html - 为什么 Chrome 移动仿真在宽度缩小时移动元素?

javascript - Jquery:选择 $(this) 所在的类

html - 图片提交表单

html - CSS 格式化换行符

jquery - 使用 jQuery 计算 <ul> 中的 <li> 数量

html - 如何使用CSS在一段中添加多种字体?