I’ve been stuck on the portfolio project for a few days now and I don’t really know what I’m doing wrong.
I created a navbar heading and I want it to go across the top of the page when it’s in a desktop browser, but when it gets smaller, I want it to collapse. I don’t know much about the navbar heading, so I looked it up and I found some simple code that appears to work. The one problem is that it won’t toggle when it’s compressed. I checked and re-checked the code many times over but I can’t seem to find where my problem lies. I know that I can use jQuery to solve the problem, but I would rather learn how to do it in bootstrap (this time).
Also, I took out the col commands in my code, because I couldn’t seem to get them to do what I wanted to do. I used float left and right and it works, but could someone tell me how I would get an image and text to do the same thing with the col commands? I tried using the
Anyway, here is my pen for what I have so far.
Pen didn’t work, so I’m pasting the code
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Portfolio</title>
<link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Jonathan <small>English Teacher</small></a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="#Jonathan">Jonathan</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#info">Info</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<div class="container">
<div class="row">
<div >
<img id="myImage" class="float-left profilePic img-circle" src="http://i105.photobucket.com/albums/m224/jonobugs/Itoshima.jpg" style="height: 100px" alt="profile shot"/></a>
<h2>Jonathan Hamelin</h2>
<h3>Work hard, play harder.</h3>
</div>
</div>
</div>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>
</body>
</html>
**css code:**
body {
margin-top: 60px;
background-color: cornsilk;
}
.navbar {
background-color: darkgreen;
color: blue;
}
.navbar-brand {
line-height:12px;
padding-top:20px;
padding-bottom:5px;
}
.navbar-brand small {
display:block;
font-size:10px;
}
h2 {
float: right;
text-align: center;
vertical-align: top;
width: 60%;
line-height: 1em;
}
h3 {
float: right;
text-align: center;
vertical-align: top;
width: 60%;
font-style: italic;
font-size: 1.2em;
line-height: 1.2em;
}
#myImage {
position: absolute;
float: left;
}
Thanks for any help!
Jonathan