html - 如何添加侧边栏?

标签 html css

这是 post.html 的 css:

/* Space out content a bit */
body {
  padding-top: 20px;
  padding-bottom: 20px;
}
/* Everything but the jumbotron gets side spacing for mobile first views */
.header,
.marketing,
.footer {
  padding-right: 15px;
  padding-left: 15px;
}

/* Custom page header */
.header {
  border-bottom: 1px;
}
/* Make the masthead heading the same height as the navigation */
.header h3 {
  margin-top: 0;
  margin-bottom: 0;
  line-height: 40px;
}

/* Custom page footer */
.footer {
  padding-top: 19px;
  color: #777;
  border-top: 1px solid #e5e5e5;
}

/* Customize container */
@media (min-width: 768px) {
  .container {
    max-width: 60%;
  }
}
.container-narrow > hr {
  margin: 30px 0;
}

.jumbotron {
  border-bottom: 1px solid #e5e5e5;
}
.jumbotron .btn {
  padding: 14px 24px;
  font-size: 21px;
}

.marketing {
  margin: 40px 0;
}
.marketing p + h4 {
  margin-top: 28px;
}

@media screen and (min-width: 768px) {
  /* Remove the padding we set earlier */
  .header,
  .marketing,
  .footer {
    padding-right: 0;
    padding-left: 0;
  }
  /* Space out the masthead */
  .header {
    margin-bottom: 30px;
  }
  /* Remove the bottom border on the jumbotron for visual effect */
  .jumbotron {
    border-bottom: 0;
  }
}

如何添加侧边栏? max-width 属性负责页面中心的主要内容。如何向边添加内容? Float:right 不起作用 right float 的内容位于中心内容的右侧,而不是页面的右侧。

最佳答案

我不确定你所说的侧边栏是指隐藏菜单还是右栏。

右栏:

  <div id="rightColumn">
        stuff goes here...
  </div>

div#rightColumn 
{
  float: right; 
  right: 15px;
  width: 150px;
}

...是一种方式。右栏 div 在 HTML 正文中,在任何主要内容区域 div 中;我怀疑你有它在里面,这会导致你看到的行为。

如果是隐藏菜单,则需要 Javascript;见http://semantic-ui.com/modules/sidebar.html#/examples .但是您没有将其作为标签,所以我假设您指的是右列或左列。

关于html - 如何添加侧边栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26023895/

相关文章:

html - 如何使用媒体查询制作响应式页脚

javascript - 如何在 ReactJS 中验证输入类型 ="number"?

javascript - jQuery 动画运行不流畅

html - Opera 忽略链接上的背景悬停过渡

html - 具有不断变化的元素 HTML 的背景

javascript - JS 中 for 循环的计时

javascript - Flexbox 仅适用于 Chrome

css - 带有边框底部和边框半径的按钮不是预期的结果

css - 图像不会出现在外部 CSS 中

HTML 显示不正确,列嵌套在另一列中