Logo in BootStrap navbar-brand class behaving weridly - html

I am designing a responsive HTML page using bootstrap css. I am using the navbar-brand class in which there is a logo. The code for that segment is:
<div class="grad">
<a class="navbar-brand" id="navbar-logo" href="http://someUrl"><img src="images/someLogo.gif" height="43" alt="logo"></a>
<div>
<ul class="nav navbar-nav mycss-aligned">
<li><span class="name">LastName, FirstName</span></li>
<li><span class="logo1">some</span><span class="logo2">Stuff</span></li>
</ul>
</div>
</div>
That mycss-aligned is just a few dimensions for the list below it and is not relevant to our problem so I am not sharing it. The relevant CSS from BootStrap has been slightly modified by me to suit my needs and it is as follows:
.navbar-brand {
float: left;
height: 60px;
padding: 10px 10px;
font-size: 18px;
line-height: 20px;
}
.navbar-brand>img {
-o-object-fit: contain;
object-fit: contain;
max-height: 100%;
height: 100%;
max-width: 100%;
width: auto;
margin: 0 auto;
margin-left:125%;
margin-top:-5%;
}
I have a HTML div which is center aligned and has 60% width of total screen. I am trying to match the start of the division with the start of the logo. While I can achieve this, as you can see, I am required to use an unusually high percentage for the margin-left value in .navbar-brand>img. That being said, Even when I can achieve that, the design is barely responsive and the logo does not slide across along with the division when the page is resized. The funny thing is
<div>
<ul class="nav navbar-nav mycss-aligned">
<li><span class="name">LastName, FirstName</span></li>
<li><span class="logo1">some</span><span class="logo2">Stuff</span></li>
</ul>
</div
is perfectly responsive. What can I do to solve this?

First I would suggest that you use more of the bootstrap components to create a context for the elements you want to use. E.g. there is a navbar-fixed-top class.
You can see my fork of the code on jsfiddle There is an outline on all divs to visualise the alignment.
Here is how I would write the same
<header>
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-content">
<a class="navbar-brand" id="navbar-logo" href="http://someUrl">
<img src="images/someLogo.gif" height="43" alt="logo">
</a>
<ul class="navbar-list">
<li><span class="name">LastName, FirstName</span>
</li>
<li><span class="logo1">Some</span><span class="logo2">Stuff</span>
</li>
</ul>
</div>
</div>
</div>
</header>
<main>
<div class="container">
<div style="width: 60%; margin:0 auto; text-align:justify;">
<br>
<br>
<br>
<br>
<br>
<br>This is just some uberRandom text to show how the division is getting aligned and justified
</div>
</div>
</main>
And the re-written css
.navbar {
background: linear-gradient(white, grey);
box-shadow: 0 0 10px #333;
}
.navbar-content {
width: 60%;
margin: 0 auto;
font-size: 13px;
line-height: 17px;
}
.navbar-list {
float: right;
margin-top: 5px;
}
.navbar-brand {
padding: 0;
}
.navbar-brand>img {
-o-object-fit: contain;
object-fit: contain;
max-height: 100%;
height: 100%;
max-width: 100%;
padding-top: 10px;
margin: 0 auto;
}
Notice how there is an inner content of the navbar that is set to same width as the actual content (the paragraph). That way you don't have to use those silly margins and the image and text should align.

Related

How to make two lines on either side of the navigation bar?

I would like the navbar to look like this, with two horizontal lines on either side of the navbar.
html code:
<div id="navbar">
<div id="navbar-links">
<a class="active" href="#home">HOME</a>
ABOUT
WORKS
CONTACT
</div>
</div>
Depending on exactly what the surrounding CSS is, but given just the HTML in the question, you could put a line as background to the whole navbar using a linear-gradient and blank it out under the actual links by giving that a white background.
#navbar {
background-image: linear-gradient(transparent 0 49%, blue 49% 51%, transparent 51% 100%);
position: relative;
rdisplay: inline-block;
margin: 0 1vw;
display: flex;
justify-content: center;
}
#navbar-links {
background: white;
padding: 0 2vw;
}
#navbar-links a{
color: gray;
text-decoration: none;
}
<div id="navbar">
<div id="navbar-links">
<a class="active" href="#home">HOME</a>
ABOUT
WORKS
CONTACT
</div>
</div>
You will need to play around with the padding or margins to get the spacing that you want.
I am not sure what you want exactly but I tried to follow the image with the html you provided. This method uses two spans, one before and one after the links. You can adjust the font sized and sizes/colours of the lines as you please.
This will appear differently if you are using Bootstrap.
.left, .right{
flex-grow: 1;
background: linear-gradient(lightskyblue, lightskyblue);
background-position: 0% 50%;
background-size: 100% 2px;
background-repeat: repeat-x;
}
#navbar-links>a{
color:black;
float: left;
text-decoration: none;
width: 25%;
text-align: center;
}
<div id="navbar" style="width:95%;display: flex;margin: 40px auto;">
<span class='left'></span>
<div id="navbar-links" style="width:65%; padding: 0 5px">
<a class="active" href="#home">HOME</a>
ABOUT
WORKS
CONTACT
</div>
<span class='right'></span>
</div>
</h3>

Contain navbar links to content container when resizing window

I have a bootstrap navbar that I need to span the entire width of the screen, but have the logo and link at the right stay the consistent width of the container below it, as illustrated below, and not have the LINK on the right jump to the logo and logo shoved to the left below 768px when shrunk down:
[=============LOGO------------------------------------------LINK=============]
| |
| |
| |
When the user downsizes the screen, the navigation items should remain inline with the content below.
<nav class="navbar navbar-default">
<ul class="nav nav-justified centered">
<li><img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" width="140" height="40">
</li>
<li><a class="getapp" href="#">LINK</a>
</li>
</ul>
</nav>
<div class="container">
CONTENT
</div>
.navbar {
background-color: #000;
}
.centered {
width:100%;
margin:0 auto;
}
.nav>li{
display:table-cell;
}
JSFIDDLE: LINK
I found a simple solution by setting the outer div of the nav and the content container to use .inside which contains the nav and content to the same width. When the window is resized, the navigation and page content grow and shrink at the same rate.
<nav>
<div class="inside">
<div class="logo">
<img src="logo.png">
</div>
<div class="links">
<img src="image.png">
</div>
</div>
nav{
position: fixed;
top: 0;
height: 70px;
width: 100%;
background: #000;
z-index: 99999;
}
.logo{
float: left;
padding-top: 15px;
}
.links{
float: right;
line-height: 50px;
padding-top: 20px;
padding-right: 15px;
}
.inside{
width: 90%;
margin: 0 auto;
}

How do I get top/bottom spacing to be responsive?

I'm trying to finish up my portfolio page right now. Having an issue getting the top/bottom padding spacing to stay the same on 24" and 13". As you can see from the images below, the 24" inch currently looks how I want it to, with all my elements on the right side directly in the middle. When it becomes 13", the spacing is off and the elements aren't centered. How do I fix this?
24" - http://i988.photobucket.com/albums/af6/jtbitt/jay-portfolio-24-inch-spacing_zpsenaqpzp4.png
13" - http://i988.photobucket.com/albums/af6/jtbitt/jay-portfolio-13-inch-spacing_zps45ygidew.png
HTML FRONT PAGE -
<body ng-app="jayPortfolio">
<!-- NAVBAR -->
<header>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="/">JAY BITTNER</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>ABOUT</li>
<li>PORTFOLIO</li>
<li>EXPERIENCE</li>
<li>CONTACT</li>
</ul>
</div>
</div>
</nav>
</header>
<!-- LOAD OTHER PAGES HERE -->
<main>
<div id='ng-view' ng-view></div>
</main>
</body>
HTML FRONT PAGE PARTIAL -
<section id="about" ng-controller="aboutController">
<div class="container-fluid">
<div class="row">
<div class="about-left col-lg-6 col-md-6 col-sm-12 col-xs-12">
</div>
<div class="about-right col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="about-content">
<div class="about-content-title">
<h1><strong>I'M JAY.</strong></h1>
</div>
<br />
<div class="about-content-info" ng-model="about.firstParagraph">
<p ng-if="about.firstParagraph"><strong>An entrepenurial minded, Full Stack Developer. Whenever I'm up against a challenge that I care about, it gives me a rush. Focusing on the big picture is important to me, but I never forget the smaller details. Anything that is not challenging is boring, and makes me yawn. Anything that is seemingly impossible interests me a lot. I'm ready to get to work.</strong></p>
<p ng-if="!about.firstParagraph"><strong>Currently seeking a Javascript position, using the MEAN stack, in New York City. Being innovative, ambitious, and hard working are values that are very important to me. I want to join a company that has similar values and has goals of reaching ridiculous levels of success, not just modest realistic ones. I love working with a solid team.</strong></p>
</div>
<br />
<div class="about-button">
<button ng-if="about.firstParagraph" class="label label-success" ng-click="about.switchParagraph()"><strong>MORE =></strong></button>
<button ng-if="!about.firstParagraph" class="label label-success"><strong>VIEW PORTFOLIO</strong>
</div>
<br />
<div class="about-personal-info">
<h4><strong>Email: jaybittner#gmail.com</strong></h4>
<br />
<div class="about-icon" ng-repeat="profile in about.profiles">
<img src="{{ profile.icon }}" />
</div>
</div>
</div>
</div>
</div>
</div>
</section>
CSS -
#about {
height: 100%;
width: 100%;
background-image: -webkit-gradient(linear,left top,right bottom,color-stop(0.12, #061419),
color-stop(0.61, #36875F)
);
background-repeat: no-repeat;
}
#about .container-fluid, #about .container-fluid .row {
height: 100%;
width: 100%;
}
.about-left {
height: 100%;
background-image: url('../../images/jay-ocean.jpg');
background-repeat: no-repeat;
background-position: 0 100%;
border-right: 3px solid black;
}
.about-right {
width: 50%;
height: 100%;
}
.about-content {
width: 50%;
height: 100%;
margin: 0 auto;
padding-top: 20%;
padding-left: 5%;
text-align: center;
}
.about-content-title h1{
font-size: 3.4vw;
}
.about-content-info p {
font-size: 1vw;
word-spacing: 0.3vw;
}
.about-button button {
color: gray;
border: 1px solid black;
background-color: black;
}
.about-button a {
color: gray;
}
.about-personal-info h4 {
font-size: 1vw;
word-spacing: 0.3vw;
}
.about-icon {
display: inline;
word-spacing: 0.3vw;
}
.about-icon img {
width: 30px;
height: 30px;
border-radius: 10px;
border: 1px solid black;
}
Your problem seems to be in the navigation bar, where there is a solid container, when your page content lies in container-fluid.
It's hard for me to throw a straight off working code for you by now, but your issue is the placement of your navbar-brand. You could try to center it or adjust it's position via padding or margin in media queries.
To do so, put this in your CSS:
#media (max-width: 1199px)
{
.navbar-brand {
padding-left: 100px;
}
}
The max width in media query calculates the screen viewport and changes the appearance of the site for something desired by the exact width or height of the page on screen.
With max-width: 1199px this media query uses this padding-left attribute to .navbar-brand when the screen (or the browser window) is showing the page below this width.
You can also work around with this to use with min-width or even height related viewport settings in CSS.

2 divs in one row with max-width

I have 2 divs I want to show in one line when browser resizes. On all screens it will show in one line, but now it breaks in second line when browser resizes.
HTML
<div class="navbar" id="navbar">
<a href="#" class="logo">
<img src="logo.png">
</a>
<div class="topnav-con">
<div class="menu-top-menu-container">
<ul class="nav-menu" id="menu-top-menu">
<li>nav 1</li>
<li>nav 2</li>
</ul>
</div>
</div>
</div>
CSS
.navbar {
.max-width: 1310px;
}
.logo {
float: left;
margin-left: 20px;
margin-right: 25px;
}
.topnav-con {
-moz-box-sizing: border-box;
background: none repeat scroll 0 0 #7A9CBD;
clear: none;
float: left;
max-width: 1203px;
width: 100%;
}
Don't keep the width of the .topnav-con as 100%.
Keep some ratio between both class .topnav-con and .logo
.logo{
width: 20%;
}
.topnav-con{
width: 80%;
}
But it's not preferable while displaying navbar. Keep the ratio till some min-width: 600px.
Then break the menu into next line.

How can I use Responsive Design principles to fix this screen size issue?

For a project of mine I decided to start using Responsive Design. The guide I was using wasn't definitive and purely introductory so I got lost somewhere there and can't find the problem here. If use the code below you'll render yourself a navigation menu. It looks fine on a 13 inch screen but go to a smaller screen size by perhaps shortening the width of your browser you'll notice that the navigation menu will take over the logo's space. How can I tweak this so that the navigation menu won't be on top of the logo and perhaps will stop before it goes over the logo?
HTML:
<header class="bar_top">
<div class="logo_block">
<a href="index.php">
<img alt="Logo" src="/logo.png" class="logo">
</a>
</div>
<nav class="menu_above">
<ul class="menu">
<li class="menu_inner">Home</li>
<li class="menu_inner">Our Products</li>
<li class="menu_inner">Services</li>
<li class="menu_inner">About Company</li>
<li class="menu_inner">Contact
<ul class="menu_layer">
<li class="menu_contact_is"><a class="menu_contact_inner" href="#">Menu 1</a>
</li>
<li class="menu_contact_is"><a class="menu_contact_inner" href="#">Menu 2</a>
</li>
<li class="menu_contact_is"><a class="menu_contact_inner" href="#">Menu 3</a>
</li>
</ul>
</li>
<span class="phone_us">000-000-0000</span>
</ul>
</nav>
</header>
CSS:
.bar_top {
background-color: #FFFFFF;
font-size:14.5px;
width: 100%;
height: 82px;
top: 0;
left: 0;
position:absolute;
z-index: 99;
}
.logo_block {
display: block;
position: absolute;
z-index: 998;
}
.logo {
margin-left: 30px;
margin-top: -3px;
height: 85px;
}
.menu_above {
width: 960px;
margin: 40px auto;
float:right;
}
.menu_layer {
margin-left: -40px;
}
.menu_contact_is {
color: #ffffff !important;
}
a.menu_contact_inner {
color: #ffffff !important;
}
.phone_us {
font-size: 1.5625em;
margin-left: 75px;
}
Try the attribute margin: auto; to set elements on the center of the screen or the container, instead of using static values to position the elements
Also you can read about flexible design and responsive design to learn about.
If you are trying to keep the menu next to the logo on the left side of the page you should try this:
.logo_block {
display: inline-block;
vertical-align: top;
}
.menu_above {
margin: 40px auto;
display: inline-block;
}
It's quite common to wrap the content with a div container that has a fixed with and auto margin on the sides to keep it on the center of the page.
You should also consider to revise the other elements on you page as you are using unnecessary relative positioning. ;)