Just currently working on my site and using bootstrap to help me as i was told it was a great framework to use. Anyway i am currently having a problem putting text in the header and positioning it in the right place.
My html code:
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class = "Text">
<a class="navbar-brand" href="#">
<h1>Text1</h1>
<h2>Text2</h2>
<h3>Joruney</h3>
<p>Starting to work around here</p>
</a>
</div>
</div>
<div class="navbar-collapse collapse">
<ul class = "nav navbar-nav navbar-right">
<li class="active">Home</li>
<li>About</li>
<li class="dropdown">
Text<b class="caret"></b>
<ul class="dropdown-menu">
<li>Text1</li>
<li>Text2</li>
<li>Text3</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
CSS:
.navbar-default {
background-color: #760003;
padding: 30px;
}
.Text h1 {
font-family: "Times New Roman", Georgia, Serif;
font-size: 59px;
margin-top: -30px;
float: left;
padding-left: 10px;
}
.Text h2 {
font-family: "Times New Roman", Georgia, Serif;
font-size: 65px;
margin-top: 7px;
margin-bottom: -25px;
margin-top: -22px;
padding-right: 6px;
float: left;
}
.Text h3 {
font-family: "Times New Roman", Georgia, Serif;
font-size: 44px;
margin-top: -17px;
padding-top: 0px;
float: left;
}
.Text p{
font-family: 'Open Sans', sans-serif;
font-size: 16px;
margin-top: 35px;
float: left;
}
So i am trying to ahive by getting it to look like:
Text1 Text2 Text 3
Starting to work around here
However what its actually looking like is:
Text1 Text2 Text3
Starting to work around here
I cant get the p tag to move under it. Now i tried to use position: absolute; however when i resize the page its not mobile friendly at all. It looks awful but i can get it in the right place.
Could anyone help me with this problem so that i can get the text to go under the three text headers and when it resizes it will all stay in that same block and never move but just get smaller?
Thanks for all the help
To give an example of what i was trying to get
Example
U an see Text 1 Text 2 and Text3 are there
and then the p tag is below.
Okay I have created what you have asked for, you should look at the CSS properties text-align and display
I have created a ul with three li
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class = "Text">
<a class="navbar-brand" href="#">
<ul>
<li>test</li>
<li>test</li>
<li>test</li>
</ul>
<h6>This is below</h6>
</a>
</div>
</div>
<div class="navbar-collapse collapse">
<ul class = "nav navbar-nav navbar-right">
<li class="active">Home</li>
<li>About</li>
<li class="dropdown">
Text<b class="caret"></b>
<ul class="dropdown-menu">
<li>Text1</li>
<li>Text2</li>
<li>Text3</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
CSS:
.navbar-default {
background-color: #760003;
padding: 20px;
}
.Text ul {
font-size: 20px;
margin-top: -30px;
margin-left: 0;
margin-bottom: 0;
list-style: none;
padding: 0;
text-align: center;
}
.Text ul li {
display: inline-block;
}
.Text h6 {
margin-top: 0;
font-size: 26px;
text-align: center;
}
This was done very fast to give you an idea of how to do it, you should look at the Bootstrap Documentation and learn about the CSS positioning
https://getbootstrap.com/components
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference
Related
I'm trying to center my menu list items in the bootstrap navbar. I've tried with the many CSS styles but it is still in the left.Below is my html and css please correct me if I'm wrong with the css.[To be more specific what I want is I want those menu items right below the Logo.][1]
<div class="header-botom">
<div class="content white">
<nav class="navbar navbar-default nav-menu" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="clearfix"></div>
<!--/.navbar-header-->
<div class="collapse navbar-collapse collapse-pdng" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav nav-font">
<li>Home</li>
<li>Ear Rings</li>
<li>Jewelry </li>
<li>Accessories</li>
</ul>
<div class="clearfix"></div>
</div>
<!--/.navbar-collapse-->
<div class="clearfix"></div>
</nav>
<div class="clearfix"></div>
</div
>
</div>
.nav-menu{
background: transparent;
border-radius: 0;
border: 0;
margin-top: 6px;
}
.navbar .{
text-align:center;
}
.navbar-nav li{
float: none;
display: inline-block;
}
[1]: https://i.stack.imgur.com/wxHSz.png
What you looking for is to add these css properties.
.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}
.navbar .navbar-collapse {
text-align: center;
}
Possible Duplicate of this question.
JS Bin here
Add the following class in your custom css:
.navbar-nav {
text-align: center;
}
Demo:
.nav-menu {
background: transparent;
border-radius: 0;
border: 0;
margin-top: 6px;
}
.navbar . {
text-align: center;
}
.navbar-nav li {
float: none;
display: inline-block;
}
.navbar-nav {
text-align: center;
background: #e4e4e4;
}
<div class="header-botom">
<div class="content white">
<nav class="navbar navbar-default nav-menu" role="navigation">
<div class="collapse navbar-collapse collapse-pdng" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav nav-font">
<li>Home</li>
<li>Ear Rings</li>
<li>Jewelry </li>
<li>Accessories</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="clearfix"></div>
</nav>
<div class="clearfix"></div>
</div>
</div>
yes its seems like i got the solution for your problem, if you are using bootstrap
add the class into your custom css file
.collapse-pdng { padding: 0px 0px; margin: 0 auto; width: 32%; }
add the following class in your html file
<div class="text-center">
<div class="collapse navbar-collapse collapse-pdng" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav nav-font">
<li>Home</li>
<li>Ear Rings</li>
<li>Jewelry </li>
<li>Accessories</li>
</ul>
<div class="clearfix"></div>
</div>
</div>
add the class text-center in div and put your whole menu in that class, i hope this will help you, please let me know
Edit #1: Here's a picture of the issue:
Edit #2: Here's a picture after I use the brand class
Edit #3:
I'm trying to float an image beside a navbar. It works until I have the navbar 100% width. Then the navbar goes below the image.
Here's my HTML:
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img alt="Brand" class="pull-left" src="Images/logo.png">
</a>
</div>
<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar"></span>
</button>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav">
<li>Home</li>
<li>Internet</li>
<li>Phone</li>
<li>Android TV</li>
<li>Shaw Direct</li>
<li>Contact Us</li>
</ul>
</div>
</div>
</nav>
And here's my CSS:
.Navlinks {
font-size: 24px;
color: white;
padding-top: 50%;
vertical-align: middle;
}
.Navlinks:hover {
color: white;
}
.Navlinks:focus {
color: white;
}
.navbar-default {
background-color: #00AEFE;
height: 89px;
}
.nav.navbar-nav li a{
color: white;
font-size: 18px;
}
Is there a way to make sure these two can float side by side?
There's an example in official docs:
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img alt="Brand" src="...">
</a>
</div>
</div>
</nav>
https://getbootstrap.com/components/#navbar-brand-image
This answer is based on #Serg Chernata answer
Your logo must be transparent and if it's so bigger than what you want, maybe a css style width or height to <img> tag is needed. something like navbar-brand > img {height: 40px;}
also you should move <button> into <div class="navbar-header"> to right positioning of navbar toggle button in mobile devices.
.Navlinks {
font-size: 24px;
color: white;
padding-top: 50%;
vertical-align: middle;
}
.Navlinks:hover {
color: white;
}
.Navlinks:focus {
color: white;
}
.navbar-default {
background-color: #00AEFE;
height: 89px;
}
.nav.navbar-nav li a {
color: white;
font-size: 18px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img alt="Brand" class="pull-left" src="Images/logo.png">
</a>
<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav">
<li>Home
</li>
<li>Internet
</li>
<li>Phone
</li>
<li>Android TV
</li>
<li>Shaw Direct
</li>
<li>Contact Us
</li>
</ul>
</div>
</div>
</nav>
<body>
<div class="sts-viewport-fill">
<nav role="navigation" class="nav navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button data-toggle="collapse" data-target=".navbar-collapse" type="button" class="navbar-toggle">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">Knonet</span>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href=#>Log In</a></li>
<li><a href=#>Sign Up</a></li>
<li><a href=#>Help</a></li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<h1 class="text-center">CONNECT WITH EVERYONE.<br>
<small>Knonet aims to connect the whole world with the Internet.</small>
</h1>
</div>
</div>
<div class="container sts-second-slide">
Salut, et Bonjour!
</div>
</body>
That there's my HTML. I've applied a bunch of CSS rules like so:
body {
font-family: 'Source Sans Pro', 'Segoe UI Light', sans-serif;
font-weight: initial;
font-weight: 100;
}
.sts-viewport-fill {
position: absolute;
top:0;right:0;bottom:0;left:0;
background-color: #000000;
color: #ffffff;
}
.sts-viewport-fill .container-fluid h1 {
margin: 250px auto 100px auto;
font-weight: 900;
}
.navbar-collapse, nav [type="button"] {
border: none !important;
border-radius: 0%;
}
.sts-second-slide {
margin-top: 100px;
}
As far as I'm concerned, this makes the div.sts-viewport-fill fit the entire viewport of the screen, or at least what's left of it.
The problem? See all that French there? Salut, et Bonjour!?
It does not appear in the browser. Observe:
Can somebody tell me what's going one here? I have a really strong feeling this has something to do with the position: absolute; and top:0;bottom:0; rules.
Merci d'Avance!
PS: Even if I apply a color: #fff; attribute to the .sts-second-slide selector, I still don't get a result.
You have to add position to that element.
Try
.sts-second-slide {
margin-top: 100px;
position: relative;
}
I want to fix the logo on the navigation bar , I want to either increase the height of navigation bar and fix it without adjusting the image size amd When i shrink the website to mobile view , The Logo is seen below the collapse button .
Preview of the website (http://threeguys.us/works/testing.html)
testing.html
<div class="jumbotron">
<div class="container">
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="images/logo/logo.png" width="250px" height="60px"></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li class="active">Home</li>
<li>Rates</li>
<li>Employee</li>
<li>Contact Us</li>
</ul>
</div>
</div>
</nav>
<div class="call_button">
<button type="button" class="btn btn-default">call us</button>
</div>
</div>
</div><!--jumbotron end-->
style.css
.jumbotron
{
text-align: center;
background-size: cover;
background-image: url(images/car/car.png);
}
.container
{
padding:0px;
}
.navbar
{
height: 60px;
background-color: transparent;
border:0px;
padding-top: 0px;
}
.navbar-header
{
width:70px;
background-color: transparent;
}
ul
{
padding:0;
}
.call_button
{
margin-top : 428px;
}
.content
{
background-color: white;
padding-top:0px;
}
.footer-nav
{
text-align: center;
}
.text_order
{
background-image: url(images/text_order/rectangle.jpg);
text-align: center;
padding: 5px;
}
.text_order p
{
font-size: 20px;
}
.footer-nav li
{
display: inline;
}
.footer-nav li a
{
padding-left: 50px;
text-decoration: none;
color: #f7ab00;
}
.footer-nav li a:hover
{
color:black;
}
Based on your question, comments and screenshots here are the following recommendations:
Remove this CSS code from style.css so collapse button is on the right (and not above the logo):
.navbar-header {
width:70px;
background-color: transparent; //don't necessarily need to remove this one but it isn't serving a purpose currently
}
To get the nav outside of the jumbotron whilst keeping the full image screen, perform the following updates:
Update testing.html to the following:
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="images/logo/logo.png" width="250px" height="60px"></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li class="active">Home</li>
<li>Rates</li>
<li>Employee</li>
<li>Contact Us</li>
</ul>
</div>
</div>
</nav>
<div class="jumbotron">
<div class="container">
<div class="call_button">
<button type="button" class="btn btn-default">call us</button>
</div>
</div>
</div><!--jumbotron end-->
Update your style.css jumbotron class and navbar class to the following:
.jumbotron {
text-align: center;
background-size: cover;
background-image: url(images/car/car.png);
margin-top: -80px; //include this account for the height of the navbar and it's margin
}
.navbar {
height: 60px;
background-color: transparent;
border: 0px;
padding: 0 120px; //the 120px value will push the logo and menu nav closer together. You will need to update your collapse breakpoints though. Adjust as you see fit.
}
If I haven't answered all your questions please comment below so I can update my answer.
Modify the flow of your HTML. Avoid putting nav inside .container.
Use a structure like this
This will put the logo inside the header as well as put it before the collapse button in mobile view.
Site : http://www.Spotlightdd.co.uk
I have a navbar that has an increased size due to the logo in the middle. The logo has a -margin value to line it up with the bottom border (I know it's out by a few px). What i'm trying to do is move the text down without just increasing the size of the navbar, so it looks more centered in the navbar. Currently, i've tried using margin/padding.line-height, anything i can think of that would only move the text to no avail. If someone could try a hand at sorting it, that would be brilliant.
Thanks
(Navbar html)
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img alt="CompanyLogo" src="img/spotlightLogo.png" style = "height: 80px" >
</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav nav-center">
<li> HOME </li>
<li> WEB DESIGN</li>
<li> GRAPHIC DESIGN </li>
<li> SOCIAL MEDIA </li>
<li class = "logo"> <img src = "img/spotlightLogo.png" class = "headerLogo img-responsive" alt = "spotlight" style = "height: 150px;"></li>
<li> PRINTING </li>
<li class="active"> BRANDING </li>
<li> VIDEO PRODUCTION </li>
<li> CONTACT </li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
(Navbar CSS)
.navbar-default {
border-bottom: 3px solid #CE1344;
background-image: none;
background-color: white;
}
.navbar .navbar-nav {
text-align: center;
display: inline-block;
float: none;
vertical-align: top;
}
li > a {
margin-top: 0px;
}
.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}
.navbar .navbar-collapse {
text-align: center;
}
.headerLogo {
margin-bottom: -50px;
}
I tried to put in every bit of code relevant. Apologies because the css file is a mess at the moment.
Try adding this to your css:
.navbar-nav>li{
padding: 20px 0;
}
.navbar-nav>li.logo{
padding: 0
};
This should do the trick.
Try this:
.nav-center{
position: relative;
top: 20px;
}
li.logo {
position: relative;
bottom: 22px;
}