This is a discussion on Button Class within the HTML & CSS Help forums, part of the Web Design category; At the moment I'm using images for my image buttons, but I thought I might try and achieve a similar ...
| |||||||
|
#1
| ||||
| ||||
| At the moment I'm using images for my image buttons, but I thought I might try and achieve a similar effect by using a class on a button. What I'm aiming for is something like the attached image. This is the CSS I have so far, but there is a gap between the background image (which is just the green box with the white > arrow in it, positioned to the right) and the border. Code: .button_green {
height:21px;
border:solid1px#325CAB;
border-collapse:collapse;
padding:0px18px0px0px;
margin:0px0px0px0px;
background-color:#FFFFFF;
background-image:url('/images/button_border_green.gif');
background-position:right;
background-repeat:no-repeat;
font-family: "Arial","Verdana";
font-size:10pt; color: #000066;
text-decoration:none;
font-weight:bold;
} <edit>Actually it seems to be working pretty well in FF. Just not in IE.</edit>
__________________ Join the folding team |
|
#2
| ||||
| ||||
| Try setting the padding to 0
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.If you like it here...throw us a few bones to help support us. Join our Folding team: DeveloperBarn Folding |
|
#3
| ||||
| ||||
| The reason for the padding was to make sure the button text doesn't write over the top of the background image. However, if I set the padding to 0px, there is still a gap between the bg image and the border.... |
|
#5
| ||||
| ||||
| A suggestion... Since you're doing .Net, use a LinkButton instead of a Button and then style like demonstrated here: CSS Buttons [Sophie’s maze] |
|
#6
| ||||
| ||||
| Have used the same CSS on a linkbutton and that seemed to work pretty well... Was kind of hoping to get the text movement when the button is clicked in IE, but as you don't seem to get that in FF, I'm not too bothered. Any ideas on maybe adding the drop shadow, like the original image I posted? At least it should save me having to create a new button image for each button type I want. |
|
#7
| ||||
| ||||
| Try something like this: A List Apart: Articles: CSS Drop Shadows |
|
#8
| ||||
| ||||
| OK. After a bit of fiddling, that seems to work reasonably well...Spot on in IE and only a tiny bit out in FF with the shadow on the right. This is what I ended up with Code: <span class="drop_shadow" style="float:right"> <span> <asp:linkbutton /> </span> </span> Code: .drop_shadow { float:left;
background: url('/images/drop_shadowAlpha.png') no-repeat bottom right !important;
background: url('/images/drop_shadow.gif') no-repeat bottom right;
margin: 10px 0 0 10px !important;
margin: 10px 0 0 5px; }
.drop_shadow span { display: block;
position: relative;
margin: -5px 5px 5px -5px;
padding: 2px 0px 0px 1px;
} Last edited by richyrich; February 26th, 2009 at 11:33 AM. |
|
#9
| ||||
| ||||
| OK. Have come up with a problem with the height of the button. The background image I'm using is 22px high. I have to set the height of the linkbutton. If I change the height in the CSS it has no effect. However, when I set the height to 20px, the text is not vertical aligning to the middle. I've tried adding vertical-align:middle; to the CSS and as a style on the linkbutton but it just stays at the top. If I remove the height attribute of the linkbutton, it defaults to an auto height and the text sits in the middle, but I want to make the button higher. I can't add padding to the CSS because that puts a gap between the background and the border. Any ideas? Last edited by richyrich; February 26th, 2009 at 02:09 PM. |
![]() |
|
| Bookmarks |
| Tags |
| button, class, css |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| class name is ambiguous | richyrich | .Net Development | 11 | August 12th, 2008 11:11 AM |
| Generic Paging Class | Shem | .Net Development | 4 | July 18th, 2008 11:29 AM |
| FTP Class Library? | Wolffy | .Net Development | 6 | May 30th, 2008 10:26 AM |
| Class library | Shem | .Net Development | 11 | May 22nd, 2008 07:01 AM |
| delete button | techker | Microsoft Access | 14 | May 21st, 2008 08:56 AM |