How to create a CSS navigation bar in 6 minutes! 🧭

Поделиться
HTML-код
  • Опубликовано: 21 ноя 2024

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

  • @BroCodez
    @BroCodez  Год назад +205

    Bro Code

    Bro Code


    Home
    About
    Products
    Contact



    This is the Home page
    Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsam minus eveniet recusandae dicta similique numquam voluptas quos tempore cupiditate pariatur, laudantium fugit alias quia veritatis nesciunt quaerat molestias adipisci assumenda.

    /* style.css */
    body{
    margin: 0px;
    }
    main{
    margin-left: 20px;
    margin-right: 20px;
    }
    h1{
    text-align: center;
    }
    .navbar ul{
    list-style-type: none;
    background-color: hsl(0, 0%, 25%);
    padding: 0px;
    margin: 0px;
    overflow: hidden;
    }
    .navbar a{
    color: white;
    text-decoration: none;
    padding: 15px;
    display: block;
    text-align: center;
    }
    .navbar a:hover{
    background-color: hsl(0, 0%, 10%);
    }
    .navbar li{
    float: left;
    }

  • @shanepelletier2347
    @shanepelletier2347 7 месяцев назад +24

    for anyone trying to make this responsive:
    body{
    margin: 0px;
    }
    main{
    margin-left: 20px;
    margin-right: 20px;
    }
    h1{
    text-align: center;
    }
    .navbar{
    background-color: hsl(0, 0%, 25%);
    }
    .navbar ul{
    list-style: none;
    padding: 0px;
    margin: 0px;
    display: inline-flex;
    }
    .navbar a{
    color: white;
    text-decoration: none;
    padding: 15px;
    display: block;
    text-align: center;
    }
    .navbar a:hover{
    background-color: hsl(0, 0%, 10%);
    }
    this uses flexbox and added .navbar{} so the background color stretches across the webpage

    • @flinch9710
      @flinch9710 7 месяцев назад +1

      You're a lifesaver. Thanks!

    • @Kieselsteo
      @Kieselsteo Месяц назад

      Yo bro it seems like u know about this. Can u help me with something ? I did everything like in the video but my Navigation Bar is not going horizontally. So picture it like that. It is vertically and the elements still take up the entire lenght of the browser as if they were div elements. How do I solve this bc I literally made everything exactly like in the video ...

  • @StopWhining491
    @StopWhining491 Год назад +56

    You've got the best step-by-step videos. Thanks for all your work and sharing.

  • @richardolajiga3176
    @richardolajiga3176 Год назад +26

    This guy is too good with his explanations

    • @l-fitness3590
      @l-fitness3590 10 месяцев назад +5

      It’s straight to the point and easy to understand definitely one of the best

  • @devd3
    @devd3 Год назад +262

    bro cooked and I ate

  • @Legomaniac359
    @Legomaniac359 9 месяцев назад +13

    Straight to the point. Thank you!

  • @jakry_apexlegends
    @jakry_apexlegends 11 месяцев назад +6

    You are a gentleman and a scholar. Thanks

  • @InterestingLake
    @InterestingLake 6 дней назад +1

    Awesome tutorial, thanks!

  • @supreme_wx2499
    @supreme_wx2499 6 месяцев назад +3

    IVE BEEN LOOKING FOR THIS SO MUCH. Im so glad l found you bro

  • @deborahtshiyeya307
    @deborahtshiyeya307 6 месяцев назад +1

    Thank you for explaining while showing us how to do it. This makes it easier to understand. You are the best❤❤

  • @happytofu5
    @happytofu5 23 дня назад

    Oh man already the third video I watch from you today. You really cover it all, thanks bro!

    • @GirlActober
      @GirlActober 10 часов назад

      I want to do options and in inside the options do another option, how can I do it??

    • @happytofu5
      @happytofu5 10 часов назад

      @@GirlActober I found the video "The Only CSS Layout Guide You'll Ever Need " by EdRoh very helpful on how to do layouts

  • @maricarlacerna5841
    @maricarlacerna5841 11 месяцев назад +5

    Finally! A working code! thank you very much for this @Bro Code you save me from failling

  • @CapDrew
    @CapDrew Месяц назад

    Great explanation. You made that look easy, I just have to make a couple of these to get it down so I don't forget.

  • @amandapanda3750
    @amandapanda3750 9 месяцев назад +5

    Thanks so much. I've been searching for sooo long to find out how to do this.

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

    Bro code is elusively elegant as ever

  • @bamanbamni
    @bamanbamni 11 месяцев назад +3

    it is important to use main (can we use a div instead of main for main content
    )

  • @user-dk9of1ok1n
    @user-dk9of1ok1n 5 месяцев назад +1

    You are the best Bro. Stay blessed 🙌

  • @asa-od9pu
    @asa-od9pu 7 месяцев назад +8

    How do I center the navigation br in the center of my webpage, it wants to all shift to the side but I want it to be about 100 pixels long and center with h1

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

    BRO YOU'RE AMAZING, HELPING ME SO MUCHHHH, THANK YOUUUU

  • @mr.shredder5430
    @mr.shredder5430 10 месяцев назад +4

    just the thing i needed thanks for sharing this content👍

  • @waltermitty4132
    @waltermitty4132 7 месяцев назад +9

    I don't understand why you added "overflow:hidden" to the CSS file? What is its purpose in this navbar?

    • @realnoscope
      @realnoscope 7 месяцев назад +5

      so it doesn't show a scroll bar on the nav bar

  • @Tempest28000
    @Tempest28000 24 дня назад

    Hi! Senior high school student here! You dropped this king 👑 🗿

  • @asterinology
    @asterinology 7 месяцев назад

    the tutorial is simple and straightforward. thank youuuuuu❤❤❤

  • @ayannasir6653
    @ayannasir6653 Год назад +14

    Make a video on how to put "LOGO" and adjust its height and width using "CSS" with according to our needs?

    • @Pankajweb996
      @Pankajweb996 5 месяцев назад +1

      Exactly same problem i was facing😂

    • @Thegoal2.P
      @Thegoal2.P 4 месяца назад

      @@Pankajweb996 just use img

  • @Asulescu
    @Asulescu 8 месяцев назад

    May god bless you ! Thank you save my life seriously

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

    Best teacher 🧑‍🏫

  • @ØgbDêcêntPRETON
    @ØgbDêcêntPRETON 16 дней назад

    Thanks man you're our a real bro 💪

  • @Procode-w2r
    @Procode-w2r 2 месяца назад

    you should be my coding teacher keep it up

  • @SmartKhani786
    @SmartKhani786 Месяц назад

    wow great work you've done❤
    i subscribed your channel.

  • @MdHossainAhmed-sc4ui
    @MdHossainAhmed-sc4ui 9 месяцев назад

    Very helpful video

  • @mohaimenpotawan2842
    @mohaimenpotawan2842 8 месяцев назад

    very kind blogger

  • @HafeezKhan-it3bl
    @HafeezKhan-it3bl Месяц назад

    Bro your crazy man I like you thanks for help ❤️❤️

  • @VijaykumarA-o8v
    @VijaykumarA-o8v 8 месяцев назад +1

    Hi Bro Codez, Your tutorials is awesome. Please clarify my doubt, Some of the using Flexbox and Grid to align the navbar button but you didn't use that so please explain
    which is correct.

    • @felcynchannel840
      @felcynchannel840 7 месяцев назад

      I believe you want to use flex box to make it more responsive

  • @OceanFanatic
    @OceanFanatic 5 месяцев назад

    Helpful video. Thank you

  • @3210egh
    @3210egh 4 месяца назад

    It helped me a lot. Thank you very much. Let's take a follow-up lecture. Lee Jong-hoon from the coast

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

    Amazing work

  • @gian-mm9kr
    @gian-mm9kr 11 месяцев назад +3

    How can I center the nav bar ? the only way i was able to get was creating a div section.

  • @princeshukraan3099
    @princeshukraan3099 8 месяцев назад

    Very good,I love him

  • @abdullahbiswas1
    @abdullahbiswas1 Год назад +2

    Thank you for the content

  • @dmojela1625
    @dmojela1625 10 месяцев назад

    Best teacher.... 👌

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

    THANKS I NEEDED THIS SO MUCH FOR SCHOOL PROJECT🎉🎉🎉🎉🎉

  • @NnFace-ql3jo
    @NnFace-ql3jo 11 месяцев назад +1

    best coder

  • @Blu3ligh7
    @Blu3ligh7 4 месяца назад

    100/10 great video!

  • @chigozie6333
    @chigozie6333 3 месяца назад +1

    Thank you Bro Code. I practised this tutorial and observed that when i floated the navigation bars RIGHT the navigation bars were not arranged in sequence as described in the script. I had no problem when i floated LEFT. How can i correct this?

    • @paIeville
      @paIeville Месяц назад

      maybe instead of using the float and overflow properties like he did, try using display:inline on the li elements and using text-align:right on the ul. but i cant test rn so dont know if it works
      edit: worked for me

  • @FrederikWoellert
    @FrederikWoellert 24 дня назад

    Yeah Bro I really learn so much from your Videos. I have another Version instead of the float: left you can change the display to inline-block for the (a) and (li):
    And i also change the margin and padding so the ul is in the center( no is not in the center when i change the size of the screen where the index.html is opened. How to center the horizontal navigation bar? Maybe with flexbox but the topic comes later.
    style.css
    /* No Margin for the Navigation Bar */
    body {
    margin: 0px;
    }
    /* The content after the Nav Bar should have a margin */
    main {
    margin-left: 20px;
    margin-right: 20px;
    }
    /* Header of the Website */
    h1 {
    text-align: center;
    }
    /* The ul content inside the navbar */
    .navbar ul {
    list-style-type: none; /* Remove the bullet Points in front */
    background-color: hsl(0, 0%, 25%);
    padding: 0px; /* Size inside the ul bar. */
    padding-left: 70px; /* to center */
    margin: 0px;
    overflow: hidden; /* Keeps content in the navbar ul */
    }
    .navbar a {
    color: white;
    text-decoration: none; /* remove the underline */
    padding: 15px; /* Space between each a Element */
    display: inline-block; /* Changed from block to inline-block */
    text-align: center;
    }
    .navbar a:hover {
    background-color: hsl(0, 0%, 10%);
    }
    .navbar li {
    display: inline-block; /* Changed from float to inline-block */
    }

  • @iangabriel1031
    @iangabriel1031 Год назад +1

    This is what i need!! Thank you so much bro i will subscribe you

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

    Appreciate this, thank you

  • @AdeelAhmad0007
    @AdeelAhmad0007 5 месяцев назад

    amazing

  • @nickpage1575
    @nickpage1575 4 месяца назад

    thank you for this! i am battling constructing a website for my web development course and i am struggling pretty badly. Now i need to fight ad figure out how to create the other sections of my site and link them to the main page...Any tips?

  • @jokosinh
    @jokosinh 4 месяца назад

    Interesting

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

    great

  • @joseluisMartin
    @joseluisMartin Месяц назад

    I've got a question, how did you add style.css to the new tab? Thank you.

  • @muhammadsulaiman4153
    @muhammadsulaiman4153 15 дней назад

    Thank you sir ❤

  • @AdeelAhmad0007
    @AdeelAhmad0007 5 месяцев назад

    Nice Video

  • @hitoshiasakura9109
    @hitoshiasakura9109 27 дней назад

    Bro explained it way more precise

  • @sanjayagnihotrii5126
    @sanjayagnihotrii5126 5 месяцев назад

    amazing brooo thumbs up for bro code share

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

    Can you make a proper responsive website. It will be easy to add in my projects.😉

  • @suyashman7964
    @suyashman7964 Год назад +2

    Epic bro

  • @KaranSingh-zz9rg
    @KaranSingh-zz9rg 4 месяца назад

    thanks sir

  • @ethioictmedia
    @ethioictmedia 10 месяцев назад

    it is Good

  • @prithurajvidyadas2850
    @prithurajvidyadas2850 Год назад +10

    why did u use "overflow:hidden" can u explain that part
    like what did u hide exactly?

    • @omairtech6711
      @omairtech6711 Год назад +2

      I want an answer to this as well. He did not explain at all.

    • @devd3
      @devd3 Год назад +8

      it prevents horizontal scrolling

    • @memefromtheinternet
      @memefromtheinternet Год назад +2

      @@devd3 thanks I also needed that

    • @pholcastaneda3699
      @pholcastaneda3699 11 месяцев назад +5

      @@devd3 But why does setting the property float:left make it disappear? I don't get it

    • @cuteminired6550
      @cuteminired6550 8 месяцев назад

      Yes exactly ​@@pholcastaneda3699

  • @AdeelAhmad0007
    @AdeelAhmad0007 5 месяцев назад

    good

  • @NaftaliKipkoech
    @NaftaliKipkoech 11 месяцев назад

    Bro had to earn my subscription and he did it

  • @ayushlimbu8044
    @ayushlimbu8044 10 месяцев назад +1

    Thanks bro!

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

    extra challenge: style nav with flexbox

  • @GirlActober
    @GirlActober 10 часов назад

    I want to do options and in inside the options do another option, how can I do it??

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

    What have I done wrong because my display:block and text align center is not working

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

    Nice bro

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

    Thank you!!!!!!

  • @Games-games506
    @Games-games506 Год назад

    you are legend - thanks

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

    Which text editor you have installed?

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

    thumbs .. nailed it ! lol

  • @SpongeknobSquarenut
    @SpongeknobSquarenut 10 месяцев назад

    instead of using colors for navigation bar can i use images?

  • @oussamaidrissi9536
    @oussamaidrissi9536 5 месяцев назад

    Thanks you

  • @AmmarAlBalawi-o1b
    @AmmarAlBalawi-o1b 9 дней назад

    how i turn it in button and make it work ?

  • @johnvincentbaguion8338
    @johnvincentbaguion8338 7 месяцев назад

    When we are outting "padding" its turning red, not blue

  • @asifirtezaratul3893
    @asifirtezaratul3893 5 месяцев назад

    Bro can you explain the "overflow: hidden" part? How did that fix the problem there?

    • @karol3209
      @karol3209 4 месяца назад

      So it doesn't show a scroll bar on the nav bar.

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

      When you use float: left; on the elements, the parent no longer recognizes the height of its floated children, because floats are taken out of the document flow. As a result, the collapses, and the background color of the disappears, making it look white (or transparent).
      When you add overflow: hidden; to the .ul1, it forces the parent to recognize the height of its floated children again. This works as a kind of hack to "clear" the floats without needing to manually add a clearfix.
      Here's why it works:
      overflow: hidden; makes the container expand to enclose its floated children, solving the collapsing issue without needing to apply the more explicit clearfix methods.
      Why the overflow: hidden; works:
      Without it: Floated elements are removed from the normal flow of the document. The container doesn't stretch to wrap around its floated children, causing it to "collapse" in terms of height.
      With it: The overflow: hidden; forces the container to calculate its dimensions based on the floated elements inside it, so it correctly stretches to enclose its content.

  • @arunimarajesh6144
    @arunimarajesh6144 5 месяцев назад

    Why did float:left and overflow: hidden make the nav bar horizontal? 4:05

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

      I also have the same doubt someone clear it

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

    Please what extension do you use

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

    Why dont you just use display flex ??

  • @Yeager_001
    @Yeager_001 3 месяца назад +1

    Bro code ❌
    Pro code ✅🤩🥵

  • @chamnabkem5459
    @chamnabkem5459 11 месяцев назад

    Thank you!!!

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

    Just make a container display flex
    It's easy

  • @brightasinde7034
    @brightasinde7034 11 месяцев назад

    Sir Please am looking for how to creat contact form email, text using nave element instead of div element ?

  • @Pavan-gq3ld
    @Pavan-gq3ld 6 месяцев назад

    I'm getting hover effect on logo how do i get rid of it help mee please ,🙋‍♀️

  • @kiddReyes
    @kiddReyes 8 месяцев назад

    If I want to float right why does my words reverse

  • @alexglez3434
    @alexglez3434 4 месяца назад +1

    great, Thanks bro

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

    yo what website editor u using

  • @Compilationguy1727
    @Compilationguy1727 Месяц назад

    The second a copy the html page the codes stoped working

  • @Альтер-эгоКаримаКумбосара

    Thx bro

  • @farhanmirza500
    @farhanmirza500 4 месяца назад

    By flex box this is very easy

  • @kingsleydied
    @kingsleydied Месяц назад

    does anyone elses nav bar stop working when they put it in a ordered list? I don't know how to get it to work

  • @nazmoonnahar9996
    @nazmoonnahar9996 6 месяцев назад +1

    Bro really cooked

  • @boss-ut6yw
    @boss-ut6yw 4 месяца назад

    question
    what is padding
    what is margin ?

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

      padding: is the space between the block content and it's border;
      Margin: is the space between the block itself and the borders of the page;

    • @boss-ut6yw
      @boss-ut6yw 3 месяца назад

      @@Irin_yigir thanks

  • @haloholahehe4285
    @haloholahehe4285 10 месяцев назад

    Damn I envy those who can speak English :(
    Please add Indonesian subtitles 🙏, especially lessons about the 24-hour,12-hour,or 8-hour Java course, Java script, PHP, and others.😅

    • @haloholahehe4285
      @haloholahehe4285 10 месяцев назад

      Your video is really great and I want to learn it but I have problems with the English it uses, especially the programming language lessons I want to learn.😅

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

      Aowkaowkoakw pake translate ke bahasa Indonesia aja bang

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

    add transition: background-color ease 1s;
    and see the result 👍

  • @adejaya1692
    @adejaya1692 7 месяцев назад

  • @EnderKyo
    @EnderKyo 11 месяцев назад

    My styled nav bar isn’t showing up on my second page the links are there it just isn’t styled like the home page, any thoughts?

    • @EnderKyo
      @EnderKyo 9 месяцев назад +1

      @@bqadrat thanks a bunch man I appreciate your comment but I already passed the class so I’m set 😂

  • @athenadaniellacruz8968
    @athenadaniellacruz8968 7 месяцев назад

    Why mine isn't working😭😭

    • @_a.p.o.n
      @_a.p.o.n 6 месяцев назад +1

      Bro chill ofc it doesn't because it's the nature of codding if it works is abnormal

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

    ty