Center Logo and nav bar horizontal - html

How can i center my logo (img) and menu links horizontal. I want the logo to be at the left and menu at right but horizontal centered.
here's my code!
thanks
<div class="menu-container">
<div class="logo">
<img src=https://app.box.com/representation/file_version_186133299510/image_2048/1.png class="logo">
</div>
<nav class="menu">
Branding
Logos
Illustration
Web
Poster
Letters
All
About
</nav>
</div>
<div class="main-intro">
<h2>Let's create something great together!</h2>
</div>
---CSS---
* {
padding: 0px;
margin: 0px;
}
.menu-container{
background-color: gray;
margin: 30px;
position
}
.logo {
height: 10em;
display: inline-block;
padding: 1em;
transition: all 0.6s ease;
-webkit-transition: all 0.6s ease;
}
.menu {
float: right;
margin: 2em; 2em; 0; 0;
display: inline-block;
vertical-align: center;
}
https://codepen.io/Randomood/pen/KmJpWX?editors=1100

try removing the height of your logo from you css?
.logo {
display: inline-block;
padding: 1em;
transition: all 0.6s ease;
-webkit-transition: all 0.6s ease;
}
EDITED:
* {
padding: 0px;
margin: 0px;
}
.menu-container{
background-color: gray;
margin: 30px;
position: relative;
padding: 1em;
}
.logo {
height:10em;
border: 1px solid red;
display: inline-block;
transition: all 0.6s ease;
-webkit-transition: all 0.6s ease;
}
.menu {
float: right;
margin: 4.5em 0em;
display: inline-block;
vertical-align: center;
}

Just try doing this to your "menu-container"
.menu-container{
display:flex;
flex-direction:row;
justify-content:center;
background-color: gray;
margin: 30px;
}
Codepen

Related

How do I remove the horizontal scroll bar from my Navbar

I'm trying to make a responsive site, in which when the width decreases, my nav-links go out of sight, but there is a ***Horizontal Scroll Bar***, that I want to get rid of. I've viewed other question for this, but none of them helped me.
Any Suggestions?
Thank in advance
HTML
<header class="head">
<nav class="navbar">
<div class="logo">
Krishang Sharma
</div>
<ul class="nav-items">
<li>Work</li>
<li>About</li>
<li>Contact</li>
</ul>
<div class="crossMenu">
<div class="line1"></div>
<div class="line2"></div>
</div>
<!-- Theme Toggle Switch -->
<div class="switch">
<div class="bg">
<div class="circle"></div>
</div>
</div>
</nav>
</header>
CSS
.navbar{
width: 100vw;
height: 10vh;
display: flex;
align-items: center;
font-family: 'Poppins', serif;
justify-content: space-evenly;
box-shadow: 0px 15px 20px #1e1e1e;
}
.logo{
width: 40%;
}
.logo a{
color: white;
transition: 0.3s;
font-size: 1.5rem;
text-decoration: none;
}
.logo a:hover{
transition: 0.3s;
color: #639FAB;
}
.nav-items{
width: 40%;
display: flex;
justify-content: space-around;
}
.nav-items, li a{
align-items: center;
height: 100%;
font-size: 18px;
color: white;
list-style: none;
transition: 0.3s;
text-decoration: none;
}
.nav-items a:hover{
transition: 0.3s;
color: #639FAB;
}
.crossMenu{
cursor: pointer;
display: none;
margin-right: 2%;
}
.line1, .line2{
margin: 4px;
height: 4px;
width: 35px;
transition: 0.5s ease;
border-radius: 25px;
background: #639FAB;
}
.switch{
cursor: pointer;
align-items: center;
}
.bg{
height: 20px;
width: 60px;
background: white;
border-radius: 10px;
transition: 0.5s ease;
}
.circle{
right: 5px;
top: -5px;
width: 30px;
height: 30px;
position: relative;
border-radius: 50%;
transition: 0.5s ease;
background: #639FAB;
}
.circleOn{
background: white;
right: -35px;
transition: 0.5s ease;
}
.bgOn{
transition: 0.5s ease;
background: #639FAB;
}
For Lower Resoultion
.nav-items{
right: 15%;
position: absolute;
transition: 0.5s ease;
transform: translateX(200%);
}
Add overflow-x: hidden; to the style= attribute of your navbar.
Why You have used transform: translateX(200%); on .nav-items element?. You should remove/add transform: translateX(0); on .nav-items this element. Then Horizontal Scroll Bar will not show

How to set up media queries in my navbar to make it mobile responsive?

I am trying to get my navbar with my logo on the left and the tabs on the right to be mobile responsive. The viewpoint meta tag drops my logo down below the nav tabs when in mobile view. It also has a scrolling function in javascript. Is it too late for me to go back in and add breakpoints with media queries? Is there an easy fix to this solution? I've tried everything and can not seem to make it work.
.nav_bar {
align-items: center;
position: relative;
height: 80px;
width: 100%;
transition: 0.2s ease;
color: rgb(78, 78, 78);
}
.nav_bar ul li a.active-page {
border-bottom: 1px solid;
}
.nav_bar .nav_ {
margin: 0;
padding: 0;
display: inline-block;
float: right;
margin-right: 5%;
}
.nav_bar .nav_ .item {
list-style: none;
display: inline-block;
font-size: 18px;
padding: 5px;
font-weight: 300;
line-height: 80px;
margin-right: 20px;
transition: 0.5s ease;
}
.nav_bar .nav_ .item a {
text-decoration: none;
color: inherit;
}
.nav_bar .logo {
color: rgb(50, 50, 50);
float: left;
display: inline-block;
margin-top: 10px;
margin-left: 5%;
width: 40px;
height: 40px;
transition: 0.5s ease;
}
.nav_bar img {
height: 40px;
width: 40px;
float: left;
:
}
.scrolled {
background-color: rgba(62, 62, 62, 0.4);
color: white;
transition: 0.5s ease;
}
.scrolled.nav_bar {
height: 50px;
background-color: rgba(62, 62, 62, 0.8);
transition: 0.5s ease;
}
.scrolled.nav_bar .nav_ .item {
line-height: 40px;
transition: 0.5s ease;
}
.scrolled.nav_bar .logo {
float: left;
display: inline-block;
margin-top: 5px;
margin-left: 5%;
width: 40px;
height: 40px;
] transition: 0.5s ease;
}
<div class="nav_bar">
<ul class="nav_">
<li class="item">
<a href="index.html" class='active-page'>Home</a>
</li>
<li class="item">
About
</li>
<li class="item">
Work
</li>
<li class="item">
Contact
</li>
</ul>
<div class="logo">
<img class="logo" src="jhlogogrey.png" alt="">
</div>
</div>
code a specific screen ratio in CSS, and within that block adjust your container’s position, padding and with.

CSS transition hover on parent effect on child

I'm trying to animate inside button but for some reason it won't work. Width of the button should shrink to 0 to the left
HTML
<div class="siteBtnShare">
<div class="share-text-wrapper">
<span class="share-text">SHARE</span>
</div>
</div>
SCSS
.siteBtnShare {
position: relative;
display: inline-block;
font-family: 'Novecentosanswide-Medium';
width: 40px;
transition: width 1s;
overflow:hidden;
.share-text-wrapper{
width: 40px;
display: inline-block;
}
&:hover .share-text-wrapper{
width: 0;
}
}
EDIT: - Inside the button should shrink to 0, but it doesn't do anything. It remains visible
The width does shrink, you just don't see it because the text flows outside of the container:
.siteBtnShare {
position: relative;
display: inline-block;
font-family: 'Novecentosanswide-Medium';
width: 40px;
transition: width 1s;
overflow:hidden;
}
.share-text-wrapper{
width: 40px;
display: inline-block;
overflow: hidden;
}
.siteBtnShare:hover .share-text-wrapper{
width: 0;
}
<div class="siteBtnShare">
<div class="share-text-wrapper">
<span class="share-text">SHARE</span>
</div>
</div>
Working code in SCSS:
.siteBtnShare {
position: relative;
display: inline-block;
font-family: 'Novecentosanswide-Medium';
width: 40px;
transition: width 1s;
overflow:hidden;
.share-text-wrapper{
width: 40px;
display: inline-block;
overflow: hidden;
}
&:hover .share-text-wrapper{
width: 0;
}
}
Try this, without the FontAwesome icon or with, as per your preference.
SCSS
.siteBtnShare {
background: #eee;
display: inline-block;
padding: 10px;
height: 20px;
width: auto;
color: #333;
&:hover {
.share-text-wrapper {
.share-text {
width: 100%;
}
}
}
}
.label {
display: inline-block;
width: 1em;
color: #888;
}
.share-text-wrapper {
display: inline-block;
white-space: nowrap;
margin-left: -1em;
padding-left: 1em;
.share-text {
display: inline-block;
width: 0%;
overflow: hidden;
-webkit-transition: width 1s ease-in-out;
-moz-transition: width 1s ease-in-out;
-o-transition: width 1s ease-in-out;
transition: width 1s ease-in-out;
}
}
HTML
<div class="siteBtnShare">
<span class="label"><i class="fa fa-share-alt" aria-hidden="true"></i></span>
<div class="share-text-wrapper">
<div class="share-text">
Share It Out
</div>
</div>
</div>
JSFiddle: https://jsfiddle.net/Jabideau/3bo4zxgc/

css outline error in firefox on li and hidden div

I have a horizontal list in which i am placing div's which are hidden until hovered over. To keep the dimensions (the hidden divs are the width of the menu) i am using outline: 2px solid black; , this works in ie and chrome, it outlines the li item but in firefox it outlines the entire ul item including the hidden div.
Does anyone know of a workaround for this or do i have a conflict for firefox outline?
css:
#marketmenu ul li{
display: block;
float: left;
position: relative;
cursor: pointer !important;
z-index: inherit;
font-size: 16px;
padding-top: 2px;
font-weight: bolder;
width: 15%;
height: 40px;
text-align: center;
background: white;
outline: 2px solid black;
}
#marketmenu ul li div {
position: absolute;
display: block;
top: 98%;
width: 600%;
background: #ffffff;
height: 200px;
opacity: 0;
visibility: hidden;
overflow: hidden;
z-index: 9;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
border-radius: 0 0 3px 3px;
-webkit-transition: all .3s ease .15s;
-moz-transition: all .3s ease .15s;
-o-transition: all .3s ease .15s;
-ms-transition: all .3s ease .15s;
transition: all .3s ease .15s;
}
html:
<div class="mheader-container">
<div id="logo" class="clearfix">
<img src="...">
</div>
<div class="userstatus">
<span class="icon-user-add"></span> Create an account
<span class="icon-user"></span> Log in
</div>
</div>
<div id="market_navigation" class="market_navigation clearfix">
<div id="marketmenu">
<ul>
<li>one<div class="menudrop"></div></li>
<li>two<div class="menudrop"></div></li>
<li>three<div class="menudrop"></div></li>
<li>four<div class="menudrop"></div></li>
<li>five<div class="menudrop"></div></li>
<li>six<div class="menudrop"></div></li>
</ul>
</div>
</div>
jsfiddle (remember its only in firefox there is a issue, renders fine in ie/chrome)
http://jsfiddle.net/ww2rkexd/1/
On the last li item, add a class of "last":
<ul>
<li>one<div class="menudrop"></div></li>
<li>two<div class="menudrop"></div></li>
<li>three<div class="menudrop"></div></li>
<li>four<div class="menudrop"></div></li>
<li>five<div class="menudrop"></div></li>
<li class="last">six<div class="menudrop"></div></li>
</ul>
Then change the CSS for the menudrop class from outline to border:
#marketmenu ul li{
display: block;
float: left;
position: relative;
cursor: pointer !important;
z-index: inherit;
font-size: 16px;
padding-top: 2px;
font-weight: bolder;
width: 15%;
height: 40px;
text-align: center;
background: white;
border-left: 2px solid black;
border-top: 2px solid black;
border-bottom: 2px solid black;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
And add the following CSS for the "last" class
li.last{
border-right: 2px solid black;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
ok this isnt pretty but it works....basically set a background of the border color and then a overlay div with the correct color. The dropdown div remains in proportion to the parent menu.
jsfiddle:
http://jsfiddle.net/dheffernan/pas1fqcp/
HTML
<div id="market_navigation" class="market_navigation clearfix">
<div id="marketmenu">
<ul>
<li><span class="innerli leftish">1st<div class="menudrop"></div></span></li>
<li><span class="innerli">2nd<div class="menudrop"></div></span></li>
<li><span class="innerli">3rd<div class="menudrop"></div></span></li>
<li><span class="innerli">4th<div class="menudrop"></div></span></li>
<li><span class="innerli">5th<div class="menudrop"></div></span></li>
<li><span class="innerli rightish">6th<div class="menudrop last"></div></span></li>
</ul>
</div>
</div>
css
#marketmenu ul{
cursor: pointer;
}
#marketmenu ul li{
display: block;
float: left;
position: relative;
cursor: pointer !important;
z-index: inherit;
font-size: 16px;
padding-top: 2px;
font-weight: bolder;
width: 15%;
height: 40px;
text-align: center;
background: black;
/*
outline: 2px solid black;
*/
}
.innerli{
display: block;
overflow: auto;
height: 88%;
width: 98%;
margin: 1%;
margin-left: 2%;
background-color: white;
padding-top: 6%;
}
.leftish{
margin-left: 2.5%;
}
.rightish{
width: 96%;
}
#marketmenu ul li div {
position: absolute;
display: block;
top: 98%;
width: 596.5%;
background: #ffffff;
height: 200px;
opacity: 0;
background: black;
visibility: hidden;
overflow: hidden;
z-index: 9;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
border-radius: 0 0 3px 3px;
-webkit-transition: all .3s ease .15s;
-moz-transition: all .3s ease .15s;
-o-transition: all .3s ease .15s;
-ms-transition: all .3s ease .15s;
transition: all .3s ease .15s;
}
#marketmenu ul li:first-child div {
}
#marketmenu ul li:nth-child(2) div {
margin-left: -100%;
}
#marketmenu ul li:nth-child(3) div {
margin-left: -200%;
}
#marketmenu ul li:nth-child(4) div {
margin-left: -300%;
}
#marketmenu ul li:nth-child(5) div {
margin-left: -400%;
}
#marketmenu ul li:nth-child(6) div {
margin-left: -500%;
padding-top: 2px;
}
#marketmenu ul li:hover div {
opacity: 1;
visibility: visible;
overflow: visible;
}
.market_navigation{
position: relative;
z-index: 40;
width: 70%;
margin-left: 30%;
height: 40px;
background: white;
}

Text isn't properly centered?

I have my social menu text-aligned:center but it's still is off quite a ways. Here's my code and a jsfiddle to demonstrate the trouble. As you can see it has more open space on the left than right. I want to even it out.
jsfiddle
HTML
<div id="wrapper">
<div id="header">
Erratic Fox
</div>
<div id="social">
<ul>
<li>Facebook</li> —
<li>Deviant Art</li> —
<li>YouTube</li> —
<li>Steam</li>
</ul>
</div>
</div>
CSS
body {
margin-top: 10px;
background-color: #E5E5E5;
}
#header {
color: #404040;
width: 50%;
margin: auto;
background-color: #ffffff;
font-size:100px;
text-align: center;
}
#social {
font-family: Roboto;
font-size: 18px;
line-height: 100px;
text-align: center;
height: 100px;
width: 50%;
background-color: white;
margin-left: auto;
margin-right: auto;
margin-top: 10px;
}
#social a {
text-decoration: none;
color: #404040;
transition: 1s color;
-moz-transition: 1s color;
-webkit-transition: 1s color;
}
#social a:hover {
color: #427FED;
transition: 1s color;
-moz-transition: 1s color;
-webkit-transition: 1s color;
}
#social li {
margin-right: 30px;
margin-left: 30px;
display: inline;
}
Add
#social ul {
padding-left:0;
}
Demo
Try to implement this:
ul { padding: 0; margin: 0; }