Create a Modal (Popup) with HTML/CSS and JavaScript

Поделиться
HTML-код
  • Опубликовано: 16 апр 2020
  • 👉 Daily Coding Challenges: iCodeThis.com/?ref=ytb-modal
    In this tutorial, we're going to learn how to build a #Modal / #Popup using HTML, CSS, and a little bit of #JavaScript to toggle a class.
    ---
    Follow me on:
    📃 Website/Blog: florin-pop.com
    👉 Twitter: / florinpop1705
    👉 Linkedin: / florinpop17
    👉 Instagram: / florinpop17
    👉 Github: github.com/florinpop17
    👉 Twitch: twitch.com/florinpop17

Комментарии • 146

  • @devtest9282
    @devtest9282 3 года назад +1

    short concise and crisp. Exactly what I wanted. Thank you

  • @KyleBondo
    @KyleBondo 3 года назад

    Excellent tutorial! Short, sweet, and to the point -- and it WORKED!! Thank you!

  • @SocialIntrovert29
    @SocialIntrovert29 2 месяца назад

    Taking a front end class in masters, you just saved my assignment. deserve a subscribe. :)

  • @abdifatahmoh
    @abdifatahmoh 4 года назад +7

    Well done, Florin. I actually like this kind of mini-js projects. It helps me to grasp how DOM JS works.

  • @KirkMitchelllelouprouge
    @KirkMitchelllelouprouge 2 года назад +1

    This is one of the best modal tutorials I've tried and the first one to actually help me implement it into my site! Thank you!

  • @letrantuantai6889
    @letrantuantai6889 2 года назад +3

    Your tutorial is awesome!!!! It is simple, straightforward and kind of easy to follow. Please keep up your good work.

  • @kettenbach
    @kettenbach 4 года назад +1

    I think I'm addicted to the sound effects at the beginning of your videos. So digital! 😀👍

  • @chiragjain4137
    @chiragjain4137 2 года назад +1

    I was really struggling with creating a Modal of my own. I was tangled in min-height, max-height. Could not even center the Wrapper div. Great video. Position fixed made a perspective a little clearer. Thank You.❤

  • @victormarinviloria633
    @victormarinviloria633 4 года назад

    Thanks, Florin! Loved your way of explaining!

  • @cosy5112
    @cosy5112 Год назад

    Thank you, super easy to follow!

  • @zaka2
    @zaka2 4 года назад +17

    wow, watched too many videos abuse youtube's 10min rule, it feels awesome to see something beautiful made in this time, thanks

    • @FlorinPop
      @FlorinPop  4 года назад +1

      Glad you like it 😄

    • @jeremiascristian521
      @jeremiascristian521 3 года назад

      You prolly dont give a shit but if you're bored like me atm then you can watch all the latest movies and series on InstaFlixxer. Been streaming with my brother for the last few days :)

    • @axtonkarson2634
      @axtonkarson2634 3 года назад

      @Jeremias Cristian yup, have been using Instaflixxer for since december myself :D

    • @ashwathmittal99
      @ashwathmittal99 2 года назад

      @@FlorinPop Can I get the code ?

  • @maximepoitoux4541
    @maximepoitoux4541 3 года назад +1

    Thanks again Florin, you are the best !

  • @BlueMoises96
    @BlueMoises96 3 года назад

    the best modal js video i have ever seen, thanks for share with us.

  • @hemantnimble8442
    @hemantnimble8442 Год назад

    Thanks a lot!
    I was struggling with popup modal you gave me the basic idea to execute what i was planning , It helped me a lot

  • @tenc6491
    @tenc6491 2 года назад

    I am glad to have found your page coz I get to learn awesome stuffs with your easy-to-comprehend-tutorials.
    You're really good. Thanks for sharing such wonderful tutorials.

  • @iUmerFarooq
    @iUmerFarooq 4 года назад +2

    Wow, I love this waiting for more like this.
    I have learned something new like *pointer-event* how this works.
    Thank you And *must always use JS in your every Tutorial.*

  • @wetsand7379
    @wetsand7379 2 года назад

    thank you for this tutorial! it was really easy to understand and follow.

  • @nilamrakholiya5650
    @nilamrakholiya5650 3 года назад

    Too useful thing explained in too less time . ..amazing👍 thank you sir

  • @kbhargavi4400
    @kbhargavi4400 Год назад

    superb explaination ! Simple n easy ! Learnt a lot in short time . Thank you florin .

  • @nickapeed
    @nickapeed 3 года назад +7

    I feel like this sounds silly but it would be a great help to have a copy of the code. When i set pointer-events to none i still can't click the button 7:12 . Also can't figure out why my 'click me please' button centered horizontally. Either way thank you for posting!

  • @lillianho6613
    @lillianho6613 Год назад

    Hi Florin, thank you for the tutorial! I'm pretty new to HTML/CSS/JS and wanted to implement an info button that would create a modal popup when clicked upon. For some reason, when I click the button, the background becomes darker but the modal doesn't show for some reason. I tried following along on a fresh project with nothing else on it, and I was able to make the modal appear when copying and pasting the code I wrote on the previous project. Do you have any idea why this might be occurring?

  • @blabberq
    @blabberq 2 года назад

    That was what I need, thank you :)

  • @ricardodesirat2590
    @ricardodesirat2590 4 года назад +7

    Hey Florin!
    Great video, as always. Love the way you quickly explain every step.
    One doubt.. could/or does it make sense to use classList.toggle instead of the .remove & .add?

  • @madu6451
    @madu6451 2 года назад

    This tutorial was great!

  • @kojoarhin8634
    @kojoarhin8634 2 месяца назад

    Appreciate you
    Helped me solve an issue

  • @bipashamazumder1884
    @bipashamazumder1884 2 года назад

    Wow learnt too many things in just 10 mins🙂 thank you sir

  • @Kreytonchild
    @Kreytonchild 9 месяцев назад

    awesome! thank you so much!

  • @skysmeller
    @skysmeller Год назад

    Damn, man TY very much! U saved me ^^

  • @sanasamir7129
    @sanasamir7129 2 года назад

    Love the video. Thank you.

  • @emmanuelphillip5856
    @emmanuelphillip5856 6 месяцев назад

    Thank you. How do i get the modal to open automatically when the index of a site is accessed?

  • @aldorsan
    @aldorsan 3 года назад

    Excelent tutorial. Good work

  • @saikiduong4179
    @saikiduong4179 3 года назад

    Thank you for this tutorial

  • @bessa9181
    @bessa9181 2 года назад

    What can I do if I want to allow the user to close the modal just clicking outside the modal box?

  • @dikshyantauprety4020
    @dikshyantauprety4020 Год назад

    Thank you so much..

  • @BahawalTV
    @BahawalTV 4 года назад

    Well done Florin!

  • @KanekiSidibe
    @KanekiSidibe 9 месяцев назад

    Well explained thanks!

  • @OyiboVFX
    @OyiboVFX 3 месяца назад

    Struggling with modals. But yours works fine. Thanks

    • @OyiboVFX
      @OyiboVFX 3 месяца назад

      Update… works fine as a stand alone HTML file. But does not work in Bootstrap Studio. The search continues

  • @sheraz_razzaq
    @sheraz_razzaq 2 года назад

    Nice Florin Thank you for sharing.

  • @dexterdragons
    @dexterdragons 3 года назад

    hey, how to refresh, scrollTop modal? e.x. boostrap modal - Scrolling long content, how to? help? tutorial?

  • @kugi7786
    @kugi7786 3 года назад

    So smooth.

  • @jafartouzeau2461
    @jafartouzeau2461 20 дней назад

    Thank you so much that was very helpful !

  • @lambdatraveller4316
    @lambdatraveller4316 4 года назад

    Please make such short videos.. Many things to learn

  • @jhonjairorengifovera9185
    @jhonjairorengifovera9185 3 года назад

    nice men, but i have a question, how disable scroll when open the modal

  • @adao5308
    @adao5308 2 года назад

    Thank you!

  • @s000sdas
    @s000sdas 2 года назад

    Vreau sa devin programator ca tine Florin!

  • @ariankheradmand4947
    @ariankheradmand4947 2 года назад

    Thank you so much

  • @ravikethe8729
    @ravikethe8729 2 года назад +2

    very nice, do you have source code listed somewhere? that will definitely help many of us to save some time too.

  • @stefanpfadt4353
    @stefanpfadt4353 2 года назад

    WOW! can i make the popup only appear when a specific user clicks on it, e.g. guest?

  • @aymdatenth1796
    @aymdatenth1796 Год назад

    thank you it helped me

  • @GuilhermeSouza-zh6go
    @GuilhermeSouza-zh6go 2 года назад

    I'm having problems, when I put fixed position it fixes the whole page and when it opens, it doesn't close

  • @HarshitSharmaVlogss
    @HarshitSharmaVlogss 3 года назад

    Great Video!!!!

  • @shanKirs10
    @shanKirs10 4 года назад +1

    Thank you - A very good one.
    But how would we disable the scroll bar and any scrolling.

    • @FlorinPop
      @FlorinPop  4 года назад +2

      You could set the body to be overflow hidden.

  • @tejasparse9053
    @tejasparse9053 2 года назад

    Why not make display none instead of switching opacities?

  • @user-se6ct5zu2f
    @user-se6ct5zu2f 2 года назад

    thank you!

  • @aramartin2804
    @aramartin2804 2 года назад

    Is it possible that when you click the close me button, it will lead you to next webpage?

  • @arantube8211
    @arantube8211 Год назад

    What name of code editor used

  • @gamingvortx4630
    @gamingvortx4630 2 года назад

    which ide u r using

  • @icrmsoftware59
    @icrmsoftware59 Год назад

    Thank you

  • @iliyalyan8937
    @iliyalyan8937 3 года назад

    how to make one for each item in table?

  • @timonwill1
    @timonwill1 4 года назад +1

    Nice!

  • @Badtricks
    @Badtricks 3 года назад

    where can we get the code

  • @abdifatahmoh
    @abdifatahmoh 4 года назад

    Can we set click me button's z-index:1; instead of setting modal-container to pointer-events: none; so the button can be on top of the modal-container ? Also set the modal-container display: none; , and from there in javascript style it to display: 'block'; when the button even listener is clicked.

    • @FlorinPop
      @FlorinPop  4 года назад +1

      You won’t have the transition with display

  • @raedsalah
    @raedsalah 4 года назад +1

    that's a great video. +1 sub

  • @proprogramming7203
    @proprogramming7203 3 года назад

    is it gonna work when we put an image instead of button. please reply.😯

  • @remax110
    @remax110 4 года назад +1

    Great tutorial. I like this mini project. Thank you.

  • @deivi3697
    @deivi3697 2 года назад

    How i do it with SessionStorage y localStorage?

  • @vikasjain8097
    @vikasjain8097 2 года назад

    How to set automatic popup when page load

  • @arescatalin1407
    @arescatalin1407 3 года назад

    The next Brad Traversy... mark my words!!

  • @willnovan6373
    @willnovan6373 Год назад

    for everyone that is asking why the button can't click nor open the modal, i wanna know if u guys r using or no. if yes then u have to place it in not in . it works for me.

    • @FlorinPop
      @FlorinPop  Год назад

      Or you can add the “defer” attribute on the script tag

  • @jatinraj4974
    @jatinraj4974 4 года назад +2

    After era of long live streaming here comes small video tutorial which we all love😍😍🤘🤘🤘

  • @Marian5Feb1971
    @Marian5Feb1971 4 года назад

    Great tutorial on creating a Modal....I am trying to pass data(unordered list) from a html page to another html page or modal. Can data be passed into Modal and should I use local storage, any suggestions would be appreciated.

    • @FlorinPop
      @FlorinPop  4 года назад

      You can use that, yes.

  • @ProgramWithErik
    @ProgramWithErik 4 года назад

    I just made this in Vue! :) and Tailwind on my channel, what a coicidence :)

  • @arunagirim3455
    @arunagirim3455 2 года назад

    could you tell the directory of the source code in github

  • @alvarocampos1495
    @alvarocampos1495 Год назад

    Very nice

  • @NottanALias
    @NottanALias 2 года назад +2

    total beginner here. when i try to do this, I always get: 'open is null'
    no idea why, I am working in cs code, referencing the .js from the HTML header using
    any tips?

    • @blank_sfr
      @blank_sfr 2 года назад

      the standard form is tu put the script tag at the bottom of body tag.
      make sure you passed the "open" id to the html BUTTON tag and your DOM selector is not having a problem.
      its all about debugging bro :D

  • @Vipeeri
    @Vipeeri 2 года назад

    What if I need 1000x modals? Then I'd have quite many unnecessary layers of js running on a website. Isn't there any way of creating the modals dynamically?

  • @blank_sfr
    @blank_sfr 2 года назад

    Question! you defined the modal inside the container(overlay). now is there a way to close the modal by clicking the gray area?
    also thanks for the great content!!

    • @emanuellamba5828
      @emanuellamba5828 2 года назад

      Yes, you can put a click eventlistener on the div with the gray area which will remove the 'show' class from the modal container

  • @karthikgovindappa
    @karthikgovindappa 4 года назад +4

    Can we use display:none instead of opacity ?

  • @revnicoana8313
    @revnicoana8313 2 года назад

    LOVE YOU

  • @augischadiegils.5109
    @augischadiegils.5109 2 года назад

    thanks

  • @DevHasan
    @DevHasan Год назад

    awesome

  • @rayahmed2202
    @rayahmed2202 3 года назад

    Thanks

  • @shubhammane2373
    @shubhammane2373 2 года назад

    how to make nested modal

  • @user-hx4uf3tc3i
    @user-hx4uf3tc3i 2 года назад

    I like this 👍.

  • @ehtishamliaqat9510
    @ehtishamliaqat9510 3 года назад

    Amazing

  • @heraldocastillo8763
    @heraldocastillo8763 3 года назад

    Thanks sr

  • @ourielperez1646
    @ourielperez1646 3 года назад +1

    Hello Florin.
    Thanks for all your videos :)
    Just one question: how can we add emojis on Codepen like you did?
    Thank you in advance.
    Have a good week :)

  • @AgniVibes
    @AgniVibes Год назад

    excelent tutorial bro, m ai scos din belea! XD
    o singura rugaminte as avea daca se poate sa ti egalezi levelul (dB) al muzicii cu cel al vocii pe final ptr ca diferenta de volum e uriasa.... am sarit din scaun! lol
    Merci inca o data! 👍👍👍

  • @olanitoritobi5107
    @olanitoritobi5107 2 года назад

    mine doesn't work please help! the button does nothing!

  • @marrisaikrishna416
    @marrisaikrishna416 2 года назад

    Awesome

  • @gurametempe3011
    @gurametempe3011 2 года назад

    Pointer-events not working help me please sir

  • @aswinm459
    @aswinm459 Год назад

    nice video

  • @Uzakoff_u
    @Uzakoff_u Год назад

    🔥🔥

  • @MrsLalaina
    @MrsLalaina 2 года назад

    Hello !
    Thanks, that's great !, now how to make it responsive? (sorry for my english, i'm French ^^)

  • @rasmusmoto7668
    @rasmusmoto7668 2 года назад

    cant close the model, the button is unclickable. tried cahnging the z.index nothing work

    • @marygracetecson7148
      @marygracetecson7148 6 месяцев назад

      Please share your code to save us time keying it. and just experiment with it. Thanks

  • @ekaterinaropleva2406
    @ekaterinaropleva2406 3 года назад

    Hey Florin, awesome tutorial. Perfectly worked with me. However, could you please explain to me how can I make multiple modals to open when clicking multiple buttons. I mean the following: I have a card gallery, and every card has a "Read more" button, which shows different information. Thanks in advance and keep up the awesome work! Best wishes from Bulgaria 💙

    • @valentepablo
      @valentepablo 3 года назад

      In that case, your modal would be like a component because you would use it a couple times. The best for that is working with Classes. It's a little bit more advanced but really saves you on the long run.

    • @johnme60
      @johnme60 2 года назад +1

      @@valentepablo Comment is 1 year old I hop you guys doing well in life. but maybe someone reading it now, I'll suggest a trick from my limited knowledge.
      1. Assume modal has a heading h1 tag, and a body with tags ; give them unique IDs
      2. Every read more button invokes a function , this functions takes "text and headline" as input.
      3. you can read the text from a text file or just write in the js file.
      4. this function receive the text and headline , and use it to change the "innerText" property of modal .
      5 . now the h1 heading tag is changed with your given headline and tag with detailed paragraph.
      6. Every readmore button has a unique Id , according to that ID ,the function can change modal text every time with different text and headline.

  • @AjayKumar-ft4ge
    @AjayKumar-ft4ge 3 года назад

    you should have shared your code for practising

  • @apurvashah9207
    @apurvashah9207 3 года назад

    Best

  • @chandranvutukuri5047
    @chandranvutukuri5047 Год назад

    where is the source code for this modal

  • @loudichoson321
    @loudichoson321 3 года назад

    Is this responsive?