webdevRefinery Forum: Have two lines of text in input button? - webdevRefinery Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Rate Topic: -----

User is online Sole_Wolf 

  • Group: Members
  • Posts: 302
  • Joined: 24-March 10
  • Expertise:HTML,PHP,Java,SQL

Posted 15 April 2012 - 03:31 PM (#1)

Have two lines of text in input button?


This is probably something very easy that I am missing, but how do you add a return in an input box?

\n doesn't work and <br> definitely doesn't work.

http://jsfiddle.net/JmJ5e/1/

Thanks.
--Sole_Wolf
0


User is offline alexdavey 

  • Bringing XKCD to a post near you
  • Group: Members
  • Posts: 848
  • Joined: 05-November 10
  • LocationLondon
  • Expertise:HTML,CSS,PHP,Javascript

Posted 15 April 2012 - 03:33 PM (#2)

Why would you want to do this? If you need to make the button bigger, you can use CSS (width, height properties) ;)
NVM... I thought of a situation :P But you could always a div as a button and style it using CSS...
0


User is offline TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5154
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 15 April 2012 - 03:37 PM (#3)

View PostSole_Wolf, on 15 April 2012 - 03:31 PM, said:

This is probably something very easy that I am missing, but how do you add a return in an input box?

\n doesn't work and <br> definitely doesn't work.

http://jsfiddle.net/JmJ5e/1/

Thanks.

Why does it need to be an input? Why not make it an
a
? What a lot of applications are doing now, primarly because of UJS.
Reserved.
0


User is online Lemon 

  • I have a dream...
  • Group: Members
  • Posts: 686
  • Joined: 24-February 11
  • Expertise:HTML,CSS,PHP,Javascript,Node.js,SQL

Posted 15 April 2012 - 03:49 PM (#4)

Theoretically like this: http://jsfiddle.net/JmJ5e/2/

But in reality, don't do this. The buttons shown in most browsers are based on the UI elements of the host OS rather than a common standard and as a result what the users see and how much configurability they have varies massively. For example, in Safari I can only see the tips of the letters on the second line and the height of the button is not adjustable, so if you implement this any use on Safari will not be able to ever see the second line.

As noted above, buttons not the tool for this task. If you need it for a form, use a div or something similar and attach a listener to the click to submit the form.
Posted Image
In the end, it's not the years in your life that count. It's the life in your years
0


User is offline Quinn 

  • More pew-pew, less QQ
  • Group: Members
  • Posts: 1307
  • Joined: 08-March 10
  • LocationPalmyra, PA, USA
  • Expertise:HTML,PHP,Javascript

Posted 15 April 2012 - 04:56 PM (#5)

<button></button>
anyone?
http://jsfiddle.net/JmJ5e/3/
<Imp> [F3ar 40]  [PWNbear 17]  [magik 15]  [dissident 10]  [mark 7]

View PostKyek, on 07 February 2011 - 07:11 AM, said:

Though anyone who thinks Europe is a country should be smacked in the face. By a train.
0


User is offline Cocoa 

  • Group: Members
  • Posts: 418
  • Joined: 30-November 10
  • LocationEngland

Posted 16 April 2012 - 03:17 PM (#6)

View PostLemon, on 15 April 2012 - 03:49 PM, said:

[...]

But in reality, don't do this. The buttons shown in most browsers are based on the UI elements of the host OS rather than a common standard and as a result what the users see and how much configurability they have varies massively.

[...]


This.

It's better to use an 'a' element because with browsers like IE6 which for some reason is still in use, it can cause major problems and it's also easier to style an 'a' element rather than an input button or the HTML5 button tag.
Dan || HTML || CSS || Web & Graphic Designer

Oh, there's no place like 127.0.0.1


Portfolio | Forrst (6 Invites) | Dribbble

MY FIRST TUTORIAL - HOW TO CREATE THE IRON MAN LOGO
0


User is online Daniel15 

  • dan.cx
  • Group: Moderators
  • Posts: 3415
  • Joined: 17-April 10
  • LocationMelbourne, Australia
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 16 April 2012 - 05:52 PM (#7)

The
<button>
element is the correct way to do this with actual buttons. <button>s can contain content like images, which makes them more awesome. You do need to make sure you style them correctly (if using custom styles for them), see http://particletree....button-element/ for some good examples.

If you want IE 6 and 7 support, there's a well-known issue in these browsers where it posts the text of the button instead of the button's value attribute. And in IE 6, when you click a submit button, it posts the values of ALL buttons on the page, not just the clicked one (so you can't know which button the user clicked). There are fixes available, one of which I've created: https://github.com/D...5/IE-button-fix
Daniel15! :D
Posted Image

Repeat after me: jQuery is not JavaScript. It is not the answer to every JavaScript-related question. When you have to write some JavaScript, do not instantly react with "Oh, I'll do that with jQuery!"

Spoiler
0


User is offline TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5154
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 16 April 2012 - 05:53 PM (#8)

View PostDaniel15, on 16 April 2012 - 05:52 PM, said:

The
<button>
element is the correct way to do this with actual buttons. <button>s can contain content like images, which makes them more awesome. You do need to make sure you style them correctly (if using custom styles for them), see http://particletree....button-element/ for some good examples.

In Chrome, the JSFiddle of the button with a break line only shows the first line.
Reserved.
0


User is offline Quinn 

  • More pew-pew, less QQ
  • Group: Members
  • Posts: 1307
  • Joined: 08-March 10
  • LocationPalmyra, PA, USA
  • Expertise:HTML,PHP,Javascript

Posted 16 April 2012 - 06:33 PM (#9)

View PostThatRailsGuy, on 16 April 2012 - 05:53 PM, said:

In Chrome, the JSFiddle of the button with a break line only shows the first line.

What version of Chrome are you using?
Posted Image
<Imp> [F3ar 40]  [PWNbear 17]  [magik 15]  [dissident 10]  [mark 7]

View PostKyek, on 07 February 2011 - 07:11 AM, said:

Though anyone who thinks Europe is a country should be smacked in the face. By a train.
0


User is offline TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5154
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 16 April 2012 - 06:54 PM (#10)

Mac, stable

Posted Image
Reserved.
0


User is offline Quinn 

  • More pew-pew, less QQ
  • Group: Members
  • Posts: 1307
  • Joined: 08-March 10
  • LocationPalmyra, PA, USA
  • Expertise:HTML,PHP,Javascript

Posted 16 April 2012 - 07:31 PM (#11)

View PostThatRailsGuy, on 16 April 2012 - 06:54 PM, said:

Mac, stable

[img]http://i.imgur.com/P2NYw.png[/img]


Try opening it in an incognito window.
<Imp> [F3ar 40]  [PWNbear 17]  [magik 15]  [dissident 10]  [mark 7]

View PostKyek, on 07 February 2011 - 07:11 AM, said:

Though anyone who thinks Europe is a country should be smacked in the face. By a train.
0


User is offline arronhunt 

  • I'm a httpster
  • Group: Moderators
  • Posts: 3398
  • Joined: 09-March 10
  • LocationLos Angeles, CA
  • Expertise:HTML,CSS,Javascript,Graphics,Flash

Posted 17 April 2012 - 12:53 AM (#12)

Doesn't work on mobile safari either
DO NOT OPEN THIS

Spoiler
0


User is offline _Sam 

  • Beep Beep
  • Group: Members
  • Posts: 633
  • Joined: 11-March 10
  • LocationZurich, Switzerland
  • Expertise:HTML,CSS

Posted 17 April 2012 - 04:34 AM (#13)

There is a very easy way, just open up Illustrator, Photoshop or some other drawing tool. Draw the button add some text and save it as png/jpg whatever. Now every browser will be able to display your button correctly.
(ಠ_ಠ)
0


User is offline callumacrae 

  • {{ post.author }}
  • Group: Members
  • Posts: 2862
  • Joined: 20-January 11
  • LocationWarwickshire, England
  • Expertise:HTML,CSS,PHP,Javascript,Node.js,SQL

Posted 17 April 2012 - 05:59 AM (#14)

View Post_Sam, on 17 April 2012 - 04:34 AM, said:

There is a very easy way, just open up Illustrator, Photoshop or some other drawing tool. Draw the button add some text and save it as png/jpg whatever. Now every browser will be able to display your button correctly.

-1, use CSS!!!
Front-end developer and writer
Twitter | GitHub | phpBB Contributor and Website Team Member | lynxphp
0


User is offline _Sam 

  • Beep Beep
  • Group: Members
  • Posts: 633
  • Joined: 11-March 10
  • LocationZurich, Switzerland
  • Expertise:HTML,CSS

Posted 17 April 2012 - 07:07 AM (#15)

Yeah the animation maybe, but I want to see how you design a button in CSS with text on multiple lines that looks the same in every browser.
(ಠ_ಠ)
0


User is offline callumacrae 

  • {{ post.author }}
  • Group: Members
  • Posts: 2862
  • Joined: 20-January 11
  • LocationWarwickshire, England
  • Expertise:HTML,CSS,PHP,Javascript,Node.js,SQL

Posted 17 April 2012 - 07:21 AM (#16)

View Post_Sam, on 17 April 2012 - 07:07 AM, said:

Yeah the animation maybe, but I want to see how you design a button in CSS with text on multiple lines that looks the same in every browser.

...
<style>
.button {
    border: 1px black solid;
    color: black;
    background-color: white;
    font-size: 16pt;
}
</style>
...
<div class="button">Clicky<br>Clicky</div>
<script>
$('.button').click(function () {
    $(this).parent('form').submit();
});
</script>
...


Using jQuery because untested.
Front-end developer and writer
Twitter | GitHub | phpBB Contributor and Website Team Member | lynxphp
0


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services