【问题标题】:How do I center my carousel?如何使我的轮播居中?
【发布时间】:2018-11-21 05:46:30
【问题描述】:

我在这里阅读了一些建议并已经尝试过,但没有一个对我有用。所以我在这里包括我的代码,看看是否有人能指出我正确的方向。

  1. 我想使旋转木马居中。
  2. 我想要一个带有文本的旋转木马内的单独容器,并且我希望该容器看起来有点褪色,带有不透明元素或 RGB (0,0,0,0.4).. 元素。

HTML-

我不知道如何在此处发布 HTML 而不出现间距错误,因此我在 codepen 中打开了一支笔:

https://codepen.io/mahiya-hawk/pen/YvZMbM

CSS-

* {
    margin: 0;
    padding: 0;
}
body {
    font-family: Calibri, sans-serif;
}
.background-wrap {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    top: 0;
    left: 0;
    z-index: -1000;
}
#video-bg-elem {
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    object-fit: cover;
}
.navbar{
    background-color: RGBA(0,0,0,0.2) !important;
}
#brand-image{
    height: 100px;
}
a.navbar-brand{
    position: relative;
}
.navbar-nav > li{
    margin-left:10px;
    padding: 33px 10px;
  }
.navbar-nav > li > a{
    text-decoration: none;
    font-size: 2vh;
    font-size: 2.3vw;
    font-family: 'Freestyle Script';
    font-weight: 900;
    color: rgb(210, 21, 84) !important;
    padding-bottom: 0.2%;
    display: block;
}
.navbar-nav > li:hover,
.navbar-nav > li:focus {
    background-color: RGBA(0,0,0,0.4) !important;
    transition: .9s;
}
.navbar-nav > .active > a,
.navbar-nav > .active > a:hover,
.navbar-nav > .active > a:focus {
    background-color: RGBA(0.0..0.4) !important;
}
.content {
    position: absolute;
    width: 100%;
    min-height: 100%;
}
.content h1 {
    text-align: center;
    font-size: 65px;
    text-transform: uppercase;
    font-weight: 300;
    color: #fff;
    margin-top: 5%;
    margin-bottom: 10px;
}
.content p {
    text-align: center;
    font-size: 20px;
    letter-spacing: 3px;
    color: #aaa;
}
.navbar-expand-lg .navbar-collapse {
    margin:-7px;
}
/* CUSTOMIZE THE CAROUSEL
-------------------------------------------------- */
/* Carousel base class */
.carousel {
    width: 1200px;
    margin-bottom: 480px;
}

/* Since positioning the image, we need to help out the caption */
.carousel-caption {
    z-index: 10;
}

/* Declare heights because of positioning of img element */
.carousel .item {
    height: 500px;
    background-color: #777;
}

.carousel-inner > .item > img {
    position: absolute;
    top: 0;
    left: 0;
    min-width: 100%;
    height: 480px;
}

【问题讨论】:

    标签: javascript html css bootstrap-4 carousel


    【解决方案1】:

    把这条规则放到你的班级里:

    .carousel {
        max-width: 1200px;
        width: auto;
        margin: 0 auto 0 auto;
        text-align: center;
    }
    

    【讨论】:

    • 嗨@Jaziel_Inc。你太棒了。那行得通。谢谢!!你能告诉我如何让旋转木马变小一点,因为 1200 太大了,我想要屏幕两侧的边距..
    • 嘿,如果你想让你的轮播更小,只需改变 max-width 属性,输入你想要的大小,我把 1200px 只是作为例子,但你可以改变你想要的大小,试试吧,我不是专家,但我认为会起作用。
    • @MahiyaHawk 如果此答案解决了您的问题,请单击复选标记考虑accepting it。这向更广泛的社区表明您已经找到了解决方案,并为回答者和您自己提供了一些声誉。没有义务这样做。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-12
    • 2015-02-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多