【问题标题】:Centering a responsive slideshow使响应式幻灯片居中
【发布时间】:2012-09-19 19:52:14
【问题描述】:

我正在使用 RefineSlide 响应式幻灯片,但无法居中,它总是粘在我的页面左侧。

#slideshow{
position: relative;
width: 960px;
height:auto;
left: 50%;
margin-left: -480px;
}

我已尝试将上述内容添加到我的 CSS 中,尽管这成功地将其居中,但不幸的是它不再响应,因为当我在 iPhone 上测试时,幻灯片不适合屏幕。

#slideshow{
position: relative;
width: 100%;
height:auto;
}

当我这样设置它的样式时,它是响应式的……但会粘在左边。我需要对此 CSS 进行哪些更改以使其居中并保持响应?

【问题讨论】:

    标签: css slideshow responsive-design centering


    【解决方案1】:

    这在某种程度上取决于您的其他标记,但总的来说这已经足够了:

    #slideshow {
        margin: auto;
        width: Npx;
        /* also display: block if the element doesn't already have it */
    }
    

    Sample.

    【讨论】:

    • 这确实使它居中,但它没有响应。似乎每当我将宽度从百分比更改为像素时,它都会停止响应。
    • @user1636968:would make no difference 本身——你的标记的其余部分在这里发挥作用。
    猜你喜欢
    • 2012-12-29
    • 2014-04-23
    • 1970-01-01
    • 2018-02-07
    • 2016-03-10
    • 2016-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多