Go Back   SitePoint Forums > Forum Index > Design Your Site > Web Page Design > CSS
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Mar 18, 2006, 23:32   #1
jace41
SitePoint Zealot
 
Join Date: Mar 2005
Posts: 113
IE: a display block

I was playing around with some css files to compare them in the browsers and notice that IE doesn't support the a and hover display block that contain the link inside. Is there a hack or solution to address this problem?

css:
Code:
#testbox {
	background-color: #00CC00;
	width: 200px;
}

#test a {
	padding: 2px;
	display: block;
}

#test a:hover {
	background-color: #CC3300;
}
Code:
<dl id="testbox">
	<dt id="test"><a href="#">test1</a></dt>
</dl>

<div id="testbox">
	<div id="test"><a href="#">test1</a></div>
</div>
jace
jace41 is offline   Reply With Quote
Old Mar 19, 2006, 01:19   #2
AutisticCuckoo
SitePoint Wizard
silver trophybronze trophy
 
Join Date: Nov 2004
Location: Åsnorrbodarna
Posts: 11,777
Try this:
Code:
#test a {
  display: block;
  width: 100%;
}
AutisticCuckoo is offline   Reply With Quote
Old Mar 19, 2006, 10:02   #3
jace41
SitePoint Zealot
 
Join Date: Mar 2005
Posts: 113
Thanks! It works. I tweaked the width 100% to 98% due to the padding to prevent the display from being expand 2px outward, just curious is there better approach when deal with padding and 100% width situation?

HTML Code:
#test a {
display: block;
padding: 2px;
width: 98%;}
jace
jace41 is offline   Reply With Quote
Old Mar 19, 2006, 13:03   #4
Paul O'B
CSS Advisor
silver trophybronze trophy
SitePoint Award Recipient
 
Paul O'B's Avatar
 
Join Date: Jan 2003
Location: Hampshire UK
Posts: 27,436
Hi,

You can use the height:1% hack to force the whole area to be active.
Code:
/* mac hide \*/
* html #test a {height:1%}
/* end hide */
Then you don't need to worry about the width at all.

You should never really mix percentage and pixels as they will never add up to exactly what you want.
Paul O'B is offline   Reply With Quote
Old Mar 20, 2006, 00:04   #5
AutisticCuckoo
SitePoint Wizard
silver trophybronze trophy
 
Join Date: Nov 2004
Location: Åsnorrbodarna
Posts: 11,777
Quote:
Originally Posted by jace41
is there better approach when deal with padding and 100% width situation?
You will have to use additional markup for that. For instance,
HTML Code:
<a href="#"><span>Link text</span></a>
Code:
a {
  display:block;
  width:100%;
}

a span {
  padding:0 2px;
}
Using Paul's solution is probably better, though.
AutisticCuckoo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
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
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 21:47.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved