• 0

Best way to create rounded corners on input box?


Question

Hi All,

I'm doing some coding and the design calls for some rounded input boxes and submit buttons with varying lengths. I am sort of in a bit of a 'pickle' at the moment as to deciding which is the best way to go about this. I was thinking of one of these two options:

1) Using NiceForms (which I personally reckon seems like overkill for simply rounded input and submit form fields)

2) Using the following code:

<div class="inputleft"></div>
<input type="text" size="20" name="text" />
<div class="inputright"></div>

Then styling the divs accordingly.

All feedback is appreciated.

Thanks,

Smctainsh

19 answers to this question

Recommended Posts

  • 0

Hmm... if they're (or you're?) that insistent on the rounded input boxes then try curvycorners, it's extremely light-weight and should work on any element, but it does need javascript enabled... the divs method wouldn't require any scripting but would have quite obfusticated markup. Personally, I'd go for the second as I really don't care if people viewing the source of my website aren't aesthetically pleased by the mounds of plaintext. :p

  • 0

You could actually get by with something like this:

<div class="inputLeft"><input type="text" blah blah ></div>

Then in the CSS - you'd have a background image of the DIV to the left, and then have the input box with a background image floating to the right. It would be very similar to the the "sliding door" effect used in tabs. Granted, its only 1 less div, but I think it makes for a bit better markup.

  • 0
Good idea, jukeboxhero52... didn't think of that one.

Oh for CSS3...

input.text {
	border:2px solid #333333;
	border-radius:10px;
}

Can't wait until that stuff becomes usable.

Looks amazing, I can't wait (I'm using NiftyCorners for my site right now), when will it become a standard?
  • 0
Good idea, jukeboxhero52... didn't think of that one.

Oh for CSS3...

input.text {
	border:2px solid #333333;
	border-radius:10px;
}

Can't wait until that stuff becomes usable.

It'll be great once that is implemented and available. :)

Thanks for the assistance everyone. I've decided to use a CSS method as opposed to a javascript method, and I think I'll implement something similar to what jukeboxhero52 suggested.

Thanks again for all of your help everyone. :)

Smctainsh

  • 0
Looks amazing, I can't wait (I'm using NiftyCorners for my site right now), when will it become a standard?

Well different portions of CSS3 are currently supported by gecko, safari and opera and both gecko and opera should have close to full support by the next full version number... but considering even IE7 doesn't have complete compliance to CSS1 yet and only supports a bit of CSS2, it'll probably IE10 before it becomes viable for practical sites... either that or a real big boom in firefox takeup. ;)

If you want to play with the rounded corners, -moz-border-radius works in firefox 2 / latest seamonkey.

  • 0

I'll go down in levels of compatibility (first = highest)

  1. GIF images
  2. PNG images
  3. border-radius

GIF images will work in probably anything

PNG images will work in IE6 and such (with mods), and Opera, Safari, IE7, etc. and such

border-radius will work in latest versions of Firefox, Safari (well, WebKit) and Konqueror (no idea about opera)

Now, border-radius is part of the CSS3 Backgrounds and Borders Module, and due to how CSS3 is being made, individual modules can reach implementation state before others (i think one module is already at that stage), but because this certain module is still draft stage, and can change, the implementations in engines have a testing prefix (e.g. -moz-border-radius,-webkit-border-radius), and some implementations still have bugs or render oddly (e.g. Gecko's)

Now, wasn't that a nice bit of useless facts :p

Edit: not -gecko-border-radius, it's -moz-border-radius >.<

  • 0

http://doyouwanttodie.com/files/web_stuff/...d%20corners.png

As you can see, rounded corners look great in the latest WebKit build (and that not all of them render, haven't checked why)

Edited by The_Decryptor
  • 0
http://doyouwanttodie.com/files/Pictures/r...d%20corners.png

As you can see, rounded corners look great in the latest WebKit build (and that not all of them render, haven't checked why)

Wow, look good... yay for mac antialiasing :p none of them should be rendering at all though, I didn't put any webkit or general properties in, only -moz O_o

I'll put in -webkit ones now.

  • 0

I put in the -webkit- bits

Oh, and from reading the css spec, border-radius only takes one value (which makes sense with WebKit's rendering, it's only taking the first value, which is either 0px or 10px), for individual corners there are other values.

IMO, that's wrong, border-radius should be able to combine all the values, but there is a reason the spec and implementation's are still draft stages ;)

  • 0
I put in the -webkit- bits

Oh, and from reading the css spec, border-radius only takes one value (which makes sense with WebKit's rendering, it's only taking the first value, which is either 0px or 10px), for individual corners there are other values.

IMO, that's wrong, border-radius should be able to combine all the values, but there is a reason the spec and implementation's are still draft stages ;)

Name: border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius, border-top-left-radius, border-radius

Value: <length> <length>?

Seems to me it takes 2... I dunno. That'd be the reason most of it isn't working in safari though - safari's spewing at the multiple specifications and not rendering them at all.

  • 0

the Name: bit is the different properties (the section is entitled "The 'border-radius' properties"), i have no idea why the two "<length> <length>?" values though.

And i got it working in Safari, it only takes 1 value for border-radius, and needs to have individual corners specified as the CSS rules (which are different to the gecko rules, gecko has the wrong rules though)

http://doyouwanttodie.com/files/web_stuff/CSS3/4.html < renders the same in Safari and Firefox.

http://doyouwanttodie.com/files/web_stuff/...corners%202.png < in latest WebKit

Edit: i just noticed a bug in the rendering, look at the navigation "tab", the antialiasing is "off"

Edited by The_Decryptor
  • 0

Yep, that's it, border-radius:10px 20px; gives a funny corner.

http://doyouwanttodie.com/files/web_stuff/...corners%203.png

Ok, messing around with some CSS3 rules, and i have to say, it rocks

testing RGBA colours in Safari (Firefox 2 screws this up): http://doyouwanttodie.com/files/web_stuff/...ari%20rocks.png

Without RGBA: http://doyouwanttodie.com/files/web_stuff/...ss3%20rocks.png

Test page: http://doyouwanttodie.com/files/web_stuff/...0test/css3.html

Test page 2 (with RGBA): http://doyouwanttodie.com/files/web_stuff/...ss3-safari.html

Edited by The_Decryptor
  • 0

I have Tahoma installed (comes with office for mac and some other things i think), and OS X's great font rendering does have something to do with it.

In the CSS3 page i did, that's using Lucida Grande (as you would see if you checked page source)

  • 0

Ahh, i get what you mean, yeah, that's the default serif font ( it's Times at 16px and italic, Safari doesn't give me much info on what it uses, it only shows me the default and fixed width font choices).

and while opacity is ok, it's simplistic, it controls the blending of the whole element (and sub elements), whereas RGBA colours can be applied to anything that takes a colour (font, border, etc.).

I'm still waiting on more support for SVG and SMIL animation though, a mix of those items with HTML would make for some great sites (e.g. shrink this element, rotate this one, scale and skew that one, etc.)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Rockstar gives last-gen GTA V players free upgrades tomorrow by Pulasthi Ariyasinghe Rockstar is preparing to launch Grand Theft Auto VI later this year, but ahead of that, the company has revealed a new offer for some Grand Theft Auto V owners. It today announced that Xbox One and PlayStation 4 version owners of the 2013-released title will soon be receiving a free upgrade to the current generation version. The studio released the Xbox Series X|S and PlayStation 5 version of Grand Theft Auto V back in 2022, bringing significant upgrades to the original console editions. This included 60 FPS gameplay at up to 4K resolution, as well as major upgrades to textures, draw distance, and audio. Faster load times, ray tracing elements, and HDR support were also added with it. While this new and enhanced version needed a new purchase of the game to jump in, now Rockstar has decided to make it a free upgrade, dropping the $40 price tag entirely on consoles. "Beginning tomorrow, those who own any PS4 version or the digital Xbox One version of Grand Theft Auto V will be able to upgrade to the PS5 or Xbox Series X|S versions at no additional cost, and experience the best versions of GTA V and GTA Online," said the company in an official blog post. The free upgrade offer will be released tomorrow, June 18, for all Xbox One and PlayStation 4 owners of Grand Theft Auto V. Players who will be jumping in on the offer will want to check how to migrate their GTA Online profile from last-generation to current-generation consoles by heading over here. The offer lands ahead of The Kortz Center Heist hitting Grand Theft Auto Online, where players and crews will be tasked with stealing priceless international art from a prestigious gallery in Pacific Bluffs. It doesn't look like Rockstar plans to stop updating its previous game even with Grand Theft Auto VI being on the horizon. The latest title is slated to launch on November 19, 2026, across Xbox Series X|S and PlayStation 5.
    • Now comes with a money back guarantee instead of a replacement! Hah
    • Rufus 4.15.2391 Beta by Razvan Serea Rufus is a small utility that helps format and create bootable USB flash drives, such as USB keys/pendrives, memory sticks, etc. Despite its small size, Rufus provides everything you need! Oh, and Rufus is fast. For instance it's about twice as fast as UNetbootin, Universal USB Installer or Windows 7 USB download tool, on the creation of a Windows 7 USB installation drive from an ISO (with honorable mention to WiNToBootic for managing to keep up). It is also marginally faster on the creation of Linux bootable USBs from ISOs. A non-exhaustive list of Rufus supported ISOs is available here. It can be especially useful for cases where: you need to create USB installation media from bootable ISOs (Windows, Linux, UEFI, etc.) you need to work on a system that doesn't have an OS installed you need to flash a BIOS or other firmware from DOS you want to run a low-level utility Rufus 4.15.2391 Beta changelog: Improve the guards for using the "silent" option Improve the ability to cancel during write retries Fix unrestricted XML entity expansion and integer overflow in ezxml parser (courtesy of @esadowski4) [GHSA-55r2-34wg-8mv9] Fix "silent" Windows installation failing at 75% in most cases [#2960] Fix a crash during boot when using UEFI:NTFS on Snapdragon X based ARM64 platforms [#2934] Fix the first WUE option always being checked by default [#2965] Fix an infinite loop when using Windows ISOs that contain multiple WIMs Fix "Enable runtime UEFI media validation" checkbox not always being properly enabled Other WUE improvements/fixes for OneDrive removal and username validation (with thanks to @christian8641) [#2984, #2991] Download: Rufus 4.15 Beta | 1.9 MB (Open Source) Links: Rufus Home Page | Project Page @GitHub | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Media Player Classic - Home Cinema 2.7.3 by Razvan Serea Media Player Classic - Home Cinema (MPC-HC) is a free and open-source video and audio player for Windows. MPC-HC is based on the original Guliverkli project (which is no longer maintained) and contains many additional features and bug fixes. As the continuation of the original Media Player Classic, MPC-HC isn’t flashy but it works with nearly any media format. MPC-HC uses DXVA technology to pass decoding operations to your modern video card, enhancing your viewing experience. And MPC-HC supports both physical and software DVDs with menus, chapter navigation, and subtitles. Overview of features A lot of people seem to be unaware of some of the awesome features that have been added to MPC-HC in the past years. Here is a list of useful options and features that everyone should know about: Dark interface Menu > View > Dark Theme When using dark theme it is also possible to change the height of the seekbar and size of the toolbar buttons. Options > Advanced Video preview on the seekbar Options > Tweaks > Show preview on seek bar Adjust playback speed Menu > Play > Playback rate The buttons in the player that control playback rate take a 2x step by default. This can be customized to smaller values (like 10%): Options > Playback > Speed step Adjusting playback speed works best with the internal audio renderer. This also has automatic pitch correction. Options > Playback > Output > Audio Renderer MPC-HC can remember playback position, so you can resume from that point later Options > Player > History You can quickly seek through a video with Ctrl + Mouse Scrollwheel. You can jump to next/previous file in a folder by pressing PageUp/PageDown. You can perform automatic actions at end of file. For example to go to next file or close player. Options > Playback > After Playback (permanent setting) Menu > Play > After Playback (for current file only) A-B repeat - You can loop a segment of a video. Press [ and ] to set start and stop markers. You can rotate/flip/mirror/stretch/zoom the video Menu > View > Pan&Scan This is also easily done with hotkeys (see below). There are lots of keyboard hotkeys and mouse actions to control the player. They can be customized as well. Options > Player > Keys Tip: there is a search box above the table. You can stream videos directly from Youtube and many other video websites You can stream videos directly from Youtube and many other video websites Put yt-dlp.exe or youtube-dl.exe in the MPC-HC installation folder. Then you can open website URLs in the player: Menu > File > Open File/URL You can even download those videos: Menu > File > Save a copy Tip: to be able to download in best quality with yt-dlp/youtube-dl, it is recommended to also put ffmpeg.exe in the MPC-HC folder. Several YDL configuration options are found here: Options > Advanced This includes an option to specify the location of the .exe in case you don't want to put it in MPC-HC folder. Play HDR video This requires using madVR or MPC Video Renderer. After installation these renderers can be selected here: Options > Playback > Output Ability to search for and download subtitles, either automatically or manually (press D): Options > Subtitles > Misc Besides all these (new) features, there have also been many bugfixes and internal improvements in the player in the past years that give better performance and stability. It also has updated internal codecs. Support was added for CUE sheets, WebVTT subtitles, etc. Media Player Classic - Home Cinema 2.7.3 changelog: Updated LAV Filters to version 0.82 Updated MPC Video Renderer to version 0.10.4.2550 Updated MPC Audio Renderer A few crash fixes, bug fixes and small improvements. Download: MPC-HC 2.7.3 (x64) | Standalone | ~20.0 MB (Open Source) Download: MPC-HC 2.7.3 (x86) | Standalone Links: MPC-HC Home Page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • One Month Later
      Vincian earned a badge
      One Month Later
    • First Post
      Jocimo earned a badge
      First Post
    • Week One Done
      suprememobiles48 earned a badge
      Week One Done
    • One Month Later
      Windows Guy earned a badge
      One Month Later
    • One Month Later
      Prasann earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      510
    2. 2
      +Edouard
      172
    3. 3
      PsYcHoKiLLa
      89
    4. 4
      Steven P.
      76
    5. 5
      neufuse
      69
  • Tell a friend

    Love Neowin? Tell a friend!