html - 元素的放置

标签 html css layout drop-down-menu

请查看我发布的 fiddle ,并告诉我如何使菜单图标(三个星号 (*))出现在欢迎用户菜单旁边。即,在同一条线上,而不是在其下方。

enter link description here

这是一个代码片段:

/*DROPDOWN FUNCTIONALITY*/
ul { 
	padding:0; 
	margin:0
}
a {
	display:block;
	text-decoration: none;
}
li {
	display:block; 
	float:left;
}
li ul li {
	float:none;
}
li ul {
	display:none; 
	position:absolute; 
	z-index:1
}
li:hover ul {
	display:block;
}

/*DROPDOWN STYLING:*/
#menu {
	height:30px
}
#menu a {
	color:#024E67; 
	padding:10px 15px 10px 15px;
}
#menu a:hover {
	color:#ffffff;
}
#menu li {
	background-color:#FFF; 
	margin-left:-1px
}
#menu li:hover {
	background-color:#61b4cf
}
i {
  margin-right: 15px;
}
<nav>
    	<div id="UserSettings" name="UserSettings" class="UserSettings">
        <!-- offer welcome message to user logged in -->
        <div class="welcomeText" id="welcomeText" name="welcomeText">
        <label>Welcome SuperUser</label>
          <ul id="menu">
          <li>
            <a href="#"><i class="fa fa-bars" title="Menu"></i>***</a>
              <ul>
              <li><a href="#"><i class="fa fa-cog" title="Preferences"></i>Preferences</a></li>
              <li><a href="#"><i class="fa fa-user" title="Active Sessions"></i>Active Sessions</a></li>
              <li><a href="#"><i class="fa fa-lock" title="Change Password"></i>Change Password</a></li>
              </ul>
          </li>
          </ul>
        </div>
     </div>
`

最佳答案

ul 添加 display: inline-block; Demo

ul {
    display: inline-block;
    margin: 0;
    padding: 0;
}

关于html - 元素的放置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35312513/

相关文章:

css - WordPress 隐藏表格行下划线

xcode - Cocoa:如何让 child 适合 parent ?

html - iOS 中 textarea 上的 Shadow DOM 强制填充

javascript - JSON 在 HTML 中抛出未定义的错误

php - 犯罪代理API

html - 下拉栏 float 的右/下。整个网格移动一个悬停在它上面

html - div 内的 CSS 图像不会改变大小

html - Bootstrap V2 "boxed"(1170px) 布局中的全宽面板

Android TextView 文本仅在 Gingerbread 中被截断

html - 垫扩展面板删除边框