Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Roland Hagan
6,443 Pointsflexible navbar
Merry Christmas Everyone. I need help with the navbar in my website. I want it to be responsive to different screen sizes, resolutions and to support different browsers. Thanks in advance to those who attempt to answer this question.
Below is my html code and css code.
<!DOCTYPE html>
<html lang="en">
<head>
<title> </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bootstrap.css"/>
<link type="text/css" rel="stylesheet" href="stylesheet2.css"/>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<ul class="navbar-left">
<li><a href="dashboard.html"><img src="homeicon1(2).png"></a></li>
<li><a href="settings.html"><img src="machineicon1(2).png"></a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="helpdocs.html"><img src="helpicon1.png"></a></li>
<li><a href="#"><img src="powerbutton1(2).png"></a></li>
</ul>
<a class="navbar-brand" href="#">
<img alt="#" src="munchlogoweb(1).png">
</a>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-md-3">
<a href="createoffer.html"><img src="createoffericon(1).png"></a>
<div class="text1"><a href="createoffer.html">Create Offer</a></div>
</div>
<div class="col-md-3">
<a href="stats.html"><img src="statsicon(1).png"></a>
<div class="text2"><a href="stats.html">Stats</a></div>
</div>
<div class="col-md-3">
<a href="settings.html"><img src="settingsicon(1).png"></a>
<div class="text3"><a href="settings.html">Settings</a></div>
</div>
<div class="col-md-3">
<a href="help.html"><img src="helpicon.png"></a>
<div class="text4"><a href="help.html">Help</a></div>
</div>
</div>
</div>
</body>
</html>
CSS:
body {
background-color: #FFFFFF;
}
.navbar-fixed-top {
width: 100%;
height: 56px;
background-color: #FF3F34;
margin-top: -8px;
margin-left: -10px;
}
.navbar li {
display: inline;
}
.navbar-left {
margin-top: -22px;
}
.navbar-right {
margin-top: -22px;
}
.logo {
display: inline;
}
.logo img {
margin-top: 7px;
margin-left: 235px;
}
.container-fluid {
margin-left: 140px;
}
.col-md-3 {
display: inline;
margin-top: 230px;
}
.text1 a {
text-decoration: none;
font-family: Verdana, sans serif;
font-size: 24px;
color: #333333;
display: inline;
}
.text2 a {
text-decoration: none;
font-family: Verdana, sans serif;
font-size: 24px;
color: #333333;
display: inline;
margin-left: 43px;
}
.text3 a {
text-decoration: none;
font-family: Verdana, sans serif;
font-size: 24px;
color: #333333;
display: inline;
margin-left: 25px;
}
.text4 a {
text-decoration: none;
font-family: Verdana, sans serif;
font-size: 24px;
color: #333333;
display: inline;
margin-left: 45px;
}
1 Answer
Parker Byrd
Courses Plus Student 17,716 Pointsgive your li's widths, and all widths should be in percentages, so that they grow/shrink based on the viewport size.
Roland Hagan
6,443 PointsRoland Hagan
6,443 PointsThanks.