Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Old 11-26-2009, 04:46 PM refer to div styles
Skilled Talker

Posts: 55
Trades: 0
I have the following code:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>(Type a title for your page here)</title>
<style type="text/css">
div.one {
position: absolute;
left: 100px;
top: 400px;
background-color: #f1f1f1;
width: 180px;
padding: 10px;
color: black;
border: #0000cc 2px dashed;
display: none;
}

div.two {
position: absolute;
left: 100px;
top: 200px;
background-color: #f1f1f1;
width: 180px;
padding: 10px;
color: black;
border: #0000cc 2px dashed;
display: none;
}
</style>

<script language="JavaScript">
function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;
}
</script>

</head>
<body >

<input type=button name=type value='Show Layer1' onclick="setVisibility('sub1', 'inline');";>
<input type=button name=type value='show Layer2' onclick="setVisibility('sub2', 'inline');";> 

<div class="one" id="sub1">Message Box</div>
<div class="two" id="sub2">Message Box 2</div>
</body>
</html>
I want to be able to display different divs depending on the button i press. How do i define 2 different types of divs like i did above and refer to them for each button?
philmetz is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-26-2009, 05:08 PM Re: refer to div styles
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Use the ID attribute.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-26-2009, 05:23 PM Re: refer to div styles
Skilled Talker

Posts: 55
Trades: 0
I tried that but dont think its right. How do i give each div an id in the css stylesheet?
philmetz is offline
Reply With Quote
View Public Profile
 
Old 11-26-2009, 05:30 PM Re: refer to div styles
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Code:
#elementid {
        property:value;
}
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to refer to div styles
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15407 seconds with 12 queries