我有这个菜单,我发现如何制作教程,但我只有一个麻烦。当我调整页面大小时,所有布局都会更改以适应新窗口大小,但是当文本不适合屏幕时,菜单似乎会生成新行。我希望所有菜单都保留在一行中,即使窗口的大小太小而无法显示所有菜单。我已经尝试了很多我在这里找到的黑客攻击,但似乎没有人能为我工作。这是我正在使用的CSS。
#navcontainer {
margin: auto;
width: 95%;
}
#menu
{
width: 100%;
margin: 0;
padding: 0 0 0 0;
list-style: none;
background: #C2D1DA;
background: -moz-linear-gradient(#DDE7ED, #C2D1DA);
background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #C2D1DA),color-stop(1, #DDE7ED));
background: -webkit-linear-gradient(#DDE7ED, #C2D1DA);
background: -o-linear-gradient(#DDE7ED, #C2D1DA);
background: -ms-linear-gradient(#DDE7ED, #C2D1DA);
background: linear-gradient(#DDE7ED, #C2D1DA);
-moz-border-radius: 50px;
border-radius: 50px;
-moz-box-shadow: 0 2px 1px #9c9c9c;
-webkit-box-shadow: 0 2px 1px #9c9c9c;
box-shadow: 0 2px 1px #9c9c9c;
}
#menu li
{
float: left;
padding: 0 0 10px 0;
position: relative;
line-height: 0;
}
#menu a
{
float: left;
height: 13px;
padding: 0 25px;
color: #1A6B91;
text-transform: uppercase;
font: bold 12px/25px Arial, Helvetica;
text-decoration: none;
text-shadow: 0 0px 1px #004063;
}
#menu li:hover > a
{
color: #333;
}
*html #menu li a:hover /* IE6 */
{
color: #333;
}
#menu li:hover > ul
{
display: block;
}
/*SUB MENU*/
#menu ul
{
list-style: none;
margin: 0;
padding: 0;
display: none;
position: absolute;
top: 23px;
left: 0;
z-index: 99999;
background: #DDE7ED;
background: -moz-linear-gradient(#DDE7ED, #C2D1DA);
background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #C2D1DA),color-stop(1, #DDE7ED));
background: -webkit-linear-gradient(#DDE7ED, #C2D1DA);
background: -o-linear-gradient(#DDE7ED, #C2D1DA);
background: -ms-linear-gradient(#DDE7ED, #C2D1DA);
background: linear-gradient(#DDE7ED, #C2D1DA);
-moz-box-shadow: 0 0 2px rgba(255,255,255,.5);
-webkit-box-shadow: 0 0 2px rgba(255,255,255,.5);
box-shadow: 0 0 2px rgba(255,255,255,.5);
-moz-border-radius: 5px;
border-radius: 5px;
}
#menu ul ul
{
top: 0;
left: 190px;
}
#menu ul li
{
float: none;
margin: 0;
padding: 0;
display: block;
-moz-box-shadow: 0 1px 0 #0A486C, 0 2px 0 #1A6891;
-webkit-box-shadow: 0 1px 0 #0A486C, 0 2px 0 #1A6891;
box-shadow: 0 1px 0 #0A486C, 0 2px 0 #1A6891;*/
}
#menu ul li:last-child
{
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
#menu ul a
{
padding: 10px;
height: 10px;
width: 170px;
height: auto;
line-height: 1;
display: block;
white-space: nowrap;
float: none;
text-transform: none;
}
*html #menu ul a /* IE6 */
{
height: 10px;
width: 170px;
}
*:first-child+html #menu ul a /* IE7 */
{
height: 10px;
width: 170px;
}
#menu ul a:hover
{
background: #0186ba;
background: -moz-linear-gradient(#04acec, #0186ba);
background: -webkit-gradient(linear, left top, left bottom, from(#04acec), to(#0186ba));
background: -webkit-linear-gradient(#04acec, #0186ba);
background: -o-linear-gradient(#04acec, #0186ba);
background: -ms-linear-gradient(#04acec, #0186ba);
background: linear-gradient(#04acec, #0186ba);
}
#menu ul li:first-child a
{
-moz-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0;
}
#menu ul li:first-child a:after
{
content: '';
position: absolute;
left: 30px;
top: -8px;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 8px solid #DDE7ED;
}
#menu ul ul li:first-child a:after
{
left: -8px;
top: 12px;
width: 0;
height: 0;
border-left: 0;
border-bottom: 5px solid transparent;
border-top: 5px solid transparent;
border-right: 8px solid #DDE7ED;/*cambiar por gradiente*/
}
#menu ul li:first-child a:hover:after
{
border-bottom-color: #04acec;
}
#menu ul ul li:first-child a:hover:after
{
border-right-color: #04acec; /*cambiar por gradiente*/
border-bottom-color: transparent;
}
#menu ul li:last-child a
{
-moz-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
}
/* Clear floated elements */
#menu:after
{
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
菜单结构的HTML代码就在这里。
<script type="text/javascript">
$(function() {
if ($.browser.msie && $.browser.version.substr(0,1)<7)
{
$('li').has('ul').mouseover(function(){
$(this).children('ul').show();
}).mouseout(function(){
$(this).children('ul').hide();
})
}
});
</script>
<div id="navcontainer">
<ul id="menu">
<li><a href="#" onclick="inicio();">Inicio</a></li>
<li><a href="#">ISO 9001</a>
<ul>
<li><a href="#">Nueva A.C. o A.P.</a></li>
<li><a href="#">Tabla A.C. y A.P.</a></li>
</ul>
</li>
<li><a href="#" onclick="muestras();">Muestras</a>
<ul>
<li><a href="#" onclick="muestras();">Solicitud de Muestra</a></li>
<li><a href="#" onclick="muestrasPendientes();">Muestras Pendientes</a></li>
<li><a href="#">Muestras Terminadas</a></li>
<li><a href="#">Garantías</a></li>
<li><a href="#">Catálogo de Productos</a></li>
</ul>
</li>
<li><a href="#" onclick="proyectos();">Proyectos</a>
<ul>
<li><a href="#" onclick="proyectos();">Nuevo Proyecto</a></li>
<li><a href="#" onclick="proyectosVista();">Proyectos</a></li>
<li><a href="#">Nueva Actividad</a></li>
<li><a href="#">Actividades Proyectos</a></li>
</ul>
</li>
<li><a href="#" onclick="tickets();">Tickets</a>
<ul>
<li><a href="#" onclick="tickets();">Nuevo Ticket</a></li>
<li><a href="#" onclick="ticketsAbiertos();">Tickets Abiertos</a></li>
<li><a href="#" onclick="ticketsTerminados();">Tickets Terminados</a></li>
<li><a href="#" onclick="ticketsPorTerminar();">Tickets por Terminar</a></li>
</ul>
</li>
<li><a href="#" onclick="iCalendar();">iCalendar</a></li>
<li><a href="#" onclick="mkt();">MKT</a>
<ul>
<li><a href="#" onclick="publicidad();">Enviar Boletin</a></li>
</ul>
</li>
<li><a href="#">Juntas</a>
<ul>
<li><a href="#">Nuevo Compromiso</a></li>
<li><a href="#">Compromisos Abiertos</a></li>
<li><a href="#">Compromisos Terminados</a></li>
<li><a href="#">Todos los Compromisos</a></li>
<li><a href="#">Nueva Minuta</a></li>
<li><a href="#">Minutas Anteriores</a></li>
<li><a href="#">Calendario de Eventos</a></li>
<li><a href="#">Recordar Compromisos</a></li>
</ul>
</li>
<li><a href="https://www.estatec.com/webmail" target="_blank">Mail</a></li>
</ul>
</div>
* html #menu{
zoom: 1;
} /* IE6 */
*:first-child+html #menu{
zoom: 1;
} /* IE7 */
这是我需要的菜单 http://i.stack.imgur.com/wXLSw.png
这是我遇到的问题 http://i.stack.imgur.com/B01H9.png
我不在乎菜单是否显示完整但我需要在同一行。 我希望你能帮助我
答案 0 :(得分:4)
将硬度设置为#menu
和overflow-y:hidden
答案 1 :(得分:2)
这是最简单的答案!
只需将以下两个属性添加到#menu css文件
即可 text-align: left;
width: 1010px;
希望它能奏效!
答案 2 :(得分:0)
#menu {
width: 100%;
margin: 0;
padding: 0 0 0 0;
list-style: none;
background: #C2D1DA;
background: -moz-linear-gradient(#DDE7ED, #C2D1DA);
background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #C2D1DA),color-stop(1, #DDE7ED));
background: -webkit-linear-gradient(#DDE7ED, #C2D1DA);
background: -o-linear-gradient(#DDE7ED, #C2D1DA);
background: -ms-linear-gradient(#DDE7ED, #C2D1DA);
background: linear-gradient(#DDE7ED, #C2D1DA);
-moz-border-radius: 50px;
border-radius: 50px;
-moz-box-shadow: 0 2px 1px #9c9c9c;
-webkit-box-shadow: 0 2px 1px #9c9c9c;
box-shadow: 0 2px 1px #9c9c9c;
min-width: 952px;
}
使用CSS中的min-width
属性。