Different CSS questions

Status
Not open for further replies.

Kavasa

Ars Tribunus Militum
2,722
So, I want to do something very simple: use CSS instead of image-rollovers to make buttons for a website, using the inset and outset borders.
They also need to be the same size.
Unfortunately, setting element width and element height for A tags didn't seem to do anything, so I put all the menu links inside P tags, with a specific style ascribed to 'em, as you can set the width and height of a P tag.

I.e.:
Code:
P.menu
{
border-style: outset;
}

P:hover.menu
{
border-style: inset;
}

Unfortunately, passing the mouse over the paragraph area doesn't seem to trigger the :hover as I was hoping it would. So, um, can I do this? If so, how?

Kavasa
 
HitScan is right. You can only use the :hover type with A elements.

To accomplish what you want, you'd need some code like this:

Code:
<style type="text/css">
p.menu       { border: 5px outset; }
</style>

<script language="JavaScript">
function change(id)
{
 id.style.border = "5px inset";
}
function change2(id)
{
 id.style.border = "5px outset";
}

</script>

<p class="menu" id="sample" onmouseover="change(sample);" onmouseout="change2(sample);">some text here</p>

i believe that this only works in IE 5+ though. Netscape seems to handle changing CSS attributes through javascript differently.

ryoma
 
can't you just use
Code:
display: block;
in the style for the a elements?

If i'm reading you right, you're looking for something like this, right? (warning: ugly and crude).

which is just:

Code:
a.menu {
	display:        block;
	width:          100px;
	margin:         0;
	border:         2px white outset;
	text-align:     center;
	text-decoration:none;
	color:          black;
	font-size:      11px;
}
a.menu:hover {
	border-style:   inset;
}

[This message was edited by arhra on April 29, 2002 at 16:30.]
 

Kavasa

Ars Tribunus Militum
2,722
grumbles

I figured it'd be like that. :hover is such a spiffy virtual element, it really ought to affect more stuff. Well, they're working on css3, so that'll prolly do it.

Plasdom - just the normal button-looking things, where there's a line of lighter pixels on top and left sides of a rectangle, then darker on bottom and right sides, to make it look like it's protruding from the page. I'd toss together an example, but I'm at work.

Edit - oh, look, whilst I was typing, someone else posted the solution. And an example. display: block. Got it. This is the problem with trying to dig through the W3C specs, they're so damn huge, finding the prop that does what you want when you don't know what it is can take a while.

Kavasa
 

Greg Hines

Ars Tribunus Militum
1,686
Subscriptor++
Originally posted by Kavasa:
I figured it'd be like that. :hover is such a spiffy virtual element, it really ought to affect more stuff. Well, they're working on css3, so that'll prolly do it.
I don't believe there are plans to expand the scope of the <code>:hover</code> pseudo-element. I believe there will be a <code>:focus</code> pseudo-element, however, and it might provide the desired behavior.

But CSS3 is going to be modular and it makes me cringe to think of the browser support for it even three or four years after the core modules have been recommended.
 
Status
Not open for further replies.