一部分div透明吗? [英] Part of div transparent?

查看:104
本文介绍了一部分div透明吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以仅使div的一部分透明,就像在div中留出一定的空间一样.

Is it possible to make only part of div transparent like an amount of space in div.

例如,您从div的顶部选择100px,顶部的100px设置了不透明度?

For example, you select 100px from top of div and the top 100px have an opacity set?

我该怎么办?

推荐答案

您可以做几件事:

  1. 尝试背景图像,其中一半是透明的,另一半不是.

  1. Try a background image where half is transparent and the other half is not.

以这样的方式使用CSS渐变:一半是透明的,而另一半不是透明的.例如:

Use a CSS gradient in such a way that half is transparent and the other is not. Ex:

background: -moz-linear-gradient(top, rgba(30,87,153,0) 0%, rgba(41,137,216,0) 50%, rgba(34,125,203,1) 52%, rgba(125,185,232,1) 100%); /* FF3.6+ */

  • 使用多个div,其中一个具有透明的BG,而另一个没有.例如:

  • Use multiple divs where one has transparent BG and the other does not. Ex:

    <div>
       <div id="transparent" style="background: transparent"></div>
       <div id="not-transparent" style="background: #000"></div>
    </div>
    

  • 我敢肯定还有其他方法,但这是想到的前三种方法.

    I'm sure there are other ways, but those are the first three that come to mind.

    祝你好运.

    这篇关于一部分div透明吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆