CSS Tutorial: Creating a Navigation Menu | Web Development Tutorials #23
Aug 15, 2023
CSS Tutorial: Creating a Navigation Menu | Web Development Tutorials #23
► Source Code \u0026 Notes: https://codewithharry.com/videos/web- … ►This video is a part of this Complete Web Development in Hindi Course Playlist: • Web Development Tutorials For Beginne… ►Click here to subscribe - / @codewithharry ►Checkout my English channel here: / programmingwithharry Best Hindi Videos For Learning Programming: ►Learn Python In One Video - • Python Tutorial In Hindi 🔥 ►Python Complete Course In Hindi - • Python Tutorials For Absolute Beginne… ►C Language Complete Course In Hindi - • C Language Tutorials In Hindi ►JavaScript Complete Course In Hindi - • JavaScript Tutorials In Hindi ►Learn JavaScript in One Video - • JavaScript Tutorial ►Learn PHP In One Video - • Learn Php In One Video In Hindi - हिं… ►Django Complete Course In Hindi - • Python Django Tutorials In Hindi ►Machine Learning Using Python - • Machine Learning Tutorials For Beginn… ►Creating \u0026 Hosting A Website (Tech Blog) Using Python - • [Hindi] Web Development Using Flask a… ►Advanced Python Tutorials - • Intermediate/Advanced python Tutorial… ►Object Oriented Programming In Python - • Object Oriented Programming Tutorials… ►Python Data Science and Big Data Tutorials - • Python Data Science and Big Data Tuto… Follow Me On Social Media ►Website (created using Flask) - http://www.codewithharry.com ►Facebook - https://www.facebook.com/CodeWithHarry ►Instagram - https://www.instagram.com/codewithharry/ ►Personal Facebook A/c - https://www.facebook.com/geekyharis Twitter - https://twitter.com/Haris_Is_Here
Content
0 -> In last video we saw how we can do styling
5.196 -> make buttons, we saw many things. Now we what will do
9.193 -> is I'll make a new file here.
13.21 -> After HTML boilerplate we will see that
15.989 -> how a navigation menu is made.
18.269 -> So, I'll write navigation here and ctrl+s to save.
23.485 -> and with that what I'll do is
27.822 -> open my live server by clicking on go live.
31.799 -> And here my live server is opened, as you can see.
35.697 -> to make navigation menu I'll add some style tags
41.312 -> because what I have to do here is add all CSS.
47.227 -> So, I will add a header and nav inside it.
53.002 -> And I will give a class="navbar" to nav because I want to target it.
57.299 -> And I'll add ul in it because I want to add some li in it.
66.07 -> And after adding li what I'll do is,
71.545 -> first of all, I'll make a ul and write li inside it.
75.942 -> li X 4, will get 4 li. One is home, 1 about, 1 services,
83.354 -> and contact us with that. It will look very bad.
88.649 -> Let's do format document first so at least this looks good.
92.167 -> And if I take you here, it looks bad not at all as navigation menu.
96.864 -> We want a good navigation menu. Let's see how to make that.
100.821 -> First of all we will target navbar class.
105.518 -> We will write .navbar
109.635 -> I'll say add a background-color: red; in .navbar.
114.671 -> Obviously, red won't look nice. But giving because
118.748 -> I want to see till where my which thing is going.
121.108 -> Now, I have given red background-color means till here it is going.
127.382 -> If I won't have added then I wouldn't have know how much space it takes.
130.94 -> with that I'll say my .navbar
136.196 -> I want that all the li's in it,
139.794 -> and here I'll write inside my navbar li
143.971 -> float: left; now it will float left but bullet is coming here.
150.685 -> So, we can remove bullet from list-styling.
154.86 -> So, list-style: none; as I do this, bullets will be gone.
164.267 -> Now the problem is my background colour is not showing
169.003 -> And it's not showing because when we float something
172.461 -> it overflows from parent. So, this is overflowed too.
177.018 -> So what I have to do is I have to target .navbar's ul
182.314 -> overflow: auto;
185.293 -> And as I do it my background should show and you can see it
189.171 -> Now I will add some padding to my li
193.348 -> And will give padding: 3px 3px;
197.605 -> And in fact let me do one thing the a inside it
201.722 -> .navbar li a, I will give padding to it.
207.697 -> You might be thinking why to that?
210 -> I am giving padding to that because if I give padding to this
213.259 -> Then what will happen let me show you
216.258 -> I have entered directly home inside it but,
217.898 -> I plan to keep a, anchor tag, inside it, so that
221.456 -> when anyone clicks on it
222.677 -> then it can reach to a page.
224.677 -> So, here in home I have kept padding which I will increase
229.493 -> So, here I have given padding to a inside it.
232.572 -> So, let me do one thing here. By placing multi-cursor here
237.788 -> I will quickly add the anchor tag like this
242.744 -> And all the rest thing like home
246.142 -> And about and services
250.099 -> All this thing I will add inside anchor tag
255.814 -> And I will quickly add with multi cursor href="#"
264.845 -> And as soon as I will do this you can see underline here
267.145 -> And obviously it's not looking nice so we will write here
272.78 -> text-decoration: none; and as I do this the underline beneath it
280 -> is gone. Let me make the background black here.
285.775 -> And with that make the colour of a white
291.678 -> And I'm not saying to keep same colour like this when you code
297.493 -> No it's not like that you don't have to make exactly like this
300.334 -> So here I think things are looking good.
302.753 -> Let me give margin to all this too.
306.571 -> Here I haven't given any margin to my li's a
312.346 -> In fact I will give margin to my li. So, margin: 3px 3px;
319.699 -> And once this is done I will set it by right clicking and inspecting.
324.795 -> And here I can increase the margin, if increase padding
328.972 -> Then the system is going like this which I don't want
332.191 -> I will want to increase my li's margin
335.429 -> If I keep this much margin from top bottom then my navigation is ok
341.064 -> 13px is right I don't want more than that 13-20 is right
347.299 -> So I will do the margin 13-20
352.255 -> And you can easily do this according to you
356.013 -> See how good it is looking now and I can do one more thing
359.831 -> I can give border-radius to this navbar
365.326 -> border-radius: 4px; So, it will be curvy from here.
371.84 -> now I can control its curve from here. I can increase it,
376.217 -> If you want to make navigation menu like this you can
379.256 -> make it 36px, and 30px is good if I do it 30px
385 -> my border-radius I can do that too.
387.699 -> And with that if you want to make it grey not black
393.354 -> then you can make it grey or reddish if you want
398.39 -> You can make navigation menu of any color
400.789 -> And with that you can add search here.
404.047 -> So, suppose I make div here inside this
407.885 -> I do div .search and write this is search box here.
413.1 -> with that I will add this in this ul box only.
416.838 -> As I will add this inside ul, you can see what happens
422.014 -> It came here. And I can give padding in this search box
428.568 -> I can give margin from top, padding will be from inside.
435.522 -> margin will come from outside. So, padding: 2px 4px;
441.757 -> You can give styling in any way you want. No problems.
444.156 -> If I increase padding in y then I make it centered.
447.414 -> And If I increase padding in X it will come like this.
451.491 -> And If I copy this padding and add in .search here
458.984 -> And with that if I add input tag here
464.319 -> And if I make type="text" name="search"
471.652 -> ID="search" and if I save it then see here
477.547 -> a search box is created and I can write here like this
482.204 -> placeholder="Search this website"
486.421 -> We saw in form video that we can add placeholder here.
489.679 -> And then we can do styling of this menu.
492.498 -> So, I can do inside nav
496.276 -> in my .navbar
500 -> style my input tag like this.
505.895 -> How? First make their border: 2px solid black;
516.724 -> with that make border-radius: 4px; Let's see how it looks.
522.499 -> Looking kind of okay. Will give padding: 3px; with it.
529.633 -> And if I inspect here by right clicking then
534.17 -> the things I have added, If I increase its padding
537.988 -> So, it will look like this. I don't want to give much padding to it.
541.706 -> because I have already given much padding to outer element
544.105 -> So, I think this should be good. I will increase border-radius
547.543 -> so that it should look like this.
549.323 -> Now, I think it looks good.
553.64 -> I want to use an icon with search this website on which
557.617 -> by click it this website will be searched.
562.893 -> but again we won't go much on it.
565.133 -> Let me do one thing the padding given to navbar input
567.992 -> will make it 3px 4px so I can increase from here.
572.129 -> So, I can only increase x padding.
575.327 -> with that let me increase y padding too.
579.684 -> So, that website looks quite right.
581.484 -> And I don't think I need to increase padding much.
585.861 -> because I don't want to disturb this inline content.
588.54 -> So, I won't increase padding much, This should be good.
591.758 -> If I make 17 in X then it will work.
595.236 -> We are not making a fully fledged website here
600 -> We are just testing here I think this should be good
602.34 -> if I do this much and increase border-radius a little
605.399 -> Then it will look good if I do border-radius: 14px;
609.436 -> With that I can set its width
613.593 -> And I can make its width as much bigger as I want
618.05 -> So I can control it by width it too
621.109 -> I think this much is enough and here
623.968 -> I can enter and search this website
625.988 -> So I will write width: 129px; here
629.566 -> I will save it and this is how my website looks
633.723 -> I will increase border-radius: 14px;
640.716 -> Now I think website is looking nice
645.353 -> You can add more content below it but again
650.089 -> If you think you don't want radius then leave it
654.466 -> Adding radius is your choice with that you can align
658.723 -> The li inside the navbar, the padding on top-bottom in li
664.798 -> with that the padding coming from here
667.996 -> You can control it suppose if I give it padding-top
677.266 -> then it will come down a little. You will get advantage of padding-top
681.324 -> The difference I push this upper side I can bring it down
684.242 -> So you can design like this using different properties
687.72 -> And below it content will come.
689.72 -> One more thing I want to do here I receive it and do it normal
694.916 -> One more thing I want to do is when we hover on it
702.469 -> on li's a then you can write that when anyone hover on it
709.463 -> Then make its background-color: red;
716.716 -> I am doing it to just show it is red like this.
722.211 -> I don't want background-colour to change I want its colour to change
727.747 -> So I'll make its colour: red;
731.225 -> So when someone brings arrow on it like this
735.622 -> You may want to have like this and on clicking it'll go on respective pages.
741.038 -> And you can add padding in a li if you want
745 -> You can add padding if you think your elements are not centred
748.858 -> Then feel free to add any padding you want to add
753.834 -> I have already added margin in all this in li's a
757.911 -> and our li is stick to top so if you want to give margin on top and bottom
762.588 -> or padding then you can give.
764.768 -> I have already added 13px margin from top and bottom
767.926 -> So you can design navigation menu like this
770.545 -> So I hope you have understood it clearly
775 -> And you can design your website like this
778.538 -> If you haven't access this playlist yet then do access
783.015 -> Because this is the place where I am uploading all the videos
785.634 -> Bookmark it by clicking here and save it by clicking here
790 -> That's it for this video.
791.761 -> Thank you so much for watching this video
793.761 -> Don't forget to like this video and I will see your next time.
Source: https://www.youtube.com/watch?v=OsPOBsclJLU