Is using layers OK?

Is using layers OK?<br />
Or is it frowned upon?<br />
<br />
Or should I be using CSS?<br />
<br />
I want to use layers to have Flash adverts that expand out.<br />
(Erm... I know most of the time these things are sooo annoying... but I'll be doing it in a subtle and less obtrusive way!)<br />
<br />
Any opinions would be greatful.<br />
<br />
Thanks.<br />
<br />
<br />
Jam<!--content-->When you say layre, do you mean <layer> or <div>?<br />
<br />
If it's <div> then go for it.<!--content-->Well... I'm not sure...<br />
Using layers, I want to overlap things.<br />
So, I assume that I must use <layer>?<br />
<br />
Or can I use <div> to do overlapping as well?<!--content-->No, an actual layer is not ok. Its a dead element. Same thing with <ilayer>.<br />
<br />
Yes a div can over lap, scroll, do whatever you want it to with css.<br />
<br />
Is this what you mean by overlap?<br />
<!-- m --><a class="postlink" href="http://quasi-ke.servebeer.com/divtst.htm">http://quasi-ke.servebeer.com/divtst.htm</a><!-- m --><br />
<br />
<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<html><br />
<head><br />
<title>over under</title><br />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/><br />
<style type="text/css"><br />
#under {<br />
height:200px; <br />
width:200px; <br />
z-index:1; <br />
border:1px solid #000000; <br />
background-color:blue;<br />
}<br />
#over {<br />
height:200px; <br />
width:200px; <br />
z-index:2; <br />
border:1px solid #000000; <br />
margin-top:-100px; <br />
margin-left:100px; <br />
background-color:green;<br />
}<br />
</style><br />
</head><br />
<body><br />
<div id="under">This div is under</div><br />
<div id="over">This div is over</div><br />
</body><br />
</html><br />
<br />
This is the css making the divs do that<br />
<br />
<style type="text/css"><br />
#under {<br />
height:200px; <br />
width:200px; <br />
z-index:1; <br />
border:1px solid #000000; <br />
background-color:blue;<br />
}<br />
#over {<br />
height:200px; <br />
width:200px; <br />
z-index:2; <br />
border:1px solid #000000; <br />
margin-top:-100px; <br />
margin-left:100px; <br />
background-color:green;<br />
}<br />
</style><!--content-->Thanks for the reply.<br />
I'm still a bit confused.<br />
What does the 'z-index:1' do?<br />
I assumed this determined which was on top?<br />
I tried swapping the values of these.<br />
But this had no effect?<!--content-->the higher the z-index, the higher it will be. A div with z-index:2; will go above a z-index:1; and 3 above that and so on and so fourth. Default value is 0.<!--content-->Well... I did the following (I changed the z-index values):<br />
<br />
<br />
<html><br />
<head><br />
<title>over under</title><br />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/><br />
<style type="text/css"><br />
#under {<br />
height:200px; <br />
width:200px; <br />
z-index:5; <br />
border:1px solid #000000; <br />
background-color:blue;<br />
}<br />
#over {<br />
height:200px; <br />
width:200px; <br />
z-index:2; <br />
border:1px solid #000000; <br />
margin-top:-100px; <br />
margin-left:100px; <br />
background-color:green;<br />
}<br />
</style><br />
</head><br />
<body><br />
<div id="under"></div><br />
<div id="over"></div><br />
</body><br />
</html><br />
<br />
<br />
And under was still under??<!--content-->http://quasi-ke.servebeer.com/divtst.htm<br />
look again. I forgot<br />
position:relative; put that in both of the blocks. z-index is a type of positioning (z axis) so it needs a type of positioning. Just like if you use top bottom left and right you need a positioning.<br />
<!-- m --><a class="postlink" href="http://www.w3schools.com/css/css_positioning.asp">http://www.w3schools.com/css/css_positioning.asp</a><!-- m --> here is more on it, look the last two links. You can see how z-index can be used to create a background image, which can be very conveiniant sometimes.<!--content-->Thanks for the reply.<br />
Your link doesn't seem to work though?<br />
Can you give the code? :)<br />
Thanks.<!--content--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<html><br />
<head><br />
<title>over under</title><br />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/><br />
<style type="text/css"><br />
#under {<br />
height:100px; <br />
position:relative;<br />
width:100px; <br />
z-index:1; <br />
border:1px solid #000000; <br />
background-color:blue;<br />
}<br />
#over {<br />
height:100px; <br />
position:relative;<br />
width:100px; <br />
z-index:2; <br />
border:1px solid #000000; <br />
margin-top:-50px; <br />
margin-left:50px;<br />
background-color:green;<br />
}<br />
#under2 {<br />
height:100px; <br />
position:relative;<br />
width:100px; <br />
z-index:3;<br />
margin-top:-50px;<br />
margin-left:100px;<br />
border:1px solid #000000; <br />
background-color:blue;<br />
}<br />
#over2 {<br />
height:100px; <br />
position:relative;<br />
width:100px; <br />
z-index:2; <br />
border:1px solid #000000;<br />
margin-top:-50px; <br />
margin-left:150px; <br />
background-color:green;<br />
}<br />
</style><br />
</head><br />
<body><br />
<div id="under">This div is under</div><br />
<div id="over">This div is over</div><br />
<div id="under2">This div is now over</div><br />
<div id="over2"><br/><br/><br/>This div is now under</div><br />
</body><br />
</html><br />
<br />
neither link works? :(<!--content-->OK... kewl... I get it now. :)<br />
BUT... why do I need to use <div>??<br />
I can achieve the same results by applying the style on the object I want to apply it to?<br />
Let me know.<br />
Thanks.<!--content-->Originally posted by jammer20002 <br />
I can achieve the same results by applying the style on the object I want to apply it to?If you can get the same effect without adding extra tags then do it, your page will load slightly faster, be rendered slightly faster and your code will be more semantic.<br />
<div> tags are handy because they have no default rendering applied to them (other than display:block), be careful when you apply the same styles to another element which may have default styles applied to it.<!--content-->Yes, like lava lamp said, you can do the same thing i did with this div with a list, table, <p>, any block element you want. But a div is just a stand alone block, it is the easiest to use. Like if you used a table it would want to stretch and the cells would snap tegether, it would also not be semantically corect. A paragraph will have spaces around it and is designed for text and it would not be semantically correct to use for this either.<!--content-->
 
Back
Top