Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Part of div transparent?

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

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

How would I do it?

like image 967
DemCodeLines Avatar asked Dec 07 '11 21:12

DemCodeLines


People also ask

Can a div be transparent?

If you just want your element to be transparent, it's really as easy as : background-color: transparent; But if you want it to be in colors, you can use: background-color: rgba(255, 0, 0, 0.4);

How do I make a section transparent in HTML?

First, we create a <div> element (class="background") with a background image, and a border. Then we create another <div> (class="transbox") inside the first <div>. The <div class="transbox"> have a background color, and a border - the div is transparent.

How do I create a part of a div?

Simply just layer the div's and place the images as background images in your CSS. It's clean, neat and very easy to acomplish what you are looking for.


1 Answers

You can do a couple of things:

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

  2. 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+ */
    
  3. 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.

Good luck.

like image 121
Jemaclus Avatar answered Oct 11 '22 19:10

Jemaclus