i've made a change to the navigation from scrolling in only one page to linking them to other pages instead. but i cant seem to make the href link work after that. i dont know what could be the problem here
i havent made any changes to the CSS, originally it was meant to be a navigation for one page, but im changing it to navigation to other pages
im pretty sure i need to do something to the css but im not sure what
it is
class="sidebar-navigation hidde-sm hidden-xs">
<div class="logo">
<img src="img/logo.png" alt="logo" style=" margin-top:13px;width:100%;height:100%;">
</div>
<nav>
<ul>
<li>
<a href="index.html">
<span class="rect"></span>
<span class="circle"></span>
Home
</a>
</li>
<li>
<a href="company.html">
<span class="rect"></span>
<span class="circle"></span>
Company
</a>
</li>
.sidebar-navigation nav {
position: relative;
top: 60%;
left: 60%;
-webkit-transform: translateX(-60%) translateY(-60%);
-moz-transform: translateX(-60%) translateY(-60%);
-ms-transform: translateX(-60%) translateY(-60%);
-o-transform: translateX(-60%) translateY(-60%);
transform: translateX(-60%) translateY(-60%);
}
.sidebar-navigation ul {
margin-left: 45px;
list-style: none;
padding: 0;
}
.sidebar-navigation li{
padding: 10px 0;
}
.sidebar-navigation span{
display: inline-block;
position:relative;
}
.sidebar-navigation nav a{
display: inline-block;
color: #fff;
margin-top: 5px;
text-decoration: none!important;
font-size: 15px;
letter-spacing: 0.5px;
text-transform: capitalize;
}
.circle{
margin-right: 5px;
height: 10px;
width: 10px;
left: 0px;
top: -1px;
border-radius: 50%;
background-color: transparent;
border: 2px solid #fff;
transition: all 0.3s;
}
.rect{
height: 1px;
width: 0px;
left: 0;
bottom: 5.5px;
background-color: #fff;
-webkit-transition: -webkit-transform 0.1s, width 0.6s;
-moz-transition: -webkit-transform 0.1s, width 0.6s;
transition: transform 0.1s, width 0.6s;
}
Related
I have a navigation menu that contains a burger icon made with 3 <span> that is inside another elements :
.navbar {
width: 100%;
color: #fff;
background-color: #df0024;
padding: 1% 0;
}
.tog {
display: flex;
cursor: pointer;
float: right;
width: 6%;
position: absolute;
top: 0;
right: 0;
bottom: 0;
align-items: center;
justify-content: center;
height: auto;
}
/*This is the div that contain the burger 3 layers*/
#nav-icon {
height: -webkit-fill-available;
height: -moz-fill-available;
height: -o-fill-available;
height: fill-available;
position: relative;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
cursor: pointer;
}
/*/The style of each of the burger icon 3 layers*/
#nav-icon span {
display: block;
position: absolute;
height: 3.1vh;
width: 100%;
background: white;
border-radius: 9px;
opacity: 1;
left: 0;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
#nav-icon span:nth-child(1) {
top: 0px;
}
#nav-icon span:nth-child(2) {
top: 12px;
}
#nav-icon span:nth-child(3) {
top: 24px;
}
<nav class="navbar">
<div class="logo">
<img src="" alt='Logo' />
</div>
<div id='tog' class="tog">
<label for="toggle" id='nav-icon'>
<div class='icon-container'>
<span></span>
<span></span>
<span></span>
</div>
</label>
</div>
</nav>
How to center the #nav-icon span inside the #nav-icon vertically ? All I want is centering the burger icon so I don't care of changing the other elements style that contain the burger icon.
I had to tweak a lot to make this work, but I used a nice vertical-centering trick I know involving top: 50%; plus transition: translateY(-50%);. If you apply those to a child div then it will be vertically centered within a sized parent (the parent should also have position relative or absolute).
I applied these styles to the .icon-container in your code.
.navbar{
width: 100%;
position: relative;
color: #fff;
background-color: #df0024;
padding: 1% 0;
}
.tog {
display: flex;
cursor: pointer;
float: right;
width: 6%;
position: absolute;
top: 0;
right: 0;
bottom: 0;
align-items: center;
justify-content: center;
height: auto;
}
/*This is the div that contain the burger 3 layers*/
#nav-icon{
position: absolute;
top:0;
bottom:0;
left:0;
right: 0;
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
cursor: pointer;
}
.icon-container {
padding: 0 5px;
box-sizing: border-box;
position: relative;
top: 50%;
-ms-transform: translateY(-50%); /* IE 9 */
-webkit-transform: translateY(-50%); /* Chrome, Safari, Opera */
transform: translateY(-50%);
}
#nav-icon span{
display: block;
width: 100%;
height: 5px;
margin-bottom: 3px;
background: white;
border-radius: 9px;
opacity: 1;
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
<nav class="navbar">
<div class="logo">
<img src="" alt='Logo'/>
</div>
<div id='tog' class="tog">
<label for="toggle" id='nav-icon'>
<div class='icon-container'>
<span></span>
<span></span>
<span></span>
</div>
</label>
</div>
</nav>
If you have nothing against flex, you may also drop the absolute positionning.
.navbar {
display: flex;
align-items: center;/* vertical-centering */
color: #fff;
background-color: #df0024;
padding: 1% 0;
/* DEMO PURPOSE ONLY to show vertical centering */
transition:0.25s;
height: 100px;
background-image:linear-gradient(to top, transparent 50%, rgba(255,255,255,0.15) 50%);
}
.navbar:hover {height:200px;}
/* end -- DEMO PURPOSE ONLY to show vertical centering */
nav a {
/* demo purpose , useless about centering */
margin: 0 0.5em;
color: white;
}
.tog {
cursor: pointer;
width: 1.5em;
margin-left: auto;/* goes all the way to the right side */
}
/*This is the div that contain the burger 3 layers*/
#nav-icon {
display: block;
transform: rotate(0deg);
transition: .5s ease-in-out;
cursor: pointer;
}
/*The style of each of the burger icon 3 layers*/
#nav-icon span {
display: block;
background: white;
margin: 0.25em 0;
border-radius: 9px;
opacity: 1;
height: 0.25em;
transform: rotate(0deg);
transition: .25s ease-in-out;
box-shadow: 1px 1px 1px;
}
<nav class="navbar">
<div class="logo">
<img src="" alt='Logo' />
</div>
another link ?
<div id='tog' class="tog">
<label for="toggle" id='nav-icon'>
<div class='icon-container'>
<span></span>
<span></span>
<span></span>
</div>
</label>
</div>
</nav>
I have a tooltip to show my search when hovering over an icon. That works fine in itself.
My problem is, that this icon is inside an inline-block navigation and cause it acts as the parent of my tooltip it has to have the large width of it which messes up my layout.So if I don't extend the width of my parent with the Icon the Tooltip messes up due to the small width of ~30px of it's parent.
If I extend the width from my parent to 300px (The size of my tooltip), it messes up my layout.
I need a way of relieving the tooltip itself from the inside of the element with the Icon.
HTML Structure:
<div id="search">
<div class="wrapper">
<div class="popper inline">
<i class="fa fa-tags" />
<div class="tooltip">
<form>
<input placeholder="Search Tags" autocomplete="off" />
<button type="submit">
<a class="btn">
<i class="fa fa-search" />
</a>
</button>
</form>
</div>
<div class="inline">
<form>
<input placeholder="Search Tags" autocomplete="off" autofocus="true" />
<button type="submit">
<a class="btn">
<i class="fa fa-search" />
</a>
</button>
</form>
</div>
</div>
</div>
CSS (Scss):
#search {
background: $secondary;
padding: .25rem;
div.popper {
background: transparent;
border: none;
font-size: .8rem;
color: $highlight;
}
.inline form {
button, input, a {
background: transparent;
border: none;
font-size: .8rem;
color: $highlight;
}
input[type="Search"] {
width: 1368px;
outline: none;
font-style: italic;
font-size: .7rem;
padding: 1rem .5rem;
}
button {
margin-left: 1rem;
}
}
}
.popper {
position: relative;
width: 300px;
}
.popper .tooltip {
background: $secondary;
bottom: 100%;
color: $highlight;
display: block;
left: -25px;
margin-bottom: 20px;
opacity: 0;
padding: .8rem;
pointer-events: none;
position: absolute;
width: 300px;
max-width: 90%;
border-radius: 3px;
-webkit-transform: translateY(10px);
-moz-transform: translateY(10px);
-ms-transform: translateY(10px);
-o-transform: translateY(10px);
transform: translateY(10px);
-webkit-transition: all .25s ease-out;
-moz-transition: all .25s ease-out;
-ms-transition: all .25s ease-out;
-o-transition: all .25s ease-out;
transition: all .25s ease-out;
}
/* This bridges the gap so you can mouse into the tooltip without it disappearing */
.popper .tooltip:before {
bottom: -20px;
content: " ";
display: block;
height: 25px;
left: 0;
position: absolute;
width: 100%;
}
/* CSS Triangles - see Trevor's post */
.popper .tooltip:after {
border-left: solid transparent 7px;
border-right: solid transparent 7px;
border-top: solid $secondary 7px;
bottom: -7px;
content: " ";
height: 0;
left: 50%;
margin-left: -13px;
position: absolute;
width: 0;
}
.popper:hover .tooltip {
opacity: 1;
pointer-events: auto;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
-o-transform: translateY(0px);
transform: translateY(0px);
}
I am grateful for all Your help! If you need further information, comment please.
I have trouble vertically centering icon that drops on image hover, and I am trying to ease out its drop down. Currently it is coming down too aggressive but no matter what transition property I set (ease, ease-out etc.) it doesn't change.
https://jsfiddle.net/4br7sj0q/2/
<div class="fader">
<a href="#">
<img width="200" height="350" src="http://placehold.it/200x350">
<span class="fa fa-search fa-3x"></span>
</a>
</div>
.fader {
position: relative;
span.fa {
position: absolute;
top: -9999px;
// center horizontal
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
transition: all 0.3s ease-out;
}
&:hover .fa {
top: 50%;
}
}
Couple of things.
The icon is coming a long way. You really don't need to send it 9999px away, just enough to be offscreen (or apply overflow hidden to the parent and then it can just be 1em off the top).
Then change the transition to something like transition: all 0.5s ease;...if it's too fast, make the time longer.
The easing function should just be ease...not ease-out...it looks more natural.
Finally, to adjust the centering you need to drag it back up half it's own height
transform:translateY(-50%);
li {
list-style: none;
text-align: center;
}
.fader {
position: relative;
overflow: hidden;
display: inline-block;
}
.fader img {
-webkit-transition: all 0.3s;
transition: all 0.3s;
display: block;
}
.fader img:hover {
opacity: 0.5;
}
.fader span.fa {
color: #333;
position: absolute;
top: -1em;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
-webkit-transition: all .5s ease;
transition: all .5s ease;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
.fader:hover .fa {
top: 50%;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css" rel="stylesheet" />
<li>
<div class="fader">
<a href="#">
<img width="200" height="350" src="http://placehold.it/200x350"> <span class="fa fa-search fa-3x"></span>
</a>
</div>
</li>
Your top value is insanely high ;)
Just change it to a more reasonnable value to hide it and it should be good for you :
span.fa {
color: #333;
position: absolute;
top: -60px;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
transition: all 0.3s ease-out;
}
Fiddle
I have a link that I'm trying to position:absolute inside a position:relative container. However when I do so, it skews the text to the right by about 10-15pxs and makes it look really off center. However if I change absolute to relative, the text returns to where it should be (the center). Why is position:absolute doing this, and is there any fixes? I've included my code below and any help would be great. Thanks!
The text that is giving me trouble is this:
<div class="green select">
<p><a class="button" href="links/calculator.html">Discover</a></p>
</div>
</div>
Here is the rest of my HTML:
.headerContent {
position: relative;
width: 55%;
margin: auto;
height: 100%;
text-align: center;
}
.title {
font-family: 'Oxygen', sans-serif;
font-weight: 700;
color: white;
font-size: 90px;
padding-bottom: 15px;
}
.headerText {
position: absolute;
bottom: 35%;
font-family: 'Oxygen', sans-serif;
font-weight: 400;
font-size: 18px;
line-height: 27px;
width: 90%;
margin: auto;
display: block;
left: 0;
right: 0;
}
.select a {
position: absolute;
font-family: 'Oxygen', sans-serif;
font-weight: normal;
top: 225px;
font-size: 25px;
color: white;
text-decoration: none;
width: 110px;
padding-top: 5px;
padding-bottom: 5px;
margin: auto;
}
.select a::before,
.select a::after {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 2px solid #fff;
content: '';
opacity: 0;
-webkit-transition: -webkit-transform 0.3s, opacity 0.3s;
-moz-transition: -moz-transform 0.3s, opacity 0.3s;
transition: transform 0.3s, opacity 0.3s;
}
.select a::after {
border-color: #fff;
opacity: 0;
-webkit-transform: translateY(-7px) translateX(6px);
-moz-transform: translateY(-7px) translateX(6px);
transform: translateY(-7px) translateX(6px);
}
.select a:hover::before,
.select a:focus::before {
opacity: 0;
-webkit-transform: translateY(5px) translateX(-5px);
-moz-transform: translateY(5px) translateX(-5px);
transform: translateY(5px) translateX(-5px);
}
.select a:hover::after,
.select a:focus::after {
opacity: 1;
-webkit-transform: translateY(0px) translateX(0px);
-moz-transform: translateY(0px) translateX(0px);
transform: translateY(0px) translateX(0px);
}
<div class="headerContent">
<nav>
<ul class="navDown">
<li>Intro</li>
<li>Wind</li>
<li>Solar</li>
<li>Nuclear</li>
<li>End</li>
</ul>
<a href="#" class="menu-icon">
<p class="menu"></p>
</a>
</nav>
Scroll
Scroll
<h1 class="title bigTitle">Going Green.</h1>
<p class="headerText">
A change is coming- and that change will be making the switch to green forms of energy. If you are interested in learning how you can help the environment and save money over time- you have come to the right place. It is time to Energize Change. <br>
<span
class="emphasis">Click below to find the perfect green energy source for you and your family!</span>
</p>
<img class="people" src="images/peoplesSad.png" />
<p class="noElechouse"></p>
<div class="green select">
<p><a class="button" href="links/calculator.html">Discover</a></p>
</div>
</div>
Add
.select a
{
left:0;
right:0;
}
Honestly I don't see why you're bent on absolutely positioning your link.
Fiddle
The containing block, which is the first ancestor element that does not have position: static. If there is no such ancestor, the element serves as the containing block.
you can do it that way
add
.relative {position: relative !important}
and append it to
<a class="button relative" href="links/calculator.html">Discover</a>
For navigation, I opted to use CSS shapes rather than images with overlaid text. However, in every browser, the text appears misaligned towards the right.
Preview on jsFiddle
HTML code:
<nav id="globalNav">
<ul>
<li>
<div class="stars"></div>
<a id="navHome">home</a>
</li>
<li>
<div class="stars"></div>
<a id="navWork">work</a>
</li>
<li>
<div class="stars"></div>
<a id="navAbout">about</a>
</li>
</ul>
</nav>
CSS code:
#globalNav {
position: fixed;
z-index: 1;
width: 100%;
height: 100px;
top: 0;
left: 0;
overflow: hidden;
background-color: #1b2326;
color: #2A363B;
}
#globalNav ul {
margin: 1.25em auto;
padding: 0;
position: relative;
-webkit-padding-start: 0;
-moz-padding-start: 0;
text-align: center;
}
#globalNav li {
padding: 0 3.5em;
display: inline-block;
}
#globalNav a {
position: absolute;
top: 1.3em;
padding: 0 0.25em;
-moz-padding-start: 0;
font-size: 1em;
text-transform: uppercase;
color: #FECEA8;
}
#globalNav a:hover {
position: absolute;
top: 1.3em;
padding: 0 0.25em;
-moz-padding-start: 0;
font-size: 1em;
text-transform: uppercase;
color: #ED6161;
-webkit-transition: .3s ease-in;
-moz-transition: .3s ease-in;
-ms-transition: .3s ease-in;
-o-transition: .3s ease-in;
transition: .3s ease-in;
}
/* dodecagram stars */
.stars {
background: #2A363B;
width: 60px;
height: 60px;
position: relative;
}
.stars:before, .stars:after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 60px;
width: 60px;
background: #2A363B;
}
.stars:before {
-webkit-transform: rotate(30deg);
-moz-transform: rotate(30deg);
-ms-transform: rotate(30deg);
-o-transform: rotate(30deg);
}
.stars:after {
-webkit-transform: rotate(60deg);
-moz-transform: rotate(60deg);
-ms-transform: rotate(60deg);
-o-transform: rotate(60deg);
}
I already searched the forum (i.e., Center text with background CSS “shape”), however the solution didn't work for me.
Add the following CSS to your <a> tags inside the shapes and they will align in the center of the shape :)
position: absolute;
top: 1.3em;
-moz-padding-start: 0;
font-size: 1em;
text-transform: uppercase; /* Also, note that I removed the padding */
color: #FECEA8;
display: block;
width: 60px;
word-wrap: break-word;
}
http://jsfiddle.net/TVkNK/7/
Adding text-align:center to the css did it for me. I also used padding-top to add appropriate padding for vertical centering.