将固定容器集中在自举转盘上

时间:2013-12-17 13:36:29

标签: html5 css3 twitter-bootstrap-3 carousel centering

我有一个全屏版本的bootstrap轮播工作非常好。

但是,我想将一个包含三个图标的div水平和垂直居中,并将其固定在滑动轮播图像上。

我尝试过设置班级的宽度:

.centered {
  position:fixed; 
  width: 500px;
  margin: 0 auto;

 }

但是,左上角的三个图标不多。

如果您想检查我的HTML代码,可以使用以下链接:

http://www.gregorydanelian.comule.com/stu/

非常感谢程序员!

1 个答案:

答案 0 :(得分:1)

使用绝对/固定居中:

  .parent {
     position: relative;
  }
  .centered {
     position: absolute;
     top: 0;
     right: 0;
     bottom: 0;
     left: 0;
     margin: auto;
     width: 500px;
     height: 200px;
 }

使用此方法,您将水平和垂直居中。缺点是你需要固定中心元素的宽度和高度。

以下是position: fixed; http://jsfiddle.net/ngP8f/

的版本 祝你好运!