/    Sign up×
Community /Pin to ProfileBookmark

CSS – Positioning

Hi,

I have an HTML Button on my page and a <div> element (which contains some text), clicking on the button should display the <div> element just UNDER the button (no matter where the button is on the page)

is this something has to do with absolute positioning in CSS?

Please tell me the syntax (or example) for it.

Thanx

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@CentauriAug 20.2008 — That depends a bit on what code you have that displays the div at the moment. If the div follows the button in the html, and is hidden and displayed using display:none and display:block, then it would naturally appear below the button.
Copy linkTweet thisAlerts:
@phantom007authorAug 20.2008 — That depends a bit on what code you have that displays the div at the moment. If the div follows the button in the html, and is hidden and displayed using display:none and display:block, then it would naturally appear below the button.[/QUOTE]

This is my code
[code=html]
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test</title>
</head>
<body>
<div id="mydiv">Text here..Text here..Text here..Text here..</div>
<p>&nbsp;</p>
<table width="100%" border="1" cellspacing="2" cellpadding="2">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="center"><input type="submit" name="Submit" value="Click Here..." /></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>
</body>
</html>

[/code]
Copy linkTweet thisAlerts:
@CentauriAug 20.2008 — First of all, what is the table for?..

Second, a submit button input needs to be within a form.

Thirdly, if the div is completely divorced from the button that displays it (and before it in the html), as well as not making sense semantically, you would not be able to position it relative to the button.

If the button is within a form, then the div can also be within that form following the button. A simple show/hide javascript attached to the button's onclick event can show the div.
×

Success!

Help @phantom007 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...