html - Html/Css 上的透明磁贴,如 Windows Phone 8

标签 html css windows-phone-8

我想在网页上制作这样的用户界面。但我不明白我应该怎么做。我尝试了 z-index,但无法将页面制作成这样。

This is transparent tile example

<style>
    .divilk {
        background-color: red;
        z-index: 1;
        width: 100%;
        height: 500px;
    }

    .divikinci {
        background-color: purple;
        width: 200px;
        height: 300px;
        margin-left: 200px;
        margin-top: 100px;
        z-index: 2;
    }

    .divtrans {
        z-index: -999;
        background-color: transparent;
        margin-top: 100px;
        margin-left: 50px;
        height: 50px;
        width: 50px;
    }
</style>
<div style="margin-top:100px;">
    <div class="divilk">
        <div class="divikinci">
            <div class="divtrans"></div>
        </div>
    </div>
</div>

我尝试了 divtrans 的 z-index:1。

最佳答案

我认为您想要做的是创建一种透过黑色进入后面背景图像的窗口。这在 CSS 中是不可能的 - 您不能使元素的一部分透明而其余部分不透明。

作为一种可能的解决方法,您可以在每个单独的窗口上设置背景,并使用 background-position 调整位置。例如,像这样的东西:

.window {
    background-image: url('your-image.png');
    width:100px;
    height:100px;
    position:absolute;
    left:20px;
    top:20px;
    background-position:-20px -20px;
}

你可以在这里看到这样的效果:http://jsfiddle.net/ygmn8phw/

关于html - Html/Css 上的透明磁贴,如 Windows Phone 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25745518/

相关文章:

html - 为什么人们将他们的文件命名为 index.html?

javascript - 如何使用 javascript 和 Canvas 将图像切割成等距的单个图 block ?

html - 如何修复百分比宽度列 1px 间隙的显示柔性?

windows-phone-8 - 如何以编程方式从 Windows Phone 8 中选取照片

windows-phone-8 - 在 Windows Phone 8 中存储配置值/设置的最佳方式

angular - 如何从 Angular 的 PrimeNG 库中为 AutoComplete 组件设置焦点

php - HTML5 <audio> 隐藏音频源

css - Flying Saucer xhtml to pdf header margins on every page

javascript - sass:vh 和 px 之间的计算

windows - 使用 Windows Phone 应用程序进行的 PayPal 交易