简体   繁体   English

引导水平导航栏不起作用。 显示为垂直

[英]bootstrap horizontal navbar not working. appears as vertical

hi i used bootstrap vertical navbar in my home page and now i want to make horizantal navbar in my gallery page. 嗨,我在首页中使用了垂直引导栏,现在我想在图库页面中制作水平导航栏。 but new navbar also displaying vertically. 但是新的导航栏也会垂直显示。 i want to make bootstrap default navbar for this page. 我想将此页面设为引导程序默认导航栏。 i used this code segmant to make vertiacl navbar in home page. 我使用此代码段在首页中制作了vertiacl navbar。

 /* make sidebar nav vertical */ 
@media (min-width: 768px) {
  .sidebar-nav .navbar .navbar-collapse {
    padding: 0;
    max-height: none;
  }
  .sidebar-nav .navbar ul {
    float: none;
  }
  .sidebar-nav .navbar ul:not {
    display: block;
  }
  .sidebar-nav .navbar li {
    float: none;
    display: block;
  }
  .sidebar-nav .navbar li a {
    padding-top: 12px;
    padding-bottom: 12px;
  }

now i want to undo these navbar to horizantal 现在我想撤消这些导航栏到水平

thnx n

You should learn what these properties you are using do.. 您应该了解所使用的这些属性的作用。

Display:block; : Quote from W3C W3C的报价

In a block formatting context, boxes are laid out one after the other, vertically, beginning at the top of a containing block. 在块格式设置上下文中,将框从包含块的顶部开始垂直地一个接一个地布置。 The vertical distance between two sibling boxes is determined by the 'margin' properties. 两个兄弟箱之间的垂直距离由'margin'属性确定。 Vertical margins between adjacent block boxes in a block formatting context collapse. 块格式化上下文中相邻块框之间的垂直边距折叠。

In a block formatting context, each box's left outer edge touches the left edge of the containing block (for right-to-left formatting, right edges touch). 在块格式设置上下文中,每个框的左外边缘与包含块的左边缘接触(对于从右到左的格式,右边缘接触)。 This is true even in the presence of floats (although a box's content area may shrink due to the floats). 即使存在浮子,也是如此(尽管由于浮子,盒子的容纳区域可能会缩小)。


Float:none; : Quote from Noah Stokes 诺亚·斯托克斯的名言

The float property has four values that we can apply to it: left, right, inherit, and none. float属性具有四个可以应用的值:left,right,inherit和none。 Each value is pretty self explanatory. 每个值都是很容易解释的。 For example, if you assign float: left to an element, it will move to the left-most boundary of its parent element. 例如,如果将float:left分配给元素,它将移动到其父元素的最左侧边界。 The same idea applies if you were to assign float: right; 如果要分配float,则适用相同的想法:right; to an element. 到一个元素。 That element would be sent off to the right-most boundary of its parent element. 该元素将被发送到其父元素的最右边边界。 The inherit value tells an element to inherit the float value of its parent element. 继承值告诉元素继承其父元素的float值。 The value none is the default value and tells an element not to float at all. 值none是默认值,它告诉元素根本不要浮动。

Floating means, very generally, to push a block-level element to the left or to the right, manipulating the flow in relation to other block elements. 浮动意味着通常将块级元素向左或向右推,从而控制相对于其他块元素的流程。

Block means to define the type of element and the space it takes up on the page. 块表示定义元素的类型及其在页面上所占的空间。 The majority of HTML elements are either going to be block or inline elements by default. 默认情况下,大多数HTML元素要么是block元素,要么是inline元素。 The display properties is used to manipulate these defaults. 显示属性用于操纵这些默认值。 Block elements, or elements manipulated with the display properties to be block elements will take up all of the horizontal space of it's parent, or, very generally, often begin at the beginning of a line and end at the end of the line. 块元素,或使用显示属性进行操作的元素将成为块元素的父元素的所有水平空间,或者通常在行的开头开始并在行的结尾结束。


Change your float:none; 更改float:none; to float:left; float:left; and display:block; display:block; to display:inline-block; display:inline-block;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM