Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
Like Tree2Likes
  • 2 Post By Ronald Roe

Thread: In need of creating a simple toggle/switch slide button from image reference

  1. #1
    Junior Member
    Join Date
    Mar 2016
    Posts
    2
    Member #
    53589

    In need of creating a simple toggle/switch slide button from image reference

    Hello,

    I wish to create a toggle/switch button function suited for the image attached.

    toggle.jpg

    The button is essentially choosing between two states/selections/radio buttons, either public or private / yes and no.
    The white box on the left is opaque(the only moving box that can go left or right), hiding the 'private' selection underneath (state off), while the 'public' selection is displayed (on, selected)
    The background with the text is static, while the box can toggle left/right

    I have seen bootstraps version and other similar buttons, but they dont work in the manner that I would like.

    I tried various ways of doing this myself, but being more of a designer, I failed miserably.
    I made this design, and I wish for it to work successfully. I preferably would like this to be strictly HTML and CSS, without having to be jQuery enabled.

    I would need some helpful coders to help me a.s.a.p, and will be greatly appreciated

    Thank you!

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Here's a good article from CSS-Tricks on a checkbox "hack", which is like what you're doing: https://css-tricks.com/the-checkbox-hack/

    Here's a code snippet that implements it: https://css-tricks.com/snippets/css/...radio-buttons/
    satindertech and TheGAME1264 like this.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #3
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    Ron nailed it. The checkbox hack is the greatest innovation in CSS in about the last 5 years. I'm not exaggerating...I use it in a ton of places, including a new image gallery technique I'm working on for a pair of sites under construction that I should be launching in the next few weeks. I love me some checkbox hackin'!

    In your case, you'd probably do a single background for your public/private (or yes/no) and adjust the background position using CSS depending on whether the box is checked or not.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:26 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com