首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS过渡与三星Galaxy Tab 2

CSS过渡与三星Galaxy Tab 2
EN

Stack Overflow用户
提问于 2012-10-30 19:43:57
回答 1查看 593关注 0票数 0

我正在为平板电脑开发一个网络应用程序,我为我的复选框设计了一套div和一个标签,这样它看起来就像一个开关。(JsFiddle在这里。)

它在iPad 2& 3上工作得很好,但是当我在三星Galaxy 2上看到它时,它只在我将平板电脑从纵向转向景观时才会改变状态,反之亦然。

我也尝试过没有过渡,但仍然是同样的问题。

没有Javascript,我能得到我想要的效果吗?

所以不会让我链接到jsfiddle,下面是代码:

HTML:

代码语言:javascript
复制
<label class="switch" for="test">
    <input type="checkbox" id="test">
    <div class="track">
        <div class="knob"></div>
    </div>
</label>​

CSS:

代码语言:javascript
复制
label.switch > .track {
    width: 80px;
    height: 52px;
    border-radius: 60px;
    box-shadow: 0 1px 3px black inset, 0 -1px 1px rgba(255,255,255,0.15);
    /*border: 5px solid #666;*/
    display:inline-block;
    cursor:pointer;
    background: #333;
    background: -moz-linear-gradient(top,  rgba(0,0,0,0.65) 0%, rgba(0,0,0,0) 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.65)), color-stop(100%,rgba(0,0,0,0)));
    background: -webkit-linear-gradient(top,  rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%);
    background: -o-linear-gradient(top,  rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%);
    background: -ms-linear-gradient(top,  rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%);
    background: linear-gradient(to bottom,  rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%);
    transition: background .5s;
    -webkit-transition: background .5s;
    -moz-transition: background .5s;
    -o-transition: background .5s;
    -ms-transition: background .5s;
}

label.switch > .track > .knob {
    height: 54px;
    width: 54px;
    border-radius: 50px;
    margin-top:-1px;
    box-shadow: 0 2px 3px black, 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 0 0 5px rgba(237,237,237,1) inset;
    transition: margin-left .25s;
    -webkit-transition: margin-left .25s;
    -moz-transition: margin-left .25s;
    -o-transition: margin-left .25s;
    -ms-transition: margin-left .25s;
    background: rgb(191,191,191);
    background: -moz-linear-gradient(top,  rgba(191,191,191,1) 0%, rgba(246,246,246,1) 53%, rgba(255,255,255,1) 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(191,191,191,1)), color-stop(53%,rgba(246,246,246,1)), color-stop(100%,rgba(255,255,255,1)));
    background: -webkit-linear-gradient(top,  rgba(191,191,191,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%);
    background: -o-linear-gradient(top,  rgba(191,191,191,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%);
    background: -ms-linear-gradient(top,  rgba(191,191,191,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%);
    background: linear-gradient(to bottom,  rgba(191,191,191,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%);
}


label.switch > input {
    display:none;
}

label.switch > input:checked ~ .track {
    background: #D96200

}

label.switch > input:checked ~ .track > .knob {
    margin-left:26px;
}
​
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-31 18:42:08

Android平板电脑(至少三星Galaxy 2)推出了一个旧版本的Chrome作为默认浏览器。

此浏览器不识别普通同胞选择器 (~)。这就是为什么动画不能工作的原因。

解决方案是更改邻接同胞选择器 (+)通用同胞选择器的所有出现情况。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13146526

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档