我想将我的下拉菜单栏移到右侧。
我尝试过右对齐和文本对齐:右边,结果是菜单向右移动,但下拉菜单没有。
现在我有以下下拉菜单,但在左侧:
使用以下CSS:
#headermenu {
}
#headermenu a:hover, #headermenu a:active, #headermenu a:focus, #headermenu a.thispage {
color: #39729B;
}
#headermenu ul {
padding:0;
list-style: none;
position: relative;
display:block;
}
#headermenu ul li {
float:left;
display:list-item;
list-style: none;
}
#headermenu ul li a {
display:block;
padding:5px;
color:#FFFFFF;
text-decoration: none;
width: 70px;
text-align: center;
border-color: #39729B;
border-width: thin;
border-right-style: solid;
background-color: #062134;
}
/* Change this in order to change the Dropdown symbol */
li > a:after { content: ''; }
li > a:only-child:after { content: ''; }
/* The Dropdown Styles */
/* =================== */
/* Hide Dropdowns by Default */
#headermenu ul ul {
display: none;
position: absolute;
}
/* Display Dropdowns on Hover */
#headermenu ul li:hover > ul {
display:list-item;
}
/* Fisrt Tier Dropdown */
#headermenu ul ul li {
width:170px;
float:none;
position: relative;
border-bottom:none;
}

<div id="headermenu">
<ul>
<li><a href="../About.html">About</a></li>
<li><a href="../JobsMainpage.php" class="this">Jobs</a>
<!-- First Tier Drop Down -->
<ul class="lol">
<li><a href="../Jobs.php">Available Jobs</a></li>
<li><a href="../MyJobs.php">My Jobs</a></li>
<li><a href="../PostJob.php">Post Job</a></li>
<li><a href="../MyPage.php">My Page</a></li>
</ul>
</li>
<li><a href="../index.php?logout">Log out</a></li>
<!-- First Tier Drop Down -->
</ul>
</div>
&#13;
答案 0 :(得分:3)
将float: right;
添加到#headermenu
css,如下所示:
#headermenu {
float: right;
}
#headermenu a:hover, #headermenu a:active, #headermenu a:focus, #headermenu a.thispage {
color: #39729B;
}
#headermenu ul {
padding:0;
list-style: none;
position: relative;
display:block;
}
#headermenu ul li {
float:left;
display:list-item;
list-style: none;
}
#headermenu ul li a {
display:block;
padding:5px;
color:#FFFFFF;
text-decoration: none;
width: 70px;
text-align: center;
border-color: #39729B;
border-width: thin;
border-right-style: solid;
background-color: #062134;
}
/* Change this in order to change the Dropdown symbol */
li > a:after { content: ''; }
li > a:only-child:after { content: ''; }
/* The Dropdown Styles */
/* =================== */
/* Hide Dropdowns by Default */
#headermenu ul ul {
display: none;
position: absolute;
}
/* Display Dropdowns on Hover */
#headermenu ul li:hover > ul {
display:list-item;
}
/* Fisrt Tier Dropdown */
#headermenu ul ul li {
width:170px;
float:none;
position: relative;
border-bottom:none;
}
&#13;
<div id="headermenu">
<ul>
<li><a href="../About.html">About</a></li>
<li><a href="../JobsMainpage.php" class="this">Jobs</a>
<!-- First Tier Drop Down -->
<ul class="lol">
<li><a href="../Jobs.php">Available Jobs</a></li>
<li><a href="../MyJobs.php">My Jobs</a></li>
<li><a href="../PostJob.php">Post Job</a></li>
<li><a href="../MyPage.php">My Page</a></li>
</ul>
</li>
<li><a href="../index.php?logout">Log out</a></li>
<!-- First Tier Drop Down -->
</ul>
</div>
&#13;