Style Input fields with CSS - (4 examples)

แชร์
ฝัง

ความคิดเห็น • 159

  • @BeforeSemicolon
    @BeforeSemicolon  ปีที่แล้ว +1

    Which of these 4 examples you like the most?
    Any other style you go for in your personal projects?

  • @anadoovershima2088
    @anadoovershima2088 4 ปีที่แล้ว +4

    Hey
    I know you might not see this, as this video is a bit old, but I stumbled on this and I am so grateful that you do this. I encourage you to continue. Blessings.!!

    • @BeforeSemicolon
      @BeforeSemicolon  4 ปีที่แล้ว +1

      Thank you Anadoo. I apreciate the gesture of taking time to provide feedback so I always take time to acknowledge the comment. Lets stay connected :)

  • @jiharedconteh4530
    @jiharedconteh4530 3 ปีที่แล้ว +1

    I have to admit, this is the best coding channel on TH-cam. The truth is, I just subscribed.
    Keep up the good work. Looking forward to learning more from you.

    • @BeforeSemicolon
      @BeforeSemicolon  3 ปีที่แล้ว

      Thank you and welcome to BFS 😊 stay tuned

  • @davicarvalhodesouza7260
    @davicarvalhodesouza7260 3 ปีที่แล้ว +3

    After you showed how to make the placeholder vanish, oh, I think I spent 10 minutes just looking at my placeholder vanish and reappear, it's so smooth

  • @David-iq1kd
    @David-iq1kd 4 หลายเดือนก่อน +1

    This is incredible, and CSS only on top. I've tried to recreate all of these and struggled in the past.

  • @roaringpain3250
    @roaringpain3250 3 ปีที่แล้ว +17

    I think it's a fucking crime that you don't have waaaaay more subscribers! Thanks a lot for this and for everything that you do :).

    • @BeforeSemicolon
      @BeforeSemicolon  3 ปีที่แล้ว +2

      I agree :) thank yo so much for this comment

    • @leaker8643
      @leaker8643 3 ปีที่แล้ว +2

      @@BeforeSemicolon same feeling here!

    • @nikolaisawyer2392
      @nikolaisawyer2392 3 ปีที่แล้ว

      I dont mean to be so off topic but does anyone know of a method to log back into an Instagram account?
      I somehow forgot my login password. I would appreciate any assistance you can give me

    • @zevkarter9600
      @zevkarter9600 3 ปีที่แล้ว +1

      @Nikolai Sawyer Instablaster ;)

  • @joshDotJS
    @joshDotJS 4 ปีที่แล้ว +8

    Amazing tutorial! Covers everything you need to know about styling text input fields. It is easy to take the concepts you presented here and expand upon them in custom ways for my own needs. Thank you sir. Liked and subscribed.

    • @BeforeSemicolon
      @BeforeSemicolon  4 ปีที่แล้ว

      Thank you and I appreciate the feedback. Welcome to Before Semicolon :)

  • @purplexion2
    @purplexion2 2 ปีที่แล้ว +1

    Izi videwo ziratanga amakuru cyane kandi ndabakunda! Nyamuneka kora amashusho menshi nkaya!

  • @arioum-amogh
    @arioum-amogh 2 ปีที่แล้ว +1

    I would've called by self an intermediate CSS dev, but now after watching this, imma call myself a beginner.

  • @delphaze
    @delphaze 2 ปีที่แล้ว

    I know this voice!!!! How I’m I just finding about this channel now? So proud of you E… 🎉🎉🎉

    • @BeforeSemicolon
      @BeforeSemicolon  2 ปีที่แล้ว

      Hehe thanks … its my little secret (i guess). Thank you 😊

  • @IAmBael
    @IAmBael 2 ปีที่แล้ว +3

    Still a great tutorial a year and a half later, thanks a lot!

    • @BeforeSemicolon
      @BeforeSemicolon  2 ปีที่แล้ว

      Thank you. Glad its not getting old 😊

  • @madhav3444
    @madhav3444 ปีที่แล้ว +1

    Loved it. Can we do this in react native input? Is there any way to make a separate module of this styling you showed and use in React native? Thanks

    • @BeforeSemicolon
      @BeforeSemicolon  ปีที่แล้ว

      Absolutely possible. I have done something similar in RN . Dont have a video on RN in this channel. It pretty much comes down to animation and transforming

  • @smartnoobgamer8292
    @smartnoobgamer8292 3 ปีที่แล้ว +1

    Great content, super presentation😊👏👏👏👏. You diserve more subscribers. Keep up the good work dude.

  • @fadilrahadiansyah4223
    @fadilrahadiansyah4223 3 ปีที่แล้ว +1

    is there any tutorial like this input style, but for select dropdown element and datepicker?

    • @BeforeSemicolon
      @BeforeSemicolon  3 ปีที่แล้ว +1

      yeah sure.
      dropdown: th-cam.com/video/f_E5d9Gt5nM/w-d-xo.html
      selector: th-cam.com/video/-0VuZEYIYuI/w-d-xo.html
      date picker: th-cam.com/video/g1Zd0Y7OJuI/w-d-xo.html
      check the channel for more

  • @floriancucu3801
    @floriancucu3801 4 ปีที่แล้ว +2

    Amazin tutorial. Extremely helpful. Just one question, why are you using transform: translateY(-50%) on the .custom-field .placeholder if you already positioned it on the Y-axis by top: calc(50% + 10px)? Isn't enough just the top positioning with the proper values?

    • @BeforeSemicolon
      @BeforeSemicolon  4 ปีที่แล้ว +1

      thanks :). The top will put the top of the placeholder at the center but we want the vertical center of the placeholder at the center so we shift it up 50%.

  • @purplexionroblox
    @purplexionroblox 2 ปีที่แล้ว +1

    how do you get rid of the grey things on the outside of an input tag right when you make them?

    • @BeforeSemicolon
      @BeforeSemicolon  2 ปีที่แล้ว +1

      You need to be more specific. Whats the time in the video?

    • @purplexionroblox
      @purplexionroblox 2 ปีที่แล้ว

      @@BeforeSemicolon here's a link showing the grey things: th-cam.com/video/QaAAAR3qG40/w-d-xo.html

    • @BeforeSemicolon
      @BeforeSemicolon  2 ปีที่แล้ว +1

      Those are borders. You set “appearance” and “border” to “none”

    • @purplexionroblox
      @purplexionroblox 2 ปีที่แล้ว +2

      @@BeforeSemicolon thank you so much you deserve a sub

    • @BeforeSemicolon
      @BeforeSemicolon  2 ปีที่แล้ว +1

      Thank you. Appreciated. Welcome to BFS 😊

  • @sallus449
    @sallus449 3 ปีที่แล้ว +2

    Excellent mate love this please keep doing these videos

    • @BeforeSemicolon
      @BeforeSemicolon  3 ปีที่แล้ว +1

      Thank you…love your photo by the way

    • @sallus449
      @sallus449 3 ปีที่แล้ว +1

      Haha man of culture i see

  • @ikeem9000
    @ikeem9000 2 ปีที่แล้ว

    Thanks for the explicit demonstration @
    I used span tag to position my custom placeholder absolutely to the input border top according to your tutorial, however, when I clicked email input field and wanted to select one of my email accounts, I realized as I hovered on one of my emails, it automatically suggested my number and address(and filled their respective fields in which the customer placeholder overlapped the suggestion while I have not actually selected the email ). In this case, I couldn't see the suggestion clearly because of the overlapping, how do I go about it?

    • @BeforeSemicolon
      @BeforeSemicolon  2 ปีที่แล้ว

      That is handled by the browser so to disable that add
      autocomplete="off"
      To the input field and any form you place the field inside of.

  • @data_with_michalis
    @data_with_michalis 3 ปีที่แล้ว +1

    Really great work! Keep up the good content mate!

  • @savedbygrace2993
    @savedbygrace2993 ปีที่แล้ว

    Hi! Thank you for this, how about select types? :D
    I'm having hard time to implement it on select types. thanks!

    • @BeforeSemicolon
      @BeforeSemicolon  ปีที่แล้ว

      Hi. What do you mean by “implement it on select types”? What are trying to do?
      I have a video on styling select tags
      th-cam.com/video/-0VuZEYIYuI/w-d-xo.html
      And dropdowns
      th-cam.com/video/f_E5d9Gt5nM/w-d-xo.html

  • @flyingcheburek2320
    @flyingcheburek2320 3 ปีที่แล้ว +1

    How can I put gradient background on the input field?

    • @BeforeSemicolon
      @BeforeSemicolon  3 ปีที่แล้ว

      You can use the same technique i used for buttons on this video th-cam.com/video/adUCbVi4G-s/w-d-xo.html

    • @flyingcheburek2320
      @flyingcheburek2320 3 ปีที่แล้ว +1

      @@BeforeSemicolon thx man, it help a lot!

  • @emersonpessoa05_10
    @emersonpessoa05_10 3 ปีที่แล้ว +2

    Obrigado. Salvou minha vida! = Thanks. Saved my life!

  • @mdbdrrhm
    @mdbdrrhm 2 ปีที่แล้ว +1

    Great job and explanation!!!

  • @ivaylopetrov9956
    @ivaylopetrov9956 3 ปีที่แล้ว +2

    I love it. Soo intense and useful.

  • @tedsemon1326
    @tedsemon1326 2 ปีที่แล้ว +1

    This is a wonderful video - I learned a lot by watching it and unpacking it. One thing I do not understand though is if you wrap the input field inside of a div, the placeholder text gets pushed down several pixels and when you focus on the field, the downsized text no longer is pushed up all the way out of the field. I can fix this by changing the two margin-top settings, but I'm wondering why I have to do this. Does a div come with some sort of default padding or margin? I tried setting those values to zero, but the issue still occurred. I just want to make sure that I'm addressing this issue the correct way. Thank you, sir - and I have Liked and Subscribed to your Channel.

    • @BeforeSemicolon
      @BeforeSemicolon  2 ปีที่แล้ว

      Thank you and welcome to BFS. In order to help you ill need more details of your code. Div is a plain element with no styling so i need to see your code.

    • @tedsemon1326
      @tedsemon1326 2 ปีที่แล้ว +1

      @@BeforeSemicolon That's what I thought about div too. I took the code that you posted on Codepen as a base - I created a default HTML file (Shift! on VSCode), added the HTML code from your Codepen and the CSS code inside a tag and tried that - worked great. I then enclosed custom field two in a div and got the problem.



      Enter URL

      This happens with all four label options - I tested it on both Chrome and Firefox, same thing.
      I also then tried directly modifying the codepen - wrapped option two in a div - and got the same erroneous result (and this was on Edge) - hopefully you should be able to see that too.
      I can post my entire file here if you want but it's about 250 lines, total. Thank you VERY MUCH for responding so quickly.

    • @BeforeSemicolon
      @BeforeSemicolon  2 ปีที่แล้ว

      add “display: inline-block” to .custom-field

    • @tedsemon1326
      @tedsemon1326 2 ปีที่แล้ว

      @@BeforeSemicolon I did that - and it now works. But I've run into another problem. If I add a (for="field") clause to the label (so it reads in Codepen "", then clicking on the placeholder text does nothing, it does not bring the field into focus. Clicking outside the placeholder text allows focus, but not when you click on the placeholder text itself. And I need the for clause, of course, so that I can capture/validate the input (at least that's the only way I know how to do it). Thanks again.

    • @BeforeSemicolon
      @BeforeSemicolon  2 ปีที่แล้ว

      You dont need “for” when putting input inside a label tag. developer.mozilla.org/en-US/docs/Web/HTML/Element/label#attr-for
      Validation is on the input so play with that: developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation

  • @coolwaterdvr
    @coolwaterdvr 4 ปีที่แล้ว +1

    Awesome. Can you help me how to use/convert the css for select?

    • @BeforeSemicolon
      @BeforeSemicolon  4 ปีที่แล้ว +1

      I dont quiet understand your request. More details please?

    • @coolwaterdvr
      @coolwaterdvr 4 ปีที่แล้ว +1

      @@BeforeSemicolon may bad. What I meant was how to convert the css to work with . I tried making a copy of the css and replaced the input to select. Somehow it worked. 🤣 The only thing I cant figure out is the dropdown arrow for the select is now missing.

    • @BeforeSemicolon
      @BeforeSemicolon  4 ปีที่แล้ว +1

      I have a video on that.
      It is called:
      CSS Select Tag Styling - how to style select tag with CSS

    • @coolwaterdvr
      @coolwaterdvr 4 ปีที่แล้ว +1

      @@BeforeSemicolon nice. Thanks! 👍

    • @BeforeSemicolon
      @BeforeSemicolon  4 ปีที่แล้ว +1

      Let me know if that helps

  • @johnlawrencequinones4354
    @johnlawrencequinones4354 3 ปีที่แล้ว

    Hi! Great tutorial! I have one concern though, which is what if I entered an invalid input into an input field? For instance, the required format for a phone number are number inputs, so when entering letters, the placeholder still comes down. Adding invalid makes the placeholder permanently on top of the field input. How do I fix this? helppppp

    • @BeforeSemicolon
      @BeforeSemicolon  3 ปีที่แล้ว

      Try to use the :invalid pseudo-class for the style that moves the label up.
      .custom-field input:invalid + .placeholder {…}
      Check this article where I provide example with error state medium.com/codex/how-to-style-an-input-field-with-css-only-tips-and-techniques-e6a00e9dcc50

  • @shazbaz5695
    @shazbaz5695 4 ปีที่แล้ว +1

    Can you do a few landing pages (mobile-first approach), please?

    • @BeforeSemicolon
      @BeforeSemicolon  4 ปีที่แล้ว +1

      For sure...anything specific you are interested on or anything will do?

    • @shazbaz5695
      @shazbaz5695 4 ปีที่แล้ว +1

      @@BeforeSemicolon something e-commerce related would be great. I want to get a comfortable coding variety of different landing pages. Thanks in advance.

  • @nelsenanggara7298
    @nelsenanggara7298 2 ปีที่แล้ว +1

    thank you very helpful, i like people give code in description

    • @BeforeSemicolon
      @BeforeSemicolon  2 ปีที่แล้ว

      Thanks. Yeah that always happen on this channel 😉

  • @nikhilvishwakarma3275
    @nikhilvishwakarma3275 4 ปีที่แล้ว

    amazing video. But if the field is empty than how to make placeholder and border color red

    • @BeforeSemicolon
      @BeforeSemicolon  4 ปีที่แล้ว +2

      .custom-field.one input:not(:valid) {
      border: 2px solid red;
      }
      I recommend using Javascript for this because this will make the fields initially red.
      Maybe add a class like “.untouched” and on focus u remove the “.untouched” class then ur css would be:
      .custom-field.one input:not(:valid):not(.untouched) {
      border: 2px solid red;
      }

    • @nikhilvishwakarma3275
      @nikhilvishwakarma3275 4 ปีที่แล้ว +1

      @@BeforeSemicolon thank you. You solve my problem 👍

    • @BeforeSemicolon
      @BeforeSemicolon  4 ปีที่แล้ว

      Anytime

  • @afridihasan1124
    @afridihasan1124 3 ปีที่แล้ว +1

    Amazing work man

  • @leuvaprince7955
    @leuvaprince7955 3 ปีที่แล้ว +1

    can anyone tell me how to use this code cuz i never copy pasted one. :)

    • @BeforeSemicolon
      @BeforeSemicolon  3 ปีที่แล้ว

      There is a link in the description. Feel free to copy the code and use it your project

    • @leuvaprince7955
      @leuvaprince7955 3 ปีที่แล้ว

      @@BeforeSemicolon hey i did but it didn't work.... any soln?

    • @leuvaprince7955
      @leuvaprince7955 3 ปีที่แล้ว

      @@BeforeSemicolon and its not working for more than one textbox.

    • @BeforeSemicolon
      @BeforeSemicolon  3 ปีที่แล้ว

      Share how you are using it

  • @francescociulla
    @francescociulla 4 ปีที่แล้ว +1

    Great video!

  • @muhammadaadil3546
    @muhammadaadil3546 4 ปีที่แล้ว +3

    Thank you for the second one

  • @isaacchukwuka5966
    @isaacchukwuka5966 4 ปีที่แล้ว

    Awesome video man, when i Change the type to email, the labels drop down when i enter an input instead of remaining up

    • @BeforeSemicolon
      @BeforeSemicolon  4 ปีที่แล้ว

      If you change the type you must fall to using the .dirty class instead of the :valid state. Check the source code.

    • @isaacchukwuka5966
      @isaacchukwuka5966 4 ปีที่แล้ว

      @@BeforeSemicolon yes, i added javascript and changed the input:value to input.dirty in css
      But The script doesn't seem work at all
      all input losses focus with text in them
      I Don't know what I'm doing wrong

    • @BeforeSemicolon
      @BeforeSemicolon  4 ปีที่แล้ว

      I updated the source code with .dirty option as well and included many input field type as example as well. Check it out for reference.

  • @vijayr.b.1050
    @vijayr.b.1050 3 ปีที่แล้ว +1

    Oh thanks a lot u got a new subscriber

  • @theuncommonfactory5171
    @theuncommonfactory5171 4 ปีที่แล้ว +1

    Very Useful Video man! You Are awesome.. Keep going.. 😃

  • @chirengito
    @chirengito 3 ปีที่แล้ว +1

    nice job 💚 u ar great

  • @sumitttpaul
    @sumitttpaul 2 ปีที่แล้ว

    If I write something in that input field and lost the focus then border animation is not working

    • @BeforeSemicolon
      @BeforeSemicolon  2 ปีที่แล้ว

      More details please

    • @sumitttpaul
      @sumitttpaul 2 ปีที่แล้ว

      @@BeforeSemicolon means in blur state , their is no animation when textfield has some value

    • @BeforeSemicolon
      @BeforeSemicolon  2 ปีที่แล้ว

      Correct. This remains in that state when field gets value. If you dont want that simply remove the selector that targets fields with value

  • @leaker8643
    @leaker8643 3 ปีที่แล้ว +2

    Amazing video! i

  • @code1860
    @code1860 3 ปีที่แล้ว +1

    Amazing. Subscribed.

  • @gonzaotc
    @gonzaotc 3 ปีที่แล้ว

    I completly lost when you done the background linear-gradient then added left bottom/100% outside the (). Cant understand that

    • @BeforeSemicolon
      @BeforeSemicolon  3 ปีที่แล้ว

      Thats CSS background shorthand.
      background: bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment initial|inherit;
      www.w3schools.com/cssref/css3_pr_background.asp

  • @h4ss778
    @h4ss778 4 ปีที่แล้ว +1

    This is amazing

  • @envyza7869
    @envyza7869 3 ปีที่แล้ว +1

    You got one new subs :D

  • @narasimmans5418
    @narasimmans5418 3 ปีที่แล้ว +1

    Thanks Bro🤝

  • @Mai-karunga-business
    @Mai-karunga-business 2 ปีที่แล้ว +1

    Thankyou ❤️❤️❤️

  • @danielvnzla6278
    @danielvnzla6278 4 ปีที่แล้ว +3

    amazing thanks

  • @muhammadehsan7371
    @muhammadehsan7371 4 ปีที่แล้ว +1

    Thank you very much

  • @mymusawo2393
    @mymusawo2393 2 ปีที่แล้ว +1

    Subscribing with all my accounts! Great content… go E! 🚀

    • @BeforeSemicolon
      @BeforeSemicolon  2 ปีที่แล้ว

      Thanks for the support. Welcome to BFS

  • @yannickmussche5068
    @yannickmussche5068 3 ปีที่แล้ว +1

    No explanation of how to style a form. Just a video of how you style your form.

    • @BeforeSemicolon
      @BeforeSemicolon  3 ปีที่แล้ว

      Thats on the top of the list. Will be my next video

  • @gamet8290
    @gamet8290 3 ปีที่แล้ว

    Отлично! Спасибо огромное. Теперь понятно.

  • @deebx8214
    @deebx8214 2 ปีที่แล้ว +1

    helpful

  • @codestronomer4531
    @codestronomer4531 3 ปีที่แล้ว +1

    this technique does not work in textarea

    • @BeforeSemicolon
      @BeforeSemicolon  3 ปีที่แล้ว +1

      The video is for text-based input but the same strategy still works for textarea. Have you find anything that did not?

    • @codestronomer4531
      @codestronomer4531 3 ปีที่แล้ว +1

      @@BeforeSemicolon I solved the problem. It was enough to write ( required="" ) in the textarea.

    • @BeforeSemicolon
      @BeforeSemicolon  3 ปีที่แล้ว

      Oh okay…you can actually learn a different technique by reading this article i wrote link.medium.com/ZqJnRu2zbhb. It uses placeholder instead of required.

    • @codestronomer4531
      @codestronomer4531 3 ปีที่แล้ว +1

      @@BeforeSemicolon thank you for help

    • @BeforeSemicolon
      @BeforeSemicolon  3 ปีที่แล้ว

      Anytime

  • @ssigitas69
    @ssigitas69 4 ปีที่แล้ว +1

    It is for professionals, not for beginners. For me everything to fast and not clear to many everything

    • @BeforeSemicolon
      @BeforeSemicolon  4 ปีที่แล้ว +1

      Sorry about that. Anything I can do to help you in thay regard?

    • @ssigitas69
      @ssigitas69 4 ปีที่แล้ว +1

      @@BeforeSemicolon thank you so much, but nothing. It is my problem. I still need learn lot of things 😁

    • @BeforeSemicolon
      @BeforeSemicolon  4 ปีที่แล้ว +1

      Then in that case reach out anytime through any of the social media platforms linked in the description of this video. Ill be glad to help.