![]() |
Button
1 Attachment(s)
I wanna code a button, such as in the attached image.
But I can't get it to work :S So yea, I'm hoping you can fix it :-) They have rounded corners, just incase you didn't see. The ends, I've cut out, so they are 2px wide, and 28px high, each. The actual gradient of the button, is 1px wide, and 28px high. I want the button to expand in <-> ways, if I write more stuff in the button. HTML Code:
<div class="button">Code:
.button-background {And also, I'm assuming that this ain't expanding if I write more text.. :S |
Uh... that's too many DIV elements for just a button. *!* The problem is that the more there are the more trouble browsers have because they compute/render differently. So, the work around to "too many divs" is to make the start/stop of the button to span elements. Like so:
HTML Code:
<div class="myButton">css Code:
I noticed the 2px border, so my suggestion is that you cut the leading and trailing two pixels of the border into -start/-stop images. Then the middle of that can be the repeating -center gradient. It'll be cleaner and easier to understand too. ;-) |
Hey! That worked, almost like I wanted xD
Current codes are index.html HTML Code:
<div class="myButton">Code:
.myButton {First, I can't get the text where I want. Right now the text is too far up. I know it can be solved with padding, but WHERE would I put that? I tried to put it in the content span.. but it doesn't work. I tried to put it in the button class css, but that makes the images (the ends) to get padding too, which I don't want. So that's 1 issue. The 2nd issue, is that the box isn't expanding. If I don't set any fixed width, the button gets over the whole screen. If I set a width, it's that width all the time.. so how would I make it expanding depending on how much content inside? Thanks for your help so far! :-D |
Try:
CSS Code:
The other way is to give it a padding-top value. |
Set the
line-height to be the same value as your height, that should help with the off-vertical-center text. |
vertical-align didn't work :-(
But line-height did! :-D Thanks ^^ Now it's just the issue with the expanding thing... :-( |
Remove the width, and set the
min-width to something like 32px. Don't forget right/left padding. |
1 Attachment(s)
Didn't work :-/:-/
|
Oh yeah, I forgot divs like to take 100% the width. Try changing it to a paragraph element. You might have to reset padding/margins to get it to work perfectly.
|
HTML Code:
<p class="myButton">It didn't work either :-/:-/:-/:-/ |
Took a minute to figure out, I had to stop and test rather than guess, but switch it back to a div (last time) and set this:
css Code:
|
Paragraphs and DIVs are both 'block elements' which, if a width is not specified, expand to fit their parent element (ie, the width of the page). You'll need to change the
display property to inline in order to display the buttons inline (makes sense). Either that, or you can float the element. As far as I'm aware, our favourite browser (IE6) doesn't support inline-block. |
Still doesn't work :-S
Code:
.myButton { |
#1 What's wrong now?
#2 What's your doctype? For one thing, the third span in which you put your content is superfluous, so just remove it and its class. |
1. It still expands over the whole page... :-S
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
That'd be the problem. With an XHTML 1.0 Transitional document you won't have that problem.
|
What difference does the doc type actually have?
|
@Gareth
The DOCTYPE tells the browser wich level off error mode to work in when itīs reading the HTML or XHTML code. Because certain versions of XHTML and HTML support different features and such. And if that isīnt enough some JavaScript DOM related scripts donīt work in various DOCTYPE:s. Thats my experience any way, correct me if im wrong. /EyeDentify |
Okey, so exactly should the doctype be, in my case???
(never done anything with doctype before.. the doctype is automaticly generated when I create a new html file with my program..) |
Well, if you're using a visual editor you will have problems. This is why I gave up on Dreamweaver back in the MX days, it forced me to do things in ways I knew weren't the best.
Try searching for the option to change the project/file from HTML 4 into XHTML 1.0/1.1 Transitional. Otherwise, you'll just have to learn to do it by hand. |
| All times are GMT. The time now is 07:21 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0