html - 无法让 div 环绕我的标题。谁能明白为什么?

标签 html css navigation word-wrap

对于我的生活,我不明白为什么我的“div”不会环绕标题...我已经关闭它,未指定高度...

我已经搜索了其他帖子,但到目前为止还没有解决方案。是否存在我忽略的冲突?

这是 html:

<div id="navcontainer">
    <div id="siteLogo"> <a href="index.html"><img src="images/some image in a folder"/></a>        

    <div id="menu">
        <ul>
          <li><a href="index.html">Home</a></li>
            <li><a href="calendar.html">Calendar</a></li>
            <li><a href="contact.html">Contact</a></li>
        </ul>
    </div>
    </div>
 </div>

还有 CSS:

#menu li a:hover { 
    color: #ff9900;
    border-bottom: 4px solid #ff9900;
}

#siteLogo img{
    height:auto;
    width: 220px;
}

#menu {
font-family: 'Comfortaa', Arial, Helvetica, sans-serif;
font-size: 16px;
color: #c0c0c0;
    }

#outer {
    width: 960px;
    margin:0 auto;
}

#wraper {
    width: 900px;
    margin:0 auto;
}

#navcontainer {
    width: 900px;
    margin: 0 auto;
    border-bottom: thick 1px #ffppoo;
}

#siteLogo {
    float: left;
    margin-top: auto;
}

#menu {
    float: right;
    margin-top: auto;
}

#menu ul li {
    display:inline;
}

#menu ul {
    margin-top: 50px;
    text-align: center;
}

#menu ul li a {
    padding:0 0 0 20px;
}

最佳答案

略微更改您的语法并包含/清除您的float:

#navcontainer {
  width: 900px;
  margin: 0 auto;
  border-bottom: solid 1px #000;
  overflow: hidden;
}

http://jsfiddle.net/xSfrb/

关于html - 无法让 div 环绕我的标题。谁能明白为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21556865/

相关文章:

javascript - 路由问题 - 哈希标签 - Angular 2

html - 在 IE 中跨度悬停

css - 将输入占位符颜色更改为更深

javascript - 打印时缺少图像

CSS - 等高列?

javascript - 固定的动态侧边栏导航菜单?

html - 分别设置两个表的样式

javascript onload 在 while

android - 更改 Android 上 Activity 动画的 z 顺序

CSS 列表菜单;按钮翻转时的额外填充