0

I was wondering how I could implement an arrow down icon next to the navigation bar text "About Me" and "Units".

In addition, how could I also make these two pages drop down menus? Below within my code I didn't make them drop down menus due to me not knowing how to make them a drop down menu.

<!DOCTYPE html>
<html lang="en">
<html>
<head>
    <title>Liam Docherty | London Web Developer &amp; GFX designer</title>
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  </head>
<style>
        body{
          margin: 0;
          padding: 0;
        }
        header{
          height: 10vh;
          background-color: #4D5061;
        }
        nav ul{
          list-style-type: none;
          overflow: hidden;
          text-align: center;
    }
        nav ul li a{
          display: inline-block;
          padding: 3.5vh 8px 4px;
          color: white;
          text-decoration: none;
          font-size: 14pt;
          font-family:'Roboto', sans-serif;
        }
        nav ul li { 
          padding-bottom:6px;
          position:relative;
          display: inline-block;
        }
        nav ul li:after {
          content:'';
          position:absolute;
          right:50%;
          bottom:0;
          left:50%;
          height:3px;
          background-color:red;
          border-radius:9px;
          transition:all .2s;
        }
          nav ul li:hover:after {
          right:0;
          left:0;
        }
          a:hover { color:red; 
        }
        #logo{
          padding-top: 2vh;
          padding-left: 20px;
          float: left;
        }
        section{
          position:relative;
        }
        .section1{
          height:93vh;
          background-color: #FFFFFF;
          text-align: center;
        }
        .section2{
          height:93vh;
          background-color: #A59E8C;
          text-align:center;
          color:white; 
          padding-top:23vh;
        }
        .contact_section{
          height:93vh;
          background-color: grey;
        }
        .hero{
          height:750px;
        }
        h1{
          font-family:'Roboto', sans-serif;
          color: white;
        }
        .container-fluid{
          padding: 60px 50px;
        }
        .bg-grey{
          background-color: #f6f6f6;
        }
        .logo-small{
          color: #000000;
          font-size: 50px;
        }
        .logo{
          color: #000000;
          font-size: 200px;
        }
        @media screen and (max-width: 768px){
          .col-sm-4 {
          text-align: center;
          margin: 25px 0;
        }
        .fa-angle-down{
          color: #4D5061;
        }
        footer{
          height:10vh;
        }
    </style>
  <body>
        <header>
          <div id="logo">
            <img src="http://placehold.it/60x60" alt=""></div>
          <nav>
              <ul>
                <li><a href="#">Home</a></li>
                <li><a href="#">About Me</a></li>
                <li><a href="#">Units</a></li>
                <li><a href="#">Clients</a></li>
                <li><a href="#contact-me">Contact Me</a></li>
              </ul>
          </nav>
        </header>
        <section class="section1">


            <div class="hero"></div>

            <i class="fa fa-angle-down" style="font-size:100px;"></i>

        </section>
        <section class="section2">
            <div class="banner">
                <h1>What I can offer you</h1>
                <p> Feel free to contact me regarding any  </p>
                <div class="container-fluid text-center">
                    <div class="row">
                        <div class="col-sm-4">
                             <span class="glyphicon glyphicon-off logo-small"></span>
                             <h4>Availability</h4>
                             <p>You can expect a response with 24 hours of the sent message. </p>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <section id="contact-me" class="contact_section">

        </section>
  </body>
  <footer>
  </footer>
</html>
  • Everybody's saying "you must use this" or "you must use that" — my multi-level drop-down menus & submenus do not use bootstrap or jquery, or any javascript at all ... they are pure HTML & CSS. Seeing that you're already using bootstrap, that would be easier than my "pure" form; I'm just pointing out that there is no single "must use" method to do this. – Stephen P Mar 03 '17 at 01:31

3 Answers3

1

You can use bootstrap to solve that problem and then apply your css to this bootstrap code.

<!DOCTYPE html>
<html>
<head>
    <title>Liam Docherty | London Web Developer &amp; GFX designer</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
</head>

<body>

    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#"><img src="http://placehold.it/60x60" alt=""></a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li><a href="#">Home</a></li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About Me<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="#">1</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                        </ul>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Units<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="#">1</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Clients</a></li>
                    <li><a href="#">Contact Me</a></li>
                </ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>

    <script src="jquery-3.1.0.min.js"></script>
    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>
</html>

Just remember to change the <script src="jquery-3.1.0.min.js"></script> for your jquery file.

Daniela Muniz
  • 123
  • 1
  • 10
  • First, you can see that the sorce of my script is comming from a file in my computer, so you can download it on yours and reference it on your code. You can download it on this [link](https://jquery.com/). Then you can notice that boostrap has it own style, so you have to overwrite whatever you want. If it is not working you can inspect the element on the browser with `ctrl+F12` to see what property the element of you navbar is getting. If the boostrap is overwriting yours, not the other way around, you can add `!important` to your css property like: `color:blue !important;` – Daniela Muniz Mar 03 '17 at 01:29
  • I can't do the work for you. It is a good practice for someone who is starting out. I can help you through doubts that you have on the way. Try and see if that helps: `.navbar-default { background:none; border:none; } .navbar-collapse .navbar-nav li a { color:#FFFFFF; } .navbar-collapse .navbar-nav li a:hover { background:#FF00FF; color:#FFFFFF; } .navbar-collapse .navbar-nav li.active a { background:#FFFF00; } .navbar-collapse .navbar-nav li.active a:hover { background:#FF00FF; color:#FFFFFF; }` This is a css reset for the boostrap theme. I think that will help you – Daniela Muniz Mar 03 '17 at 02:05
  • What I did here was add a `
    ` to nest the nav. Then I added the reset code that I posted on the last comment and with only that I already have the right background-color again. What I would advice you to do is comment the whole css code and go piece by piece adapting the ids and classes until you have your result.
    – Daniela Muniz Mar 03 '17 at 02:11
  • sure, I can help you. – Daniela Muniz Mar 03 '17 at 02:32
  • How did you do it the fisrt time? You get the classes and IDs of each element and see how it works with this new structure. You have half of the work done already with the properties of the "old" css. You are just going to adapt. – Daniela Muniz Mar 03 '17 at 10:19
  • Look, did you write this css code on your own? When you have the selectors ".selector" or "#selector" it means "all the elements with thit class" or "all the elemnts with this ID". Your css is full with classes and IDs that dont exist anymore on this new structure. You have to do some research to find out the meaning of the properties you putt on your css and then adapt to the new structure. – Daniela Muniz Mar 04 '17 at 13:44
0

It looks you are using Bootstrap, so try this code and I don't see bootstrap javascipt file in your code, which you have to link and jQuery of course.

  <ul class="nav nav-tabs">
  ...
  <li role="presentation" class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
      Dropdown <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
      ...
    </ul>
  </li>
  ...
</ul>

Let me know if you still couldn't figure out.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Lukas
  • 310
  • 3
  • 10
  • Hi, I'm new to all of this only recently started and trying to get better. Where can I find the JS and jQuerry files? In addition, I'm not sure how to implement your answer code into mine. Would I have to change my nav bar html? –  Mar 03 '17 at 00:32
  • Hi try this tutorial on w3schools https://www.w3schools.com/bootstrap/default.asp where you should find or information for beginners or use Bootstrap documentation http://getbootstrap.com/getting-started/ focus on Boostrap CDN and here is examples of navbars in bootstrap http://getbootstrap.com/components/#navbar. – Lukas Mar 03 '17 at 00:43
0

TESTED AND WORKING

Here your solution:

<!DOCTYPE html>
<html lang="en">

<html>

<head>
    <title>Liam Docherty | London Web Developer &amp; GFX designer</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<style>
    body {
        margin: 0;
        padding: 0;
    }
    header {
        height: 10vh;
        background-color: #4D5061;
    }
    nav ul {
        list-style-type: none;
        text-align: center;
    }
    nav ul li {
        display: inline-block;
    }
    nav ul li a {
        display: inline-block;
        padding: 3.5vh 8px 4px;
        color: white;
        text-decoration: none;
        font-size: 14pt;
        font-family: 'Roboto', sans-serif;
    }
    nav ul li:hover a {
        text-decoration: none;
        color: red;
        border-bottom: 1px solid red;
    }
    #logo {
        padding-top: 2vh;
        padding-left: 20px;
        float: left;
    }
    section {
        position: relative;
    }
    .section1 {
        height: 93vh;
        background-color: #FFFFFF;
        text-align: center;
    }
    .section2 {
        height: 93vh;
        background-color: #A59E8C;
        text-align: center;
        color: white;
        padding-top: 23vh;
    }
    .contact_section {
        height: 93vh;
        background-color: grey;
    }
    .hero {
        height: 750px;
    }
    h1 {
        font-family: 'Roboto', sans-serif;
        color: white;
    }
    .container-fluid {
        padding: 60px 50px;
    }
    .bg-grey {
        background-color: #f6f6f6;
    }
    .logo-small {
        color: #000000;
        font-size: 50px;
    }
    .logo {
        color: #000000;
        font-size: 200px;
    }
    @media screen and (max-width: 768px) {
        .col-sm-4 {
            text-align: center;
            margin: 25px 0;
        }
        .fa-angle-down {
            color: #4D5061;
        }
        footer {
            height: 10vh;
        }
</style>

<body>
        <nav class="navbar navbar-default">
            <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#"><img src="http://placehold.it/60x60" alt="Your Brand Name"></a>
                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                            <li><a href="#">Home</a>
                            </li>
                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">About Me <span class="caret"></span></a>
                                <ul class="dropdown-menu">
                                    <li><a href="#">Action</a>
                                    </li>
                                    <li><a href="#">Another action</a>
                                    </li>
                                    <li><a href="#">Something else here</a>
                                    </li>
                                    <li role="separator" class="divider"></li>
                                    <li><a href="#">Separated link</a>
                                    </li>
                                    <li role="separator" class="divider"></li>
                                    <li><a href="#">One more separated link</a>
                                    </li>
                                </ul>
                            </li>
                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Units <span class="caret"></span></a>
                                <ul class="dropdown-menu">
                                    <li><a href="#">Action</a>
                                    </li>
                                    <li><a href="#">Another action</a>
                                    </li>
                                    <li><a href="#">Something else here</a>
                                    </li>
                                    <li role="separator" class="divider"></li>
                                    <li><a href="#">Separated link</a>
                                    </li>
                                    <li role="separator" class="divider"></li>
                                    <li><a href="#">One more separated link</a>
                                    </li>
                                </ul>
                            </li>
                            <li><a href="#">Clients</a>
                            </li>
                            <li><a href="#contact-me">Contact Me</a>
                            </li>
                        </ul>
                      </div><!-- /.navbar-collapse -->
                    </div><!-- /.container-fluid -->
        </nav>


    <section class="section1">


        <div class="hero"></div>

        <i class="fa fa-angle-down" style="font-size:100px;"></i>

    </section>
    <section class="section2">
        <div class="banner">
            <h1>What I can offer you</h1>
            <p> Feel free to contact me regarding any </p>
            <div class="container-fluid text-center">
                <div class="row">
                    <div class="col-sm-4">
                        <span class="glyphicon glyphicon-off logo-small"></span>
                        <h4>Availability</h4>
                        <p>You can expect a response with 24 hours of the sent message. </p>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <section id="contact-me" class="contact_section">

    </section>
    <script   src="https://code.jquery.com/jquery-3.1.1.js"   integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA="   crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</body>
<footer>
</footer>
</html>

You miss the javascript files and some code as well... Next time refere to http://getbootstrap.com and try to read all the documentation. Everything is super well documented there.

Also, if I can advice you, use an external css file to store your style...

mungle
  • 30
  • 2
  • 9
  • My original CSS doesn't show when I use the coding above? any chance you help me adapt the code so it has my original CSS and drop down menu with bootstrap? I think the bootstrap styling sheet could be the issue? –  Mar 04 '17 at 01:48
  • Delete overflow: hidden in your css... please vote my answer as it was the first right answer posted... – mungle Mar 04 '17 at 06:40