调整大小时,将列表元素保留在同一行中。 CSS液体布局 [英] Keep list elements in the same line when resizing. CSS liquid layout

查看:143
本文介绍了调整大小时,将列表元素保留在同一行中。 CSS液体布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个菜单,我发现如何做一个教程,但我只有一个麻烦。当我调整页面大小的所有布局更改以适应新的窗口大小,但是当文本不适合在屏幕上的菜单似乎使新行。我想要所有的菜单保持在一行,即使窗口的大小太小,不能显示所有。我试过很多的黑客我发现这里,但没有人似乎为我工作。这是我使用的CSS。

I have this menu I found how to made on a tutorial but I have just one trouble. When I resize the page all the layout changes to fit into the new window size but the menu seems to make new lines when the text doesn't fit on the screen. I want that all the menu remains in one line even if the size of the window is too small to show it all. I have tried lots of hacks I've found here but no one seems to work for me. This is the CSS I'm using.

#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代码位于此处。

And the HTML code for the menu structure is here.

<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&iacute;as</a></li>
        <li><a href="#">Cat&aacute;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

我不在乎菜单是否显示完成,但我需要它同一行。
我希望你能帮助我。

I don't care if the menu shows complete or not but I need it on the same line. I hope you can help me

推荐答案

http://jsfiddle.net/3aSTE/

设置一个难度为 #menu overflow-y:hidden

这篇关于调整大小时,将列表元素保留在同一行中。 CSS液体布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆