I'm eating my head for days with this problem. I proposed to make a menu, two different menu lists, the language one and the section one. In normal size, I like how it looks, the problem comes when I make it responsive to look at how it looks and I don't know how to find a solution.
I leave you the part of css and html.
<header class="l-header">
<nav class="nav bd-grid">
<div class="nav__menu" id="nav-menu">
<ul class="nav__list">
<li>
<img src="img/espana (1).png" alt="">
</li>
<li>
<img src="img/pais-vasco (1).png" alt="">
</li>
<li>
<img src="img/estados-unidos-de-america (1).png" alt="">
</li>
<li>
<img src="img/francia (1).png" alt="">
</li>
<li>
<img src="img/alemania.png" alt="">
</li>
</ul>
</div>
<div class="nav__menu" id="nav-menu">
<ul class="nav__list">
<li class="nav__item">Home</li>
<li class="nav__item">About me</li>
<li class="nav__item">Skills</li>
<li class="nav__item">Projects</li>
<li class="nav__item">Contact</li>
</ul>
</div>
<div class="nav__toggle" id="nav-toggle">
<em class='bx bx-menu'></em>
</div>
</nav>
</header>
*=====NAV=====*/ .nav {
height: var(--header-height);
display: flex;
justify-content: space-between;
align-items: center;
font-weight: var(--font-semi);
}
#media screen and (max-width: 768px) {
.nav__menu {
position: fixed;
top: var(--header-height);
right: 500%;
width: 80%;
height: 100%;
padding: 2rem;
background-color: var(--second-color);
transition: .5s;
}
.nav__menu1 {
position: fixed;
top: var(--header-height);
right: -100%;
width: 80%;
height: 100%;
padding: 2rem;
background-color: var(--second-color);
transition: .5s;
}
}
.nav__item {
margin-bottom: var(--mb-4);
}
.nav__link {
position: relative;
color: #fff;
}
.nav__link:hover {
position: relative;
}
.nav__link:hover::after {
position: absolute;
content: "";
width: 100%;
height: 0.18rem;
left: 0;
top: 2rem;
background-color: var(--first-color);
}
.nav__logo {
color: var(--second-color);
}
.nav__toggle {
color: var(--second-color);
font-size: 1.5rem;
cursor: pointer;
}
/*Active menu*/
.active::after {
position: absolute;
content: "";
width: 100%;
height: 0.18rem;
left: 0;
top: 2rem;
background-color: var(--first-color);
}
/*=== Show menu ===*/
.show {
right: 0;
}
can you help me.? Thanks a lot
After the code:
Here's my suggestion.
Move the language content to the bottom of the nav when responsive and change it to a side-by-side view.
<header class="l-header">
<nav class="nav bd-grid">
<div class="nav__menu nav__menu--lang" id="nav-menu">
<ul class="nav__list nav__list--lang">
<li>
<img src="img/espana (1).png" alt="">
</li>
<li>
<img src="img/pais-vasco (1).png" alt="">
</li>
<li>
<img src="img/estados-unidos-de-america (1).png" alt="">
</li>
<li>
<img src="img/francia (1).png" alt="">
</li>
<li>
<img src="img/alemania.png" alt="">
</li>
</ul>
</div>
<div class="nav__menu" id="nav-menu">
<ul class="nav__list">
<li class="nav__item">Home</li>
<li class="nav__item">About me</li>
<li class="nav__item">Skills</li>
<li class="nav__item">Projects</li>
<li class="nav__item">Contact</li>
</ul>
</div>
<div class="nav__toggle" id="nav-toggle">
<em class='bx bx-menu'></em>
</div>
</nav>
</header>
*=====NAV=====*/ .nav {
height: var(--header-height);
display: flex;
justify-content: space-between;
align-items: center;
font-weight: var(--font-semi);
}
#media screen and (max-width: 768px) {
.l-header {
height: 100vh;
}
.nav {
position: relative;
height: 100%;
}
.nav__menu {
padding: 2rem;
background-color: var(--second-color);
transition: .5s;
}
.nav__menu--lang {
position: absolute;
bottom: 0;
}
.nav__list--lang {
display: flex;
}
}
.nav__item {
margin-bottom: var(--mb-4
}
.nav__link {
position: relative;
color: #fff;
}
.nav__link:hover {
position: relative;
}
.nav__link:hover::after {
position: absolute;
content: "";
width: 100%;
height: 0.18rem;
left: 0;
top: 2rem;
background-color: var(--first-color);
}
.nav__logo {
color: var(--second-color);
}
.nav__toggle {
color: var(--second-color);
font-size: 1.5rem;
cursor: pointer;
}
/*Active menu*/
.active::after {
position: absolute;
content: "";
width: 100%;
height: 0.18rem;
left: 0;
top: 2rem;
background-color: var(--first-color);
}
/*=== Show menu ===*/
.show {
right: 0;
}
Related
When nav-toggle is checked sidebar reduces width and span is not displayed. When nav-toggle is unchecked it all comes back, but span displays the moment nav-toggle is unchecked and takes vertical space until sidebar is wide enough.
.sidebar {
width: 345px;
transition: width 300ms;
}
#nav-toggle:checked+.sidebar {
width: 70px;
}
#nav-toggle:checked+.sidebar li a span:last-child {
display: none;
}
<input type="checkbox" name="" id="nav-toggle">
<div class="sidebar">
<div class="sidebar-brand">
<h2><span class="lab la-accusoft"></span> <span>Acusoft</span></h2>
</div>
<div class="sidebar-menu">
<ul>
<li>
<a href="" class="active"><span class="las la-igloo"></span>
<span>Dashboard</span>
</a>
</li>
<li>
<a href=""><span class="las la-users"></span>
<span>Customers</span>
</a>
</li>
</ul>
</div>
</div>
I need to delay displaying 'span' until after transition is finished or sidebar is wide enough.
You could try changing the display: none into an opacity: 0, and have another transition with a transition-delay
This may not be an exact answer but could help you in the right direction. https://jsfiddle.net/treckstar/9uqgmnfk/16/
body {
font-size: 16px;
}
.app {
display: flex;
flex-flow: row nowrap;
max-width: 100%;
padding: 20px 0px 0px 0px;
position: relative;
}
#nav-toggle {
position: absolute;
top: 0px;
left: 0px;
}
.nav-toggle-label {
position: absolute;
top: 0px;
left: 20px;
}
.main-content {
flex: 1 0 auto;
height: 50vh;
background: #eee;
padding: .5rem 2rem;
}
.sidebar {
flex: 0 0 20%;
padding: .5rem 2rem;
height: 50vh;
transition: all 1s ease;
background-color: #ccc;
}
#nav-toggle:checked+.sidebar {
flex: 0 0 5%;
padding: .5rem .5rem;
}
.sidebar ul {
margin: 0px;
padding: 0px;
list-style: none;
}
.sidebar li a span {
opacity: 1;
transition: opacity .2s ease;
transition-delay: 1.25s;
}
#nav-toggle:checked+.sidebar li a span:last-child {
opacity: 0;
}
<div class="app">
<label class="nav-toggle-label" for="nav-toggle">Toggle</label>
<input type="checkbox" name="cb" id="nav-toggle">
<div class="sidebar">
<div class="sidebar-brand">
<h2><span class="lab la-accusoft"></span> <span>Acusoft</span></h2>
</div>
<div class="sidebar-menu">
<ul>
<li>
<a href="" class="active"><span class="las la-igloo"></span>
<span>Dashboard</span>
</a>
</li>
<li>
<a href=""><span class="las la-users"></span>
<span>Customers</span>
</a>
</li>
</ul>
</div>
</div>
<main class="main-content" role="main">
<h2>
Main Content
</h2>
</main>
</div>
Im new to HTML and CSS coding and have been working on creating a practice website. I'm running into this issue with my nav bar:
When I change the width to 100%, the nav bar items align horizontally ontop one another. [image of nav bar with width:100%
I can seem to change the width of the ".top-level-menu>li" class to a very specific number and it fills my screen but it simply wont fill the width 100%.
.third-level-menu {
position: absolute;
top: 0;
right: -190px;
width: 190px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menu>li {
height: 45px;
background-color: #6640C1;
background: #6640C1;
}
.third-level-menu>li:hover {
background-color: gold;
}
.second-level-menu {
position: absolute;
top: 45px;
left: 0;
width: 100%;
/* width: 273.2px; */
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.second-level-menu>li {
position: relative;
height: 45px;
background-color: #6640C1;
background: #6640C1;
width: 100%;
}
.second-level-menu>li:hover {
background-color: gold;
}
.top-level-menu {
background-color: red;
list-style: none;
padding: 0;
margin: 0;
width: 100%;
height: 100px;
z-index: 1;
}
.top-level-menu>li {
position: relative;
height: 30px;
/* width: 273.2px; */
background: #6640C1;
z-index: 2;
text-align: center;
}
.top-level-menu>li:hover {
background-color: gold !important;
}
.top-level-menu li:hover>ul {
display: inline;
}
.top-level-menu a {
font-family: 'Fjalla One', sans-serif;
color: #FFFFFF;
text-decoration: none;
padding: 0 0 0 10px;
background: #6640C1;
display: block;
line-height: 45px;
}
.top-level-menu a:hover {
color: #000000;
background-color: gold;
}
<ul class="top-level-menu">
<li><i class="fa fa-home" style="font-size: 20px;"></i> Home</li>
<li>
<i class="fa fa-tag" style="font-size: 20px"></i> Shop All ▼
<ul class="second-level-menu">
<li>Jerseys</li>
<li>Hats</li>
<li>Gym Shorts</li>
</ul>
</li>
<li><i class="fa fa-flask" style="font-size: 20px;"></i> Customize</li>
<li>
<i class="fa fa-futbol-o" style="font-size: 20px;"></i> Teams ▼
<ul class="second-level-menu">
<li>
Soccer
<ul class="third-level-menu">
<li>Barcelona</li>
<li>PSG</li>
<li>Real Madrid</li>
</ul>
</li>
<li>
Basketball
<ul class="third-level-menu">
<li>Golden State Warriors</li>
<li>Celtics</li>
<li>Chicago Bulls</li>
</ul>
</li>
<li>
Football
<ul class="third-level-menu">
<li>New England Patriots</li>
<li>Ravens</li>
<li>Atlanta Falcons</li>
</ul>
</li>
</ul>
<li><i class="fa fa-envelope" aria-hidden="true" style="font-size: 20px;"></i> Contacts Us
</li>
</li>
</ul>
Any help would be greatly appreciated.
You can use display:flex to make it work.
Made changes to the code snippet here:
.top-level-menu {
background-color: red;
list-style: none;
padding: 0;
margin: 0;
width: 100%;
height: 100px;
z-index: 1;
display:flex;
justify-content:space-between;
}
.top-level-menu>li {
position: relative;
height: 30px;
/* width: 273.2px; */
background: #6640C1;
z-index: 2;
text-align: center;
flex:1;
}
This is what you want i believe. Run snippet to see in action.
Hope this helped.
I have used display:flex and fixed up some padding.
.third-level-menu {
position: absolute;
top: 0;
right: -190px;
width: 190px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menu>li {
height: 45px;
background-color: #6640C1;
background: #6640C1;
}
.third-level-menu>li:hover {
background-color: gold;
}
.second-level-menu {
position: absolute;
top: 45px;
left: 0;
width: 100%;
/* width: 273.2px; */
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.second-level-menu>li {
position: relative;
height: 45px;
background-color: #6640C1;
background: #6640C1;
width: 100%;
}
.second-level-menu>li:hover {
background-color: gold;
}
.top-level-menu {
list-style: none;
width: 100%;
height: 100px;
z-index: 1;
display: flex;
}
.top-level-menu>li {
position: relative;
height: 30px;
background: #6640C1;
z-index: 2;
text-align: center;
}
.top-level-menu>li:hover {
background-color: gold !important;
}
.top-level-menu li:hover>ul {
display: inline;
}
.top-level-menu a {
font-family: 'Fjalla One', sans-serif;
color: #FFFFFF;
text-decoration: none;
background: #6640C1;
display: block;
line-height: 45px;
padding: 0px 15px 0px 15px;
}
.top-level-menu a:hover {
color: #000000;
background-color: gold;
}
<ul class="top-level-menu">
<li><i class="fa fa-home" style="font-size: 20px;"></i> Home</li>
<li>
<i class="fa fa-tag" style="font-size: 20px"></i> Shop All ▼
<ul class="second-level-menu">
<li>Jerseys</li>
<li>Hats</li>
<li>Gym Shorts</li>
</ul>
</li>
<li><i class="fa fa-flask" style="font-size: 20px;"></i> Customize</li>
<li>
<i class="fa fa-futbol-o" style="font-size: 20px;"></i> Teams ▼
<ul class="second-level-menu">
<li>
Soccer
<ul class="third-level-menu">
<li>Barcelona</li>
<li>PSG</li>
<li>Real Madrid</li>
</ul>
</li>
<li>
Basketball
<ul class="third-level-menu">
<li>Golden State Warriors</li>
<li>Celtics</li>
<li>Chicago Bulls</li>
</ul>
</li>
<li>
Football
<ul class="third-level-menu">
<li>New England Patriots</li>
<li>Ravens</li>
<li>Atlanta Falcons</li>
</ul>
</li>
</ul>
<li><i class="fa fa-envelope" aria-hidden="true" style="font-size: 20px;"></i> Contacts Us
</li>
</li>
</ul>
For a mobile view, this is the expected outcome
For some reason, when I resize the window all of my drop down menu items are opened. I want it too look like to posted image and when the headers are clicked the menu opens up to the drop downs on small screens. Link to my code here: https://jsfiddle.net/ept307gm/
<div id="menuContainer" class="clearfix">
<nav id="siteMenu">
<h2 class="mobileTitle"> <img style="float: right;" src=""></h2>
<ul class="dropDownMenu">
<li id="dropDownRootItem1">
<a class="dropDownRootItem1">Information</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<ul class="menuLevel1">
<li class="menuLevel2">My Account</li>
To begin with, you need to hide the submenus in the media query for smaller devices
#siteMenu, .menuColumn {
display: none;
}
Subsequently, you can use some basic JavaScript to toggle the submenu on menu item click.
Below is the working snippet:
var listItems = document.querySelectorAll('.dropDownMenu > li');
for (let listItem of listItems) {
listItem.onclick = e => {
var subMenu = e.target.querySelector('.menuColumn');
if (window.getComputedStyle(subMenu).display === 'none') {
subMenu.style.display = 'block';
} else {
subMenu.style.display = 'none';
}
}
}
div,
a,
img,
nav {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
}
nav {
display: block;
}
h2 {
padding: 0;
margin: 0 0 10px 0;
font-size: 24px;
font-weight: bold;
color: #323232;
}
a,
a:visited {
color: #4f2683;
text-decoration: none;
}
a:active,
a:hover {
text-decoration: underline;
}
ul {
margin-bottom: 20px;
margin-top: -5px;
}
ul ul {
margin: 0;
}
a {
font-weight: 700;
}
#media handheld,
screen and (min-width: 620px) {
#menuContainer ul {
list-style: none;
}
#menuContainer {
float: left;
max-width: 821px;
width: 100%;
margin: 0;
padding-top: 20px;
margin-bottom: -20px;
}
#siteMenu .mobileTitle {
display: none;
}
#siteMenu {
height: 60px;
position: relative;
list-style: none;
font-size: 14px;
z-index: 6000;
box-shadow: none;
margin: 0;
padding: 0 0 0 10px;
}
.dropDownMenu {
position: relative;
z-index: 999;
list-style: none;
margin: 0;
padding: 0;
}
.dropDownMenu>li>a {
display: block;
overflow: hidden;
position: relative;
text-indent: 0;
color: #000;
text-align: center;
text-decoration: none;
background: 0;
border: 0 none;
height: auto;
padding: 15px 0;
font-weight: 400;
}
.dropDownMenu ul {
list-style-type: none;
float: left;
position: relative;
z-index: 9999;
margin: 0;
padding: 0;
}
ul.menuColumn {
border-left: none;
border-right: none;
}
ul.menuColumn:first-child {
border: 0;
}
.widthcontainer2col ul.menuColumn {
width: 45%;
padding: 0 10px;
}
.dropDownMenu ul.menuColumn a {
text-decoration: none;
display: block;
letter-spacing: 1px;
color: #363636;
font-size: 13px;
line-height: 115%;
margin: 6px 0;
}
.dropDownMenu li.menuLevel1 {
font-weight: 700;
letter-spacing: 0;
font-size: 12px;
line-height: 16px;
color: #4f2683;
margin: 5px 0;
}
.dropDownMenu li.menuLevel2>a {
font-weight: 400;
}
.dropDownMenu ul a:hover {
text-decoration: underline;
}
.dropDownMenu ul.menuLevel1 {
float: none;
}
.dropDownMenu .menuContainer {
position: absolute;
display: none;
box-shadow: 0 4px 4px rgba(0, 0, 0, 0.4);
-webkit-box-shadow: 0 4px 4px rgba(0, 0, 0, 0.4);
border: 1px solid #4f2683;
background: #fff;
z-index: 9999;
top: 47px;
padding: 0;
}
.dropDownMenu .innerContainer {
float: left;
width: 100%;
position: relative;
z-index: 99;
}
.dropDownMenu .widthcontainer2col {
width: 50%;
}
ul.dropDownMenu li:hover .menuContainer {
display: block!important;
}
ul.dropDownMenu li {
float: left;
cursor: pointer;
}
ul.dropDownMenu li li {
float: none;
}
.widthcontainer2col {
top: 30px;
z-index: 999;
}
/* .widthcontainer2col .innerContainer:before {
position: absolute;
content: "";
z-index: -1;
width: 53%;
top: 12px;
bottom: 14px;
right: 0;
border-left: 1px solid #b9b9b9;
} */
/* .dropDownMenu>li:hover>a {
position: relative;
text-decoration: none;
font-weight: 700;
background: #4f2683;
color: #fff;
} */
#dropDownRootItem2 {
width: 19.970631424376%;
max-width: 136px;
}
#dropDownRootItem2:hover>a {
background-position: center -21px;
}
#dropDownRootItem3:hover>a {
background-position: center -63px;
}
#dropDownRootItem4 {
width: 15.418502202643%;
max-width: 105px;
}
#dropDownRootItem4:hover>a {
background-position: center -105px;
}
#dropDownRootItem5 {
width: 16.446402349486%;
max-width: 90px;
}
#dropDownRootItem5:hover>a {
background-position: center -147px;
}
#dropDownRootItem7 .widthcontainer2col {
right: 0;
}
#dropDownRootItem1,
#dropDownRootItem3 {
width: 17.033773861968%;
max-width: 116px;
}
#dropDownRootItem6,
#dropDownRootItem7 {
width: 16.096916299559%;
max-width: 124px;
}
#dropDownRootItem7 {
width: 16.096916299559%;
max-width: 124px;
}
#dropDownRootItem6:hover>a,
#dropDownRootItem7:hover>a {
background-position: center -189px;
}
#dropDownRootItem5,
#dropDownRootItem6,
#dropDownRootItem7 {
position: relative;
}
#dropDownRootItem5 .widthcontainer2col,
#dropDownRootItem6 .widthcontainer2col,
#dropDownRootItem7 .widthcontainer2col {
width: 440px;
}
.widthcontainer2col .innerContainer:before {
position: relative;
border-left: none;
}
.innerContainer>.menuColumn:nth-child(1) {
width: 100%;
box-sizing: border-box;
}
.dropDownMenu .widthcontainer2col {
width: auto;
}
#dropDownRootItem5 .widthcontainer2col,
#dropDownRootItem6 .widthcontainer2col,
#dropDownRootItem7 .widthcontainer2col {
width: 250px;
}
.dropDownMenu .menuLevel2 {
padding: 3px 0;
}
.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
.clearfix {
display: inline-block;
}
}
#media screen and (max-width: 840px) {
#dropDownRootItem1 {
width: 17%;
}
#dropDownRootItem2 {
width: 16%;
}
#dropDownRootItem3 {
width: 14%;
}
#dropDownRootItem4 {
width: 13%;
}
#dropDownRootItem5 {
width: 12%;
}
#dropDownRootItem6 {
width: 10%;
}
#dropDownRootItem7 {
width: 10%;
}
}
#media screen and (max-width: 740px) {
#dropDownRootItem1,
#dropDownRootItem2,
#dropDownRootItem3,
#dropDownRootItem4,
#dropDownRootItem5,
#dropDownRootItem6,
#dropDownRootItem7 {
font-size: 12px;
}
}
#media handheld,
screen and (max-width: 619px) {
#siteMenu,
.menuColumn {
display: none;
}
#siteMenu {
display: block;
}
#siteMenu .mobileTitle {
display: block;
padding: 15px;
padding-left: 30px;
background-color: #4f2683;
color: #fff;
box-sizing: border-box;
cursor: pointer;
}
#siteMenu>ul {
list-style-type: none;
width: 89.5%;
padding: 0;
margin: 0 auto;
margin-bottom: 10px;
box-sizing: border-box;
transition: all .5s ease;
}
#siteMenu>ul ul {
padding: 0;
list-style: none;
}
#siteMenu a,
#siteMenu li {
margin: 0;
padding: 15px 10px;
color: #fff;
}
#siteMenu .dropDownMenu>li {
width: 100%!important;
box-sizing: border-box;
padding: 5px 0;
cursor: pointer;
}
.dropDownMenu>li>a {
font-size: 24px;
background-color: #4f2683;
display: block;
margin: 10px;
pointer-events: none;
}
.dropDownMenu>li>.menuContainer {
font-size: 16px;
width: 100%;
height: 100%;
}
.dropDownMenu>li>.menuContainer>.innerContainer {
opacity: .75;
}
#siteMenu .menuColumn>li {
padding: 0;
background-color: #fff;
color: #4f2683;
}
#siteMenu .menuColumn li a {
color: #4f2683;
}
#siteMenu li.menuLevel2 {
padding-left: 0;
}
#siteMenu .menuColumn>li>ul {
padding: 0;
}
#siteMenu .menuColumn>li>ul>li {
padding-left: 0;
margin: 2px;
}
#siteMenu .menuLevel2 {
padding: 15px;
}
}
#media print {
#siteMenu {
display: none;
}
h2 {
color: #000;
font-size: 25px;
}
img {
border: none;
}
}
<div id="menuContainer" class="clearfix">
<nav id="siteMenu">
<h2 class="mobileTitle"> <img style="float: right;" src=""></h2>
<ul class="dropDownMenu">
<li id="dropDownRootItem1">
<a class="dropDownRootItem1">Information</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<ul class="menuLevel1">
<li class="menuLevel2">My Account</li>
<li class="menuLevel2">//</li>
<li class="menuLevel2">//</li>
<li class="menuLevel2">//</li>
<li class="menuLevel2">//</li>
<li class="menuLevel2">//</li>
<li class="menuLevel2">About</li>
<li class="menuLevel2">Blog</li>
<li class="menuLevel2">Contact Us</li>
</ul>
</ul>
</div>
</div>
</li>
<li id="dropDownRootItem2">
<a class="dropDownRootItem1">Kids' Corner</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<li class="menuLevel1">
<ul class="menuLevel1">
<!-- Kids' Corner is currently under construction -->
<!-- <li class='menuLevel2'><a href='/kids-corner-home'>Kids' Corner</a></li> -->
<li class="menuLevel2">Kids' Programs</li>
<li class="menuLevel2">Story Times</li>
<li class="menuLevel2">Program Registration</li>
<li class="menuLevel2">Kids’ Annual Programs</li>
<li class="menuLevel2">Books and Kits for Kids</li>
<li class="menuLevel2">Online Resources</li>
<li class="menuLevel2">Kids’ Calendar</li>
</ul>
</li>
</ul>
</div>
</div>
</li>
<li id="dropDownRootItem3">
<a class="dropDownRootItem1">Teen Scene</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<li class="menuLevel1">
<ul class="menuLevel1">
<li class="menuLevel2">Teen Programs</li>
<li class="menuLevel2">Teen Homework Resources</li>
<li class="menuLevel2">Teen Booklists</li>
<li class="menuLevel2">Teen Magazines</li>
<li class="menuLevel2">Teen Newsletter</li>
<li class="menuLevel2">Teen Calendar</li>
<li class="menuLevel2">Contact a Teen Librarian</li>
</ul>
</li>
</ul>
</div>
</div>
</li>
<li id="dropDownRootItem4">
<a class="dropDownRootItem1">Programs</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<li class="menuLevel1">
<ul class="menuLevel1">
<li class="menuLevel2">Calendar </li>
<li class="menuLevel2">All Ages Programs</li>
<li class="menuLevel2">Adult Programs</li>
<li class="menuLevel2">Teen Programs</li>
<li class="menuLevel2">Kids’ Programs</li>
<li class="menuLevel2">Annual Programs</li>
<li class="menuLevel2">Exhibits </li>
<li class="menuLevel2">On Demand Programs</li>
<li class="menuLevel2">Other Programs</li>
</ul>
</li>
</ul>
</div>
</div>
</li>
<li id="dropDownRootItem5">
<a class="dropDownRootItem1">Learn</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<li class="menuLevel1">
<ul class="menuLevel1">
<li class="menuLevel2">Research Databases</li>
<li class="menuLevel2">Homework Resources</li>
<li class="menuLevel2">Educational Services</li>
<li class="menuLevel2">Computers, Internet & Printing</li>
<li class="menuLevel2">Private Study Rooms</li>
<li class="menuLevel2">Media Center</li>
<li class="menuLevel2">Basement Creative Lab</li>
</ul>
</li>
</ul>
</div>
</div>
</li>
<li id="dropDownRootItem6">
<a class="dropDownRootItem1">Books & Media</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<li class="menuLevel1">
<ul class="menuLevel1">
<li class="menuLevel2">Book Club Sets</li>
<li class="menuLevel2">Booklists</li>
<li class="menuLevel2">Library Book Blogs</li>
<li class="menuLevel2">Book Series Order</li>
<li class="menuLevel2">Reading Suggestions</li>
<li class="menuLevel2">Magazines & Newspapers</li>
<li class="menuLevel2">New Audio/Visual Materials</li>
<li class="menuLevel2">Requesting Books</li>
<li class="menuLevel2">Digital Collections</li>
</ul>
</li>
</ul>
</div>
</div>
</li>
<li id="dropDownRootItem7">
<a class="dropDownRootItem1">Español</a>
<div class="menuContainer widthcontainer2col">
<div class="innerContainer">
<ul class="menuColumn">
<li class="menuLevel1">
<ul class="menuLevel1">
<li class="menuLevel2">Páginas en Español</li>
<li class="menuLevel2">Usando la Biblioteca</li>
<li class="menuLevel2">Servicios </li>
<li class="menuLevel2">Eventos</li>
<li class="menuLevel2">Recursos</li>
<li class="menuLevel2">Departamento de Niños</li>
</ul>
</li>
</ul>
</div>
</div>
</li>
</ul>
</nav>
</div>
When the user clicks on the arrow down button it should being the user down to section 2. However,the section 2 page doesn't exactly fit it also shows some of section 3.
When a user clicks on the arrows how can I get it to bring the user to each section which is in size proportion and doesn't also show another section?
If I include min-height:100vh; this does the job. However, if I add text to the top of section 2 it can't be seen. This is due to the height being greater. Therefore, how can I put text at the top at it fits correctly at the top so I don't have to click on the arrow from section 1 to go section 2 then have to scroll up a little to see the text at the top of section 2.
HTML/CSS
<style>
body {
margin: 0;
padding: 0;
}
.navbar.navbar-default {
background-color: #4D5061;
height: 10vh;
z-index: 100;
}
.navbar.navbar-default ul {
list-style-type: none;
text-align: right;
}
.navbar.navbar-default ul li {
display: inline-block;
}
.dropdown-menu li {
text-align: center
}
.dropdown .dropdown-menu {
background-color: #4D5061;
}
.dropdown .dropdown-menu a {
color: white;
}
.navbar.navbar-default ul li a {
display: inline-block;
padding: 3.5vh 8px 4px;
color: white;
text-decoration: none;
font-size: 14pt;
font-family: 'Roboto', sans-serif;
}
.navbar.navbar-default ul li:after {
content: '';
position: absolute;
right: 50%;
bottom: 0;
left: 50%;
height: 3px;
background-color: #FFFFFF;
border-radius: 9px;
transition: all .2s;
}
.navbar.navbar-default ul li a:hover {
color: white;
}
.nav.navbar-nav,
.nav.navbar-nav>li {
float: none;
}
.navbar.navbar-default ul li:hover:after {
right: 0;
left: 0;
}
.nav-title {
font-size: 14pt;
margin: 0;
top: 35px;
left: 50px;
width: 100%;
position: absolute;
text-align: center;
color: white;
font-family: 'Roboto', sans-serif;
}
.navbar.navbar-default ul.dropdown-menu li,
.navbar.navbar-default ul.dropdown-menu li a {
position: relative;
display: block;
}
#logo {
padding-top: 2vh;
padding-left: 20px;
float: left;
}
.hero {
background: url("https://static.pexels.com/photos/48727/pexels-photo-48727.jpeg") center center no-repeat;;
background-attachment: fixed;
position: relative;
background-size: cover;
width: 100%;
max-width: 100%;
width: 100vw;
height: 100%;
}
section {
position: relative;
height: 95vh;
}
.section1 {
height: 100vh;
text-align: center;
color: white;
}
.section2 {
background-color: #11B5E4;
text-align: center;
color: white;
}
.section3 {
background-color: #FFFFFF;
text-align: center;
color: white;
}
.fa-angle-down {
color: #4D5061;
position: absolute;
bottom: 0px;
}
.fa-angle-up {
color: #4D5061;
position: absolute;
bottom: 0px;
}
.footer {
height: 6vh;
background-color: #4D5061;
padding: 0;
right: 0;
bottom: 0;
left: 0;
}
.footertext {
font-size: 14pt;
color: white;
font-family: 'Roboto', sans-serif;
text-align: center;
}
.profile.box {
bottom: 0;
height: 50%;
left: 0;
margin: auto;
position: absolute;
right: 0;
top: 0;
width: 50%;
}
.shape {
border-radius: 25px;
display: inline-block;
background: #4D5061;
content: url(http://i1126.photobucket.com/albums/l611/ldocherty1/IMG_0730_zpsiz4dqc47.jpg);
color: white;
height: 250px;
margin: auto;
padding: 3px;
width: 250px;
}
.shape2 {
background: linear-gradient(35deg, #4D5061, #4D5061);
border-radius: 85px;
color: white;
height: 40px;
margin: 1% auto;
opacity: 0.9;
display: inline-block;
padding: 0px;
width: 250px;
}
section{min-height:100vh;padding:10vh 0 0;}
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<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="#"><img src="http://placehold.it/60x60" alt="Your Brand Name"></a>
<h1 class="nav-title">Liam Docherty's Digital Portfolio</h1>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Home
</li>
<li class="dropdown">
About Me <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Contact
</li>
<li>Something else here
</li>
<li>Separated link
</li>
<li>One more separated link
</li>
</ul>
</li>
<li class="dropdown">
Units <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li>Separated link
</li>
<li>One more separated link
</li>
</ul>
</li>
<li>Clients
</li>
<li>Contact Me
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<section id="section1" class="section1">
<div class="hero">
<div class="profile box">
<div class="shape"></div>
<div class="shape2">
<p>kjjjjjjjjjkjjjkkjkj</p>
</div>
</div>
</div>
<i class="fa fa-angle-down" style="font-size:100px;"></i>
</section>
<section id="section2" class="section2">
<h2>
This is some text
</h2>
<i class="fa fa-angle-down" style="font-size:100px;"></i>
</section>
<section id="contact-me" class="contact_section section3">
<i class="fa fa-angle-up" style="font-size:100px;"></i>
</section>
<script src="https://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<footer>
<div class="footer">
<h2 class="footertext">Copyright © 2017 Liam Docherty's Site. All rights reserved.</h2>
</div>
</footer>
This can be easily achieved using Fullpage.js. Remember to include all the resources and of course don't forget to call jquery script. To make it clear, please see my example.
$(document).ready(function() {
$('#fullpage').fullpage();
});
.one {
background: #F1E05A;
}
.two {
background: #563D7C;
}
.three {
background: #E34C26;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.9.4/jquery.fullpage.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.9.4/jquery.fullpage.min.js"></script>
<div id="fullpage">
<div class="section one">Some section</div>
<div class="section two">Some section</div>
<div class="section three">Some section</div>
</div>
In the list below, the spans do not line up to the center of their corresponding dots. I believe this is caused by the larger gap between the first and second spans.
HTML
<nav class="side-nav-right">
<ul>
<li class="bullet">
<a data-scroll href="#center-splash"><span style="width: 66px; left: -80px;">Intro</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section1"><span style="width: 66px; left: -80px;">section1</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section2"><span style="width: 66px; left: -80px;">section2</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section3"><span style="width: 66px; left: -80px;">section3</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section4"><span style="width: 66px; left: -80px;">section4</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section5"><span style="width: 66px; left: -80px;">section5</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section6"><span style="width: 66px; left: -80px;">section6</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section7"><span style="width: 66px; left: -80px;">section7</span></a>
</li>
</ul>
</nav>
SCSS
.side-nav-right {
display: block;
position: fixed;
top: 20%;
right: 1rem;
ul {
list-style: none outside;
li {
margin-bottom: 1rem;
a {
color: transparent;
display: block;
width: 1rem;
height: 1rem;
border-radius: 50%;
background: $light-text;
box-shadow: inset 0.025rem 0.025rem 0.075rem $PG-red;
vertical-align: top;
&.active {
background: #808080;
box-shadow: none;
}
}
span {
color: $light-text;
position: absolute;
background: rgba(0,0,0,0.7);
display: none;
padding: 0.25rem 0.5rem;
border-radius: 3px;
vertical-align: middle;
}
span:before {
content:"";
display:block;
width:0;
height:0;
border:solid 5px;
border-color:transparent transparent transparent rgba(0,0,0,0.7);
position:absolute;
right:-10px;
top:9px
}
&:hover span {
display: block;
}
}
li:first-child a>span{top:-5px}
}
}
#media only screen and (min-width: 1025px) {
.side-nav-right {
top: 30%;
right: 2rem;
ul {
li {
margin-bottom: 1.5rem;
a {
width: 1.25rem;
height: 1.25rem;
}
}
}
}
}
vertical-align seems to do nothing, commenting out all margins and padding doesn't work. I'm at a loss for why these elements aren't lining up past the first one.
You're looking at it the other way around. Notice that only your first element has a specific top property set to it:
li:first-child a>span{top:-5px}
The others do not.
Just align the others, and have the first one adjusted.
In this Fiddle I gave a margin-top to all spans and removed the special treatment for the first child. Might only be working on this fiddle and your exact measurements might need some adjustments, if so correct the fiddle.
span {
color: black;
position: absolute;
background: rgba(0,0,0,0.7);
display: none;
padding: 0.25rem 0.5rem;
border-radius: 3px;
vertical-align: middle;
margin-top: -8px;
}
Here is the solution without affecting your original code structure:
Replace your html with followg code:
<nav class="side-nav-right">
<ul>
<li class="bullet">
<a data-scroll href="#center-splash"><span>Intro</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section1"><span>section1</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section2"><span>section2</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section3"><span>section3</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section4"><span>section4</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section5"><span>section5</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section6"><span>section6</span></a>
</li>
<li class="bullet">
<a data-scroll href="#section7"><span>section7</span></a>
</li>
</ul>
</nav>
Then replace your css with following code:
.side-nav-right {
display: block;
position: fixed;
top: 20%;
right: 1rem;
ul {
list-style: none outside;
li {
margin-bottom: 1rem;
position:relative;
a {
color: transparent;
display: block;
width: 1rem;
height: 1rem;
border-radius: 50%;
background: $light-text;
box-shadow: inset 0.025rem 0.025rem 0.075rem $PG-red;
vertical-align: top;
&.active {
background: #808080;
box-shadow: none;
}
}
span {
color: $light-text;
position: absolute;
background: rgba(0,0,0,0.7);
display: none;
padding: 0.25rem 0.5rem;
border-radius: 3px;
vertical-align: middle;
width: 66px;
left: -90px;
top:-4px;
}
span:before {
content:"";
display:block;
width:0;
height:0;
border:solid 5px;
border-color:transparent transparent transparent rgba(0,0,0,0.7);
position:absolute;
right:-10px;
top:9px
}
&:hover span {
display: block;
}
}
li:first-child a>span{top:-5px}
}
}
#media only screen and (min-width: 1025px) {
.side-nav-right {
top: 30%;
right: 2rem;
ul {
li {
margin-bottom: 1.5rem;
a {
width: 1.25rem;
height: 1.25rem;
}
}
}
}
}