In my website, I have added fonts (in my CSS) and have tried to use them in my website, but they don't show up. I have used three fixes:
FIX 1:
body {
-webkit-animation-duration: 0.1s;
-webkit-animation-name: fontfix;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: linear;
-webkit-animation-delay: 0.1s;
}
#-webkit-keyframes fontfix {
from { opacity: 1; }
to { opacity: 1; }
}
FIX 2:
$(‘body’)
.delay(500)
.queue(
function(next){
$(this).css(‘padding-right’, ‘1px’);
});
FIX 3:
jQuery.fn.redraw = function() {
return this.hide(0, function(){jQuery(this).show()});
};
jQuery(document).ready(function() {
jQuery('body').redraw();
});
They have all had no effect, and my website stays the same. It could be Chrome, my computer, or I might've incorrectly linked the sites, I don't know. Any help would be appreciated. Here is my code (I left out my JavaScript as it is irrelevant):
HTML
<main class="content" role="main">
<section class="section two">Ut dui diam, vulputate a gravida non, ullamcorper ac leo. Aenean pellentesque feugiat quam ac facilisis. Sed aliquam justo vel augue tincidunt facilisis. Phasellus lacinia quis sem sed aliquam. Etiam ultrices in arcu vel elementum. Maecenas scelerisque leo nec elit convallis, sagittis tincidunt purus consectetur. Cras gravida fringilla sem, in lacinia diam interdum sit amet. Nunc viverra nunc vitae diam malesuada, eu sollicitudin erat feugiat. Sed sed dapibus dui. Nullam a convallis erat, quis malesuada mi. Nunc vel malesuada elit. Proin a finibus turpis. Nullam faucibus magna sed felis fermentum iaculis. Nam et faucibus odio, vel viverra purus. Fusce pellentesque tincidunt ante, vitae tempor purus pulvinar eget. Fusce luctus orci sit amet nisi tincidunt, ut ullamcorper quam posuere. Vivamus elit massa, aliquam sed lectus non, condimentum accumsan turpis. Duis purus nibh, suscipit in lectus quis, dapibus rutrum turpis. Phasellus tristique nulla non ipsum lacinia, quis mattis quam laoreet. Vivamus sagittis, ante id sodales rutrum, odio eros commodo risus, quis consectetur lacus nunc vitae neque. Donec mauris urna, fringilla et laoreet fermentum, porttitor at nibh. Donec lorem magna, vulputate a ligula ut, tempor sollicitudin erat. Curabitur lobortis fringilla diam, a sodales nibh placerat ac. Aenean id feugiat dolor. Suspendisse potenti. Donec sed sem eu felis ullamcorper laoreet. Nunc blandit ut nibh nec condimentum. Phasellus a tincidunt ipsum. Quisque blandit congue lacus vitae venenatis. Suspendisse sit amet lobortis velit. Duis rhoncus vehicula elementum. Cras in viverra nunc. Maecenas egestas molestie mauris at placerat. Suspendisse congue faucibus est et aliquam. Nam rutrum sapien et iaculis eleifend. Donec eu tincidunt urna, quis ultrices purus. Curabitur sagittis tempus risus nec congue. Donec a felis nec dui interdum condimentum et a tortor. Quisque eget diam vitae turpis tristique imperdiet nec eget est. Sed gravida nec orci ac feugiat. Nulla et erat neque. Integer sit amet velit ornare quam rutrum tincidunt. Ut sollicitudin, nisi at porttitor maximus, nisi dui volutpat massa, non dictum diam nisi id nisi. Sed pretium ligula vitae sollicitudin bibendum. Donec viverra lorem et lectus elementum, imperdiet tempor erat cursus. Aliquam id viverra purus. In hac habitasse platea dictumst. Phasellus vel libero ac sem mollis auctor eu vitae libero. Mauris sit amet metus condimentum, consectetur tellus eget, ullamcorper orci. Donec vel arcu eros. Pellentesque vitae nulla a nisi mattis malesuada ac in dui. Interdum et malesuada fames ac ante ipsum primis in faucibus. Suspendisse rhoncus tempor purus eu gravida. Pellentesque sollicitudin, elit eu cursus finibus, quam est cursus justo, at iaculis orci neque quis elit. Aliquam auctor vel leo sit amet faucibus. Maecenas neque diam, pretium sit amet nisi non, eleifend tempus elit. Pellentesque pulvinar turpis elit, in tempus ex efficitur sed. Morbi ornare elementum enim. Donec venenatis pellentesque ante, laoreet pretium leo varius in. Aliquam eu sapien vitae nibh imperdiet consectetur. Nunc ultricies venenatis nisi quis sagittis. In hac habitasse platea dictumst. Aenean malesuada placerat neque id congue. Pellentesque sagittis euismod quam, vel convallis diam. Nunc scelerisque nibh nec congue finibus. Pellentesque non lacinia nibh, id accumsan eros. Aliquam feugiat fringilla sem. Vivamus porta metus in libero cursus, et ornare elit eleifend. Phasellus venenatis pellentesque venenatis. Nullam feugiat condimentum justo, et molestie sapien varius eget. Curabitur suscipit ex vel erat luctus, consectetur aliquet enim placerat. Vivamus id vehicula dolor, nec volutpat lectus. Integer lacinia, dolor et rhoncus blandit, sapien leo fringilla risus, nec maximus libero erat eget quam. Sed sit amet magna purus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</section>
<section class="section three">
<h2>Three</h2>
</section>
<section class="section four">
<h2>Four</h2>
</section>
</main> Top
<!-- Footer -->
<footer class="fixed_footer">
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Debitis ducimus nemo quo totam neque quis soluta nisi obcaecati aliquam saepe dicta adipisci blanditiis quaerat earum laboriosam accusamus nesciunt! Saepe ex maxime enim asperiores nisi. Obcaecati nostrum nobis laudantium aliquam commodi veniam magni similique ullam quis pariatur voluptatem harum id error.</p>
</div>
</footer>
</body>
CSS
/* Fonts */
#import url(http://fonts.googleapis.com/css?family=Teko:700);
#import url(http://fonts.googleapis.com/css?family=Exo:400,900);
#import url(http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,900italic,900,700italic,700,500italic,500,400italic);
#import url(http://fonts.googleapis.com/css?family=Bitter:400,700);
#import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900,200italic,300italic,400italic,600italic,700italic,900italic);
#import url(http://fonts.googleapis.com/css?family=Oswald:400,300,700);
#import url(http://fonts.googleapis.com/css?family=Montserrat:400,700);
/* Body */
* {
margin: 0;
padding: 0;
font-family: "Roboto", sans-serif
}
/* Header */
/* Shrinking */
/* ClearFix */
.cf:before,
.cf:after {
content: " ";
display: table;
}
.cf:after {
clear: both;
}
.cf {
font-family: "Teko", sans-serif;
top: 30px;
*zoom: 1;
width: 100%;
height: 100px;
background: #02236a;
position: fixed;
z-index: 9999;
box-shadow: 0 4px 4px rgba(0,0,0,0.1);
}
/* Header Styles */
.small {
height: 80px;
}
.small .logo {
width: 240px;
height: 80px;
}
.nav {
width: 80%;
}
.logo {
float:left;
}
/* Transitions */
header, .logo {
-webkit-transition: all 1s;
transition: all 1s;
}
/* Navigation */
ul li {
float: left;
margin-left: 50px;
padding-top: 45px;
color: #fafafa;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
-ms-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
ul li:hover {
color: #ffba00;
}
/* Social Icons */
.sicf {
z-index: 9999;
position: fixed;
height: 30px;
width: 100%;
background-color: #001f4c;
}
/* Icons */
#social-icons li {
float: left;
}
.facebook, .google, .twitter, .youtube {
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.facebook:hover {
background-color: #3b5998;
}
.google:hover {
background-color: #dd4b39;
}
.twitter:hover {
background-color: #00aced;
}
.youtube:hover {
background-color: #92291b;
}
/* Main Content */
*,
*:before,
*:after {
box-sizing: border-box;
font: 300 1em/1.5 'Merriweather', serif;
color: #242424;
padding: 0;
margin: 0;
}
html,
body {
background: rgb(236, 240, 241);
}
.content {
margin: auto;
margin-bottom: 350px;
/* Same height as footer */
}
/* Slider */
.rslides {
position: relative;
list-style: none;
overflow: hidden;
width: 100%;
padding: 0;
margin: 0;
}
.rslides li {
-webkit-backface-visibility: hidden;
position: absolute;
display: none;
width: 100%;
left: 0;
top: 0;
}
.rslides li:first-child {
position: relative;
display: block;
float: left;
}
.rslides img {
z-index: 10;
display: block;
height: auto;
float: left;
width: 100%;
border: 0;
}
/* Top Button */
.cd-top {
display: inline-block;
height: 40px;
width: 40px;
position: fixed;
bottom: 40px;
right: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
/* image replacement properties */
overflow: hidden;
text-indent: 100%;
white-space: nowrap;
background: #3d4942 url(../IMG/cd-top-arrow.svg) no-repeat center 50%;
visibility: hidden;
opacity: 0;
-webkit-transition: opacity .3s 0s, visibility 0s .3s;
-moz-transition: opacity .3s 0s, visibility 0s .3s;
transition: opacity .3s 0s, visibility 0s .3s;
}
.cd-top.cd-is-visible, .cd-top.cd-fade-out, .no-touch .cd-top:hover {
-webkit-transition: opacity .3s 0s, visibility 0s 0s;
-moz-transition: opacity .3s 0s, visibility 0s 0s;
transition: opacity .3s 0s, visibility 0s 0s;
}
.cd-top.cd-is-visible {
/* the button becomes visible */
visibility: visible;
opacity: 0.6;
}
.no-touch .cd-top:hover {
background-color: #e86256;
opacity: 0.6;
}
/* Footer */
.fixed_footer {
width: 100%;
height: 350px;
background: #111;
position: fixed;
left: 0;
bottom: 0;
z-index: -100;
}
.fixed_footer p {
color: #696969;
column-count: 2;
column-gap: 50px;
font-size: 1em;
font-weight: 300;
}
/* Miscellaneous */
a {
text-decoration: none;
}
li {
list-style: none;
}
/* Font Fix */
body {
-webkit-animation-delay: 0.1s;
-webkit-animation-name: fontfix;
-webkit-animation-duration: 0.1s;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: linear;
}
#-webkit-keyframes fontfix {
from { opacity: 1; }
to { opacity: 1; }
}
/* Delete */
.section {
max-width: 100%;
height: 42em;
padding: 10px;
}
.section h2 {
color: #fff;
font-size: 6em;
font-weight: 200;
text-align: center;
padding: 2.5em 0;
}
.one {
background: #6bb6ff;
}
.two {
background: #1E90FF;
}
.three {
background: #8B4789;
}
.four {
background: #872657;
}
Also, here is a rough fiddle.
The following line (#136 in big.css) is the culprit:
font: 300 1em/1.5 'Merriweather', serif;
This overwrites the previous font declaration of "Roboto" to "Merriweather", which isn't loaded anywhere.
Also, don't forget to add a trailing semicolon to font-family: "Roboto", sans-serif.
Your browser's builtin developer tools, namely the element inspector, are your best friend when it comes to troubleshooting CSS.
In this particular case, I opened the Chrome Dev Tools element inspector by pressing CTRL+SHIFT+I, navigated to the "Elements" tab (you can also right-click a specific element) and looked through the CSS rules applied the the body element, which revealed the overwrite:
A strike-through informs you that a rule wasn't applied, possibly because it is invalid or another rule took precedence.
Related
I have a div that has a transparent black so that the actual background color still shows but darkened. Inside this div I have a div with text.
So when added the text to my div I realized it had 2 "scrollable" sections, one for the div with the content and another one for the background div which has 100% width.
The end result should just be one scroll that goes through the page's height and reaches the footer.
Instead, right now I have to scroll inside the content div to see all the text and only when I place the mouse on the background div in the sides I'm able to reach the end of the page.
Here is the Code:
Maybe I am using the wrong elements or there is another way to get the same effect that I am trying to achieve.
*
{
-webkit-font-smoothing: antialiased;
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Courier New', monospace;
}
body
{
/*background: linear-gradient(-45deg, #ff933b, #e73c7e, #27e1ee, #20f3c2);*/
background: linear-gradient(-45deg, #ffe1c8, #ffebf3, #e6ebeb, #eeebd5);
background-size: 400% 400%;
animation: gradient 20s ease infinite;
height: 100vh;
}
#keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
header
{
z-index: 10;
backface-visibility: hidden;
background: inherit;
transition: 0.4s;
position: sticky;
top: 0;
left: 0;
width: 100%;
padding: 1%;
display: flex;
gap: 5%;
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.637);
}
header .logo
{
position: absolute;
left: 5%;
transition: all 0.2s;
max-height: 65px;
}
header .topper
{
transition: ease-in;
transition-duration: 0.4s;
color: black;
text-decoration: none;
text-transform: uppercase;
padding-left: 17%;
letter-spacing: 1%;
font-size: 50px;
}
header ul
{
position: absolute;
display: flex;
gap: 5%;
list-style: none;
}
header ul li
{
padding-left: 4%;
}
header ul li a
{
transition: ease-in;
text-decoration: none;
color: black;
font-size: 20px;
letter-spacing: 2%;
}
header ul li label
{
transition: ease-in;
font-size: 30px;
margin-left: 100%;
}
header ul li a:hover
{
color: rgb(255, 255, 255);
font-weight: 300;
border: 2px rgba(255, 255, 255, 0.459);
text-shadow: 2px 2px 3px rgb(0, 0, 0);
transition: ease-in;
font-weight: 200;
transition-duration: 0.4s;
}
header ul li label:hover
{
color: rgb(255, 255, 255);
font-weight: 300;
border: 2px rgba(255, 255, 255, 0.459);
text-shadow: 2px 2px 3px rgb(0, 0, 0);
transition: ease-in;
font-weight: 200;
transition-duration: 0.4s;
}
header .topper:hover
{
color: rgb(255, 255, 255);
transition: ease-in;
transition-duration: 0.4s;
text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.466);
}
div ::-webkit-scrollbar {
display: none;
}
div ::selection {
background: rgba(255, 207, 144, 0.822);
color: black;
}
div .main
{
position: sticky;
color: white;
overflow: auto;
height: 100vh;
z-index: 0;
width: 100%;
background: rgba(0, 0, 0, 0.712);
padding-left: 13.7%;
padding-right: 13.7%;
}
div.content
{
color: white;
overflow: auto;
height: 100vh;
z-index: 1;
padding-left: 5%;
padding-right: 4%;
background: rgba(0, 0, 0, 0.384);;
}
div.content p
{
margin-top: 16px;
}
div.content h1
{
margin-top: 30px;
}
footer
{
z-index: 1;
backface-visibility: hidden;
background: inherit;
width: 100%;
padding: 25px 10%;
box-shadow: -3px -2px 9px rgba(0, 0, 0, 0.637);
}
footer div.footer
{
flex-direction: column;
display: flex;
list-style: none;;
}
<!DOCTYPE html>
<html>
<head>
<title>Lorem ipsum</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js" defer></script>
<script src="Script.js" defer></script>
<link rel="stylesheet" href="Style.css" media="screen" type="text/css">
</head>
<body>
<header id="header">
<img src="images/MainLogo/logo.png" class="logo" id="mainLogo"></img>
Lorem ipsum
<ul id="ul">
<li>Home</li>
<li>About</li>
<li>Work</li>
<li>Contact</li>
<li><label class="mobileButton" for="hamburger" id="burguerButton">☰</label></li>
</ul>
</header>
<div>
<div class="main" id="mainContainer">
<div class="content" id="contentContainer">
<h1>Lorem ipsum</h1>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras in tristique nisi. Aliquam ligula mi, euismod id augue sit amet, malesuada pellentesque purus. Sed scelerisque dictum pellentesque.
Nunc tincidunt nibh id mi maximus rutrum ac ut enim. Etiam accumsan diam eget blandit pulvinar.
Mauris scelerisque nisl at magna facilisis vestibulum. Morbi mattis, nunc et vestibulum dignissim, magna odio tincidunt velit, at ullamcorper lacus urna at dolor.
Vivamus et tortor nec diam eleifend condimentum. Nunc ut ex vel ligula dapibus scelerisque eget in dolor. Pellentesque congue varius convallis. Curabitur efficitur volutpat orci, nec rutrum magna tempor eget.
Maecenas bibendum hendrerit cursus. Nulla vehicula tristique turpis ac dictum. Vivamus quis lobortis sapien, vel aliquet magna. Suspendisse porta ex eros, at tempor nisl maximus sed.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras in tristique nisi. Aliquam ligula mi, euismod id augue sit amet, malesuada pellentesque purus. Sed scelerisque dictum pellentesque.
Nunc tincidunt nibh id mi maximus rutrum ac ut enim. Etiam accumsan diam eget blandit pulvinar.
Mauris scelerisque nisl at magna facilisis vestibulum. Morbi mattis, nunc et vestibulum dignissim, magna odio tincidunt velit, at ullamcorper lacus urna at dolor.
Vivamus et tortor nec diam eleifend condimentum. Nunc ut ex vel ligula dapibus scelerisque eget in dolor. Pellentesque congue varius convallis. Curabitur efficitur volutpat orci, nec rutrum magna tempor eget.
Maecenas bibendum hendrerit cursus. Nulla vehicula tristique turpis ac dictum. Vivamus quis lobortis sapien, vel aliquet magna. Suspendisse porta ex eros, at tempor nisl maximus sed.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras in tristique nisi. Aliquam ligula mi, euismod id augue sit amet, malesuada pellentesque purus. Sed scelerisque dictum pellentesque.
Nunc tincidunt nibh id mi maximus rutrum ac ut enim. Etiam accumsan diam eget blandit pulvinar.
Mauris scelerisque nisl at magna facilisis vestibulum. Morbi mattis, nunc et vestibulum dignissim, magna odio tincidunt velit, at ullamcorper lacus urna at dolor.
Vivamus et tortor nec diam eleifend condimentum. Nunc ut ex vel ligula dapibus scelerisque eget in dolor. Pellentesque congue varius convallis. Curabitur efficitur volutpat orci, nec rutrum magna tempor eget.
Maecenas bibendum hendrerit cursus. Nulla vehicula tristique turpis ac dictum. Vivamus quis lobortis sapien, vel aliquet magna. Suspendisse porta ex eros, at tempor nisl maximus sed.
</p>
</div>
</div>
</div>
</body>
<footer>
</footer>
</html>
Scrolling sections are creating by using overflow:auto in CSS. If you remove those you get a single scroll bar for the whole page. However, you will have other problems with overlapping divs that you will need to fix.
*
{
-webkit-font-smoothing: antialiased;
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Courier New', monospace;
}
body
{
/*background: linear-gradient(-45deg, #ff933b, #e73c7e, #27e1ee, #20f3c2);*/
background: linear-gradient(-45deg, #ffe1c8, #ffebf3, #e6ebeb, #eeebd5);
background-size: 400% 400%;
animation: gradient 20s ease infinite;
height: 100vh;
}
#keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
header
{
z-index: 10;
backface-visibility: hidden;
background: inherit;
transition: 0.4s;
position: sticky;
top: 0;
left: 0;
width: 100%;
padding: 1%;
display: flex;
gap: 5%;
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.637);
}
header .logo
{
position: absolute;
left: 5%;
transition: all 0.2s;
max-height: 65px;
}
header .topper
{
transition: ease-in;
transition-duration: 0.4s;
color: black;
text-decoration: none;
text-transform: uppercase;
padding-left: 17%;
letter-spacing: 1%;
font-size: 50px;
}
header ul
{
position: absolute;
display: flex;
gap: 5%;
list-style: none;
}
header ul li
{
padding-left: 4%;
}
header ul li a
{
transition: ease-in;
text-decoration: none;
color: black;
font-size: 20px;
letter-spacing: 2%;
}
header ul li label
{
transition: ease-in;
font-size: 30px;
margin-left: 100%;
}
header ul li a:hover
{
color: rgb(255, 255, 255);
font-weight: 300;
border: 2px rgba(255, 255, 255, 0.459);
text-shadow: 2px 2px 3px rgb(0, 0, 0);
transition: ease-in;
font-weight: 200;
transition-duration: 0.4s;
}
header ul li label:hover
{
color: rgb(255, 255, 255);
font-weight: 300;
border: 2px rgba(255, 255, 255, 0.459);
text-shadow: 2px 2px 3px rgb(0, 0, 0);
transition: ease-in;
font-weight: 200;
transition-duration: 0.4s;
}
header .topper:hover
{
color: rgb(255, 255, 255);
transition: ease-in;
transition-duration: 0.4s;
text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.466);
}
div ::-webkit-scrollbar {
display: none;
}
div ::selection {
background: rgba(255, 207, 144, 0.822);
color: black;
}
div .main
{
position: sticky;
color: white;
height: 100vh;
z-index: 0;
width: 100%;
background: rgba(0, 0, 0, 0.712);
padding-left: 13.7%;
padding-right: 13.7%;
}
div.content
{
color: white;
height: 100vh;
z-index: 1;
padding-left: 5%;
padding-right: 4%;
background: rgba(0, 0, 0, 0.384);;
}
div.content p
{
margin-top: 16px;
}
div.content h1
{
margin-top: 30px;
}
footer
{
z-index: 1;
backface-visibility: hidden;
background: inherit;
width: 100%;
padding: 25px 10%;
box-shadow: -3px -2px 9px rgba(0, 0, 0, 0.637);
}
footer div.footer
{
flex-direction: column;
display: flex;
list-style: none;;
}
<!DOCTYPE html>
<html>
<head>
<title>Lorem ipsum</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js" defer></script>
<script src="Script.js" defer></script>
<link rel="stylesheet" href="Style.css" media="screen" type="text/css">
</head>
<body>
<header id="header">
<img src="images/MainLogo/logo.png" class="logo" id="mainLogo"></img>
Lorem ipsum
<ul id="ul">
<li>Home</li>
<li>About</li>
<li>Work</li>
<li>Contact</li>
<li><label class="mobileButton" for="hamburger" id="burguerButton">☰</label></li>
</ul>
</header>
<div>
<div class="main" id="mainContainer">
<div class="content" id="contentContainer">
<h1>Lorem ipsum</h1>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras in tristique nisi. Aliquam ligula mi, euismod id augue sit amet, malesuada pellentesque purus. Sed scelerisque dictum pellentesque.
Nunc tincidunt nibh id mi maximus rutrum ac ut enim. Etiam accumsan diam eget blandit pulvinar.
Mauris scelerisque nisl at magna facilisis vestibulum. Morbi mattis, nunc et vestibulum dignissim, magna odio tincidunt velit, at ullamcorper lacus urna at dolor.
Vivamus et tortor nec diam eleifend condimentum. Nunc ut ex vel ligula dapibus scelerisque eget in dolor. Pellentesque congue varius convallis. Curabitur efficitur volutpat orci, nec rutrum magna tempor eget.
Maecenas bibendum hendrerit cursus. Nulla vehicula tristique turpis ac dictum. Vivamus quis lobortis sapien, vel aliquet magna. Suspendisse porta ex eros, at tempor nisl maximus sed.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras in tristique nisi. Aliquam ligula mi, euismod id augue sit amet, malesuada pellentesque purus. Sed scelerisque dictum pellentesque.
Nunc tincidunt nibh id mi maximus rutrum ac ut enim. Etiam accumsan diam eget blandit pulvinar.
Mauris scelerisque nisl at magna facilisis vestibulum. Morbi mattis, nunc et vestibulum dignissim, magna odio tincidunt velit, at ullamcorper lacus urna at dolor.
Vivamus et tortor nec diam eleifend condimentum. Nunc ut ex vel ligula dapibus scelerisque eget in dolor. Pellentesque congue varius convallis. Curabitur efficitur volutpat orci, nec rutrum magna tempor eget.
Maecenas bibendum hendrerit cursus. Nulla vehicula tristique turpis ac dictum. Vivamus quis lobortis sapien, vel aliquet magna. Suspendisse porta ex eros, at tempor nisl maximus sed.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras in tristique nisi. Aliquam ligula mi, euismod id augue sit amet, malesuada pellentesque purus. Sed scelerisque dictum pellentesque.
Nunc tincidunt nibh id mi maximus rutrum ac ut enim. Etiam accumsan diam eget blandit pulvinar.
Mauris scelerisque nisl at magna facilisis vestibulum. Morbi mattis, nunc et vestibulum dignissim, magna odio tincidunt velit, at ullamcorper lacus urna at dolor.
Vivamus et tortor nec diam eleifend condimentum. Nunc ut ex vel ligula dapibus scelerisque eget in dolor. Pellentesque congue varius convallis. Curabitur efficitur volutpat orci, nec rutrum magna tempor eget.
Maecenas bibendum hendrerit cursus. Nulla vehicula tristique turpis ac dictum. Vivamus quis lobortis sapien, vel aliquet magna. Suspendisse porta ex eros, at tempor nisl maximus sed.
</p>
</div>
</div>
</div>
</body>
<footer>
</footer>
</html>
You should remove
height: 100vh;
from both div.main and div.content CSS selectors. Because defining the height of the divs is what makes the scroll bar appear.
Here is the CodeSandBox Link.
https://codesandbox.io/s/frosty-bogdan-m22tdj?file=/Style.css
I have copied and paste the following code and I want to apply this to my website. It should float at the right bottom.
I'm just a noob, I haven't tried anything, since I just don't know.
<div class="float" />
<div class="dot" />
<div class="at-about-fab">
<div class="at-about-fab__thumbnail">
<img alt="verkoper" src="https://d2tyltutevw8th.cloudfront.net/media/image/trump-round-1500174198.jpg" />
</div>
<div class="at-about-fab__meta">
<h2>Call us now!</h2>
<p>12345567890</p>
</div>
</div>
</div>
.float{
position:fixed;
width:290px;
height:100px;
bottom:14px;
right:10px;
background-color:4d4d4d;
opacity: 0.1;
border-radius:50px;
box-shadow: 2px 2px 3px #999;
opacity=50;
}
.dot {
position: absolute;
right: 215px;
display:block;
z-index:1000000;
bottom: 30px;
height: 35px;
width: 35px;
background-color: #bbb;
border-radius: 50%;
width: 14px;
height: 14px;
background: #228B22;
-webkit-transition:opacity 0.2s ease;
-moz-transition:opacity 0.2s ease;
-o-transition:opacity 0.2s ease;
}
.dot:hover{
// Red(0-255), Blue(0-255), Green(0-255), Alpha (0-1)
background-color:rgba(100,100,100,0);
opacity:0;
}
.at-about-fab {
z-index: 999999;
position: fixed;
right: 40px;
bottom: 40px;
display: flex;
align-items: center;
flex-direction: row;
}
.at-about-fab:hover .at-about-fab__meta {
opacity: 1;
}
.at-about-fab__thumbnail {
position: absolute;
top: 50%;
left: -88px;
background: #FFFFFF;
width: 78px;
height: 78px;
border: 4px solid #EEEEEE;
border-radius: 100%;
padding: 1px;
box-sizing: border-box;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
overflow: show;
cursor: pointer;
}
.at-about-fab__thumbnail img {
display: block;
width: 100%;
border-radius: 100%;
}
.at-about-fab__meta {
font-family: 'Open Sans', sans-serif;
opacity: 1;
transition: 0.2s ease;
}
.at-about-fab__meta h2,
.at-about-fab__meta p {
margin: 0;
padding: 0;
}
.at-about-fab__meta h2 {
color: #444444;
font-size: 14px;
font-weight: 500;
}
.at-about-fab__meta p {
color: #1a9228;
font-size: 24px;
font-weight: 300;
}
.at-about-fab__meta a {
color: inherit;
font-weight: 700;
text-decoration: none;
}
I want just everything floating at the right corner, i cannot seperate css and html since its going via tag manager.
By the way, I also please want to blur the background of the class=float, but do not know how.
Can someone help me?
So I checked your code and there were a few typos. First there is a </div> too much. And in your css you use opacity, change the = to :. Also the dot position has to be fixed and not absolute. And for the blur you can add this backdrop-filter: blur(10px);
.float{
position:fixed;
width:290px;
height:100px;
bottom:14px;
right:10px;
background-color:4d4d4d;
opacity: 0.1;
border-radius:50px;
box-shadow: 2px 2px 3px #999;
opacity:50;
backdrop-filter: blur(10px);
}
.dot {
position: fixed;
right: 215px;
display:block;
z-index:1000000;
bottom: 30px;
height: 35px;
width: 35px;
background-color: #bbb;
border-radius: 50%;
width: 14px;
height: 14px;
background: #228B22;
-webkit-transition:opacity 0.2s ease;
-moz-transition:opacity 0.2s ease;
-o-transition:opacity 0.2s ease;
}
.dot:hover{
background-color:rgba(100,100,100,0);
opacity:0;
}
.at-about-fab {
z-index: 999999;
position: fixed;
right: 40px;
bottom: 40px;
display: flex;
align-items: center;
flex-direction: row;
}
.at-about-fab:hover .at-about-fab__meta {
opacity: 1;
}
.at-about-fab__thumbnail {
position: absolute;
top: 50%;
left: -88px;
background: #FFFFFF;
width: 78px;
height: 78px;
border: 4px solid #EEEEEE;
border-radius: 100%;
padding: 1px;
box-sizing: border-box;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
overflow: show;
cursor: pointer;
}
.at-about-fab__thumbnail img {
display: block;
width: 100%;
border-radius: 100%;
}
.at-about-fab__meta {
font-family: 'Open Sans', sans-serif;
opacity: 1;
transition: 0.2s ease;
}
.at-about-fab__meta h2,
.at-about-fab__meta p {
margin: 0;
padding: 0;
}
.at-about-fab__meta h2 {
color: #444444;
font-size: 14px;
font-weight: 500;
}
.at-about-fab__meta p {
color: #1a9228;
font-size: 24px;
font-weight: 300;
}
.at-about-fab__meta a {
color: inherit;
font-weight: 700;
text-decoration: none;
}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui.
Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia.
Nam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi.
Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis.
Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis diam. Pellentesque ut neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
In dui magna, posuere eget, vestibulum et, tempor auctor, justo. In ac felis quis tortor malesuada pretium. Pellentesque auctor neque nec urna. Proin sapien ipsum, porta a, auctor quis, euismod ut, mi. Aenean viverra rhoncus pede. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut non enim eleifend felis pretium feugiat. Vivamus quis mi. Phasellus a est. Phasellus magna.
<div class="float">
</div>
<div class="dot"></div>
<div class="at-about-fab">
<div class="at-about-fab__thumbnail">
<img alt="verkoper" src="https://d2tyltutevw8th.cloudfront.net/media/image/trump-round-1500174198.jpg" />
</div>
<div class="at-about-fab__meta">
<h2>Call us now!</h2>
<p>12345567890</p>
</div>
</div>
Hello #Rick float is the property of the class, not a class. Use following style.
.your_class_name
{
float: right; /* Left or right depends on your design */
}
I have a pure CSS menu that is causing me some issues mostly on small screens/mobile devices.
Issue 1
When the menu is open the background is still scrollable. I would like the focus to be on the menu, and therefore the background would not scroll when the menu is open.
Issue 2
On a small screen the menu items are collapsed by default and expand once clicked on to show submenu. If one or two are expanded and the content goes beyond the devices window there is no way to scroll down to see the content outside of the current window view. If the menu is expanded it needs to be scrollable.
I experimented with the overflow property but can't fix the issue. hoping someone know how. Thanks!
body {
margin: 0;
font-family: serif;
background-color: #f4f4f4;
}
html {
color: #222;
font-size: 1.2em;
line-height: 1;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
/* ==========================================================================
Global Header
========================================================================== */
.global-nav {
/*overflow: hidden;*/
background-color: #FFF;
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 9999;
padding: 28px 0 0 0;
}
.header {
background-color: #fff;
margin: 0 auto;
width: 1170px;
z-index: 3;
clear: both;
}
.header div.menu {
overflow: hidden;
background-color: #fff;
padding: 20px 0 0 0;
-webkit-box-shadow: 0px 3px 3px 0px rgba(136,136,136,1);
-moz-box-shadow: 0px 3px 3px 0px rgba(136,136,136,1);
box-shadow: 0px 3px 3px 0px rgba(136,136,136,1);
z-index: 99999999;
}
.header img {
vertical-align: baseline;
}
.header div.menu ul.menu-links {
margin: 0;
padding: 0;
list-style: none;
}
.menu-col-one {
width: 25%;
float: left;
position: relative;
padding-bottom: 60px;
}
.menu-col-two {
width: 25%;
float: left;
position: relative;
padding-bottom: 60px;
}
.menu-col-three {
width: 25%;
float: left;
position: relative;
padding-bottom: 60px;
}
.menu-col-four {
width: 25%;
float: left;
position: relative;
padding-bottom: 60px;
}
.menu-col-five {
display: none;
}
.header div.menu ul.menu-links li a {
display: block;
padding: 20px 0 0 0;
}
.header .menu {
clear: both;
max-height: 0;
transition: max-height .2s ease-out;
width: 100%;
position: fixed;
left: 0;
}
.header .menu-icon {
cursor: pointer;
display: inline-block;
padding: 31px 32px 25px 0;
position: relative;
}
.header .menu-icon .navicon {
background: #00539D;
display: block;
height: 2px;
position: relative;
transition: background .2s ease-out;
width: 40px;
}
.header .menu-icon .navicon:before, .header .menu-icon .navicon:after {
background: #00539D;
content: '';
display: block;
height: 100%;
position: absolute;
transition: all .2s ease-out;
width: 100%;
}
.header .menu-icon .navicon:before {
top: 12px;
}
.header .menu-icon .navicon:after {
top: -12px;
}
.header .menu-btn {
display: none;
}
.header .menu-btn:checked ~ .menu {
max-height: 100%;
}
.header .menu-btn:checked ~ .menu-icon .navicon {
background: transparent;
}
.header .menu-btn:checked ~ .menu-icon .navicon:before {
transform: rotate(-45deg);
}
.header .menu-btn:checked ~ .menu-icon .navicon:after {
transform: rotate(45deg);
}
.header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:before, .header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:after {
top: 0;
}
.ac-container {
width: 1170px;
margin: 40px auto 30px auto;
text-align: left;
}
.ac-container article {
overflow: visible;
padding-right: 30px;
}
.ac-container input {
display: none;
}
.ac-container label {
position: relative;
z-index: 20;
display: block;
cursor: pointer;
font-size: 25px;
}
#media only screen and (max-width: 1169px) {
.header {
margin: 0 2%;
width: 96%;
padding-right: 0;
}
.ac-container {
width: 96%;
padding: 0 2%;
}
}
#media only screen and (max-width: 970px) {
.global-nav {
padding: 14px 0 0 0;
}
.header .menu-icon {
padding: 31px 1% 25px 0;
}
.header-content-right {
display: none;
}
.header div.menu {
margin-top: 0px;
}
.header div.menu ul.menu-links {
margin: 0;
}
.menu-col-one {
width: 100%;
border-bottom: 1px solid #f1f1f1;
margin-left: 0%;
margin-bottom: 30px;
padding-bottom: 25px;
}
.menu-col-two {
width: 100%;
border-bottom: 1px solid #f1f1f1;
margin-bottom: 30px;
padding-bottom: 25px;
}
.menu-col-three {
width: 100%;
border-bottom: 1px solid #f1f1f1;
margin-bottom: 30px;
padding-bottom: 25px;
}
.menu-col-four {
width: 100%;
margin-right: 0%;
margin-bottom: 30px;
padding-bottom: 25px;
}
.menu-col-five {
width: 100%;
margin-right: 0%;
display: block;
}
.header div.menu ul li.list-header {
display: block !important;
}
.header div.menu ul li.list-item {
display: none;
}
.ac-container label {
font-size: 16px;
color: #636c76;
font-weight: bold;
letter-spacing: 0.2px;
}
.ac-container input:checked + label, .ac-container input:checked + label:hover {
color: #454545;
}
.ac-container input + label:after {
content: '';
position: absolute;
width: 24px;
height: 24px;
right: 13px;
top: -6px;
}
.ac-container article {
background: rgba(255, 255, 255, 0.5);
margin-top: -1px;
overflow: hidden;
position: relative;
z-index: 10;
-webkit-transition: max-height 0.3s ease-out, box-shadow 0.6s linear;
-moz-transition: max-height 0.3s ease-out, box-shadow 0.6s linear;
-o-transition: max-height 0.3s ease-out, box-shadow 0.6s linear;
-ms-transition: max-height 0.3s ease-out, box-shadow 0.6s linear;
transition: max-height 0.3s ease-out, box-shadow 0.6s linear;
max-height: 0;
font-size: 14px;
}
.ac-container article a {
color: #636c76;
}
.ac-container article p {
line-height: 23px;
font-size: 14px;
padding: 20px;
}
.ac-container article ul li {
padding: 10px 0;
}
.ac-container article ul li span {
display: none;
}
.ac-container input:checked ~ article {
-webkit-transition: max-height 0.5s ease-in, box-shadow 0.1s linear;
-moz-transition: max-height 0.5s ease-in, box-shadow 0.1s linear;
-o-transition: max-height 0.5s ease-in, box-shadow 0.1s linear;
-ms-transition: max-height 0.5s ease-in, box-shadow 0.1s linear;
transition: max-height 0.5s ease-in, box-shadow 0.1s linear;
max-height: 500px;/*added*/
}
}
<!-- [Start] Header Section-->
<section class="global-nav" role="region" aria-label="globalnav">
<header class="header" role="banner">
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn"><span class="navicon"></span></label>
<div class="menu">
<section class="ac-container">
<div class="menu-col-one">
<input id="ac-1" name="accordion-1" type="checkbox" />
<label for="ac-1">DD 1</label>
<article class="ac-small">
<ul class="menu-links">
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
</ul>
</article>
</div>
<div class="menu-col-two">
<input id="ac-2" name="accordion-1" type="checkbox" />
<label for="ac-2">DD 2</label>
<article class="ac-medium">
<ul class="menu-links">
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
</ul>
</article>
</div>
<div class="menu-col-three">
<input id="ac-3" name="accordion-1" type="checkbox" />
<label for="ac-3">DD 3</label>
<article class="ac-large">
<ul class="menu-links">
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
</ul>
</article>
</div>
<div class="menu-col-four">
<input id="ac-4" name="accordion-1" type="checkbox" />
<label for="ac-4">DD 4</label>
<article class="ac-large">
<ul class="menu-links">
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
</ul>
</article>
</div>
<div class="menu-col-five">
<div class="btn-group">
<button class="btn">Button</button>
<button class="btn">Button</button>
<button class="btn">Button</button>
</div>
</div>
</section>
</div>
</header>
</section>
<!-- [End] Header Section-->
<!-- [Start] Main Content -->
<main role="main">
<p><span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span> Nullam velit nulla, sagittis non massa et, volutpat ullamcorper nunc. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque in dui quis justo consectetur feugiat et a dui. Integer eget justo eleifend, mattis lectus dictum, fermentum urna. Integer vitae elit non sem vehicula euismod sed non massa. Sed ac lacus tempus, pharetra lectus vel, vehicula felis. Sed pharetra viverra nisi sed euismod.</p>
<p>Nam sodales, massa non eleifend dignissim, diam felis suscipit eros, at semper diam justo ut arcu. Duis molestie nec nisi a maximus. Vestibulum in congue risus. Suspendisse potenti. Aliquam sodales neque ac pulvinar facilisis. Curabitur a lacinia ante. Mauris tempus risus lorem, vitae fermentum dolor congue in. Fusce at tristique dolor. Etiam pellentesque lectus malesuada risus malesuada luctus. Pellentesque quis quam vulputate, sagittis orci eget, egestas purus. Proin pulvinar felis et risus placerat lacinia.</p>
<p>In condimentum fermentum efficitur. Mauris non eros ac leo aliquam euismod eget ac metus. Aenean nec eros quis orci eleifend scelerisque. Aliquam finibus vestibulum efficitur. Quisque faucibus id tortor ac gravida. Maecenas eros sapien, mollis eu libero id, faucibus viverra velit. Fusce id blandit quam. Nullam vitae mi lorem. Cras vitae tortor placerat, viverra tellus ut, mattis enim. Aenean sit amet ante tortor. Pellentesque et dignissim urna.</p>
<p>Morbi in mollis neque, et elementum libero. Sed luctus, metus a posuere tempor, magna ante tempor leo, tempus ultrices nulla est sit amet ipsum. Curabitur bibendum aliquet erat eget interdum. Duis a egestas mi, et molestie lacus. Quisque in lorem nisi. Nulla vestibulum arcu est. Morbi blandit lacinia eleifend.</p>
<p>Quisque malesuada ex non dui dapibus, vitae pellentesque lacus hendrerit. Pellentesque euismod id elit non auctor. Sed tempus cursus vulputate. Praesent posuere ligula nunc. Fusce libero tellus, semper in justo fringilla, dignissim accumsan nulla. Nunc semper magna metus, sit amet vehicula urna aliquet id. Donec urna sem, pellentesque id justo a, rutrum maximus dui. Fusce vel condimentum purus. Vestibulum ultricies, massa eget aliquet imperdiet, orci quam luctus ante, in ornare tortor dui at lectus. Vivamus eget luctus felis. Sed pretium ornare vulputate. Nam in vulputate nisi. Fusce magna nibh, placerat et nulla eu, vulputate posuere sapien. Suspendisse sagittis enim ut semper efficitur. Fusce dignissim enim sed magna gravida, et pretium erat ultrices. Nulla dui augue, scelerisque vel leo nec, tempor auctor purus. </p>
<p><span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span> Nullam velit nulla, sagittis non massa et, volutpat ullamcorper nunc. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque in dui quis justo consectetur feugiat et a dui. Integer eget justo eleifend, mattis lectus dictum, fermentum urna. Integer vitae elit non sem vehicula euismod sed non massa. Sed ac lacus tempus, pharetra lectus vel, vehicula felis. Sed pharetra viverra nisi sed euismod.</p>
<p>Nam sodales, massa non eleifend dignissim, diam felis suscipit eros, at semper diam justo ut arcu. Duis molestie nec nisi a maximus. Vestibulum in congue risus. Suspendisse potenti. Aliquam sodales neque ac pulvinar facilisis. Curabitur a lacinia ante. Mauris tempus risus lorem, vitae fermentum dolor congue in. Fusce at tristique dolor. Etiam pellentesque lectus malesuada risus malesuada luctus. Pellentesque quis quam vulputate, sagittis orci eget, egestas purus. Proin pulvinar felis et risus placerat lacinia.</p>
<p>In condimentum fermentum efficitur. Mauris non eros ac leo aliquam euismod eget ac metus. Aenean nec eros quis orci eleifend scelerisque. Aliquam finibus vestibulum efficitur. Quisque faucibus id tortor ac gravida. Maecenas eros sapien, mollis eu libero id, faucibus viverra velit. Fusce id blandit quam. Nullam vitae mi lorem. Cras vitae tortor placerat, viverra tellus ut, mattis enim. Aenean sit amet ante tortor. Pellentesque et dignissim urna.</p>
<p>Morbi in mollis neque, et elementum libero. Sed luctus, metus a posuere tempor, magna ante tempor leo, tempus ultrices nulla est sit amet ipsum. Curabitur bibendum aliquet erat eget interdum. Duis a egestas mi, et molestie lacus. Quisque in lorem nisi. Nulla vestibulum arcu est. Morbi blandit lacinia eleifend.</p>
<p>Quisque malesuada ex non dui dapibus, vitae pellentesque lacus hendrerit. Pellentesque euismod id elit non auctor. Sed tempus cursus vulputate. Praesent posuere ligula nunc. Fusce libero tellus, semper in justo fringilla, dignissim accumsan nulla. Nunc semper magna metus, sit amet vehicula urna aliquet id. Donec urna sem, pellentesque id justo a, rutrum maximus dui. Fusce vel condimentum purus. Vestibulum ultricies, massa eget aliquet imperdiet, orci quam luctus ante, in ornare tortor dui at lectus. Vivamus eget luctus felis. Sed pretium ornare vulputate. Nam in vulputate nisi. Fusce magna nibh, placerat et nulla eu, vulputate posuere sapien. Suspendisse sagittis enim ut semper efficitur. Fusce dignissim enim sed magna gravida, et pretium erat ultrices. Nulla dui augue, scelerisque vel leo nec, tempor auctor purus. </p>
<p><span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span> Nullam velit nulla, sagittis non massa et, volutpat ullamcorper nunc. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque in dui quis justo consectetur feugiat et a dui. Integer eget justo eleifend, mattis lectus dictum, fermentum urna. Integer vitae elit non sem vehicula euismod sed non massa. Sed ac lacus tempus, pharetra lectus vel, vehicula felis. Sed pharetra viverra nisi sed euismod.</p>
<p>Nam sodales, massa non eleifend dignissim, diam felis suscipit eros, at semper diam justo ut arcu. Duis molestie nec nisi a maximus. Vestibulum in congue risus. Suspendisse potenti. Aliquam sodales neque ac pulvinar facilisis. Curabitur a lacinia ante. Mauris tempus risus lorem, vitae fermentum dolor congue in. Fusce at tristique dolor. Etiam pellentesque lectus malesuada risus malesuada luctus. Pellentesque quis quam vulputate, sagittis orci eget, egestas purus. Proin pulvinar felis et risus placerat lacinia.</p>
<p>In condimentum fermentum efficitur. Mauris non eros ac leo aliquam euismod eget ac metus. Aenean nec eros quis orci eleifend scelerisque. Aliquam finibus vestibulum efficitur. Quisque faucibus id tortor ac gravida. Maecenas eros sapien, mollis eu libero id, faucibus viverra velit. Fusce id blandit quam. Nullam vitae mi lorem. Cras vitae tortor placerat, viverra tellus ut, mattis enim. Aenean sit amet ante tortor. Pellentesque et dignissim urna.</p>
<p>Morbi in mollis neque, et elementum libero. Sed luctus, metus a posuere tempor, magna ante tempor leo, tempus ultrices nulla est sit amet ipsum. Curabitur bibendum aliquet erat eget interdum. Duis a egestas mi, et molestie lacus. Quisque in lorem nisi. Nulla vestibulum arcu est. Morbi blandit lacinia eleifend.</p>
<p>Quisque malesuada ex non dui dapibus, vitae pellentesque lacus hendrerit. Pellentesque euismod id elit non auctor. Sed tempus cursus vulputate. Praesent posuere ligula nunc. Fusce libero tellus, semper in justo fringilla, dignissim accumsan nulla. Nunc semper magna metus, sit amet vehicula urna aliquet id. Donec urna sem, pellentesque id justo a, rutrum maximus dui. Fusce vel condimentum purus. Vestibulum ultricies, massa eget aliquet imperdiet, orci quam luctus ante, in ornare tortor dui at lectus. Vivamus eget luctus felis. Sed pretium ornare vulputate. Nam in vulputate nisi. Fusce magna nibh, placerat et nulla eu, vulputate posuere sapien. Suspendisse sagittis enim ut semper efficitur. Fusce dignissim enim sed magna gravida, et pretium erat ultrices. Nulla dui augue, scelerisque vel leo nec, tempor auctor purus. </p>
<!-- [End] Main Content -->
</main>
Quick answer:
Add overflow: auto on the main and .menu
Add height: 100% to html, body, main.
Add max-height: 100% to .menu
Made header smaller by 17px and only displayed box-shadow on the bottom. You'll have to override this for mobile devices where the scrollbar is completely removed, though...
Personally, I would just add a padding at the top of the body, then let the menu slide over the content. It would be the most elegant.
body {
margin: 0;
font-family: serif;
background-color: #f4f4f4;
height: 100%; /* My code */
}
html {
color: #222;
font-size: 1.2em;
line-height: 1;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
height: 100%; /* My code */
overflow: hidden; /* My code */
}
/* My code */
main {
height: 100%;
overflow: auto;
}
/* ==========================================================================
Global Header
========================================================================== */
.global-nav {
/*overflow: hidden;*/
background-color: #FFF;
position: fixed;
top: 0;
left: 0;
width: calc(100% - 17px); /* My code */
z-index: 9999;
padding: 28px 0 0 0;
}
.header {
background-color: #fff;
margin: 0 auto;
width: 1170px;
z-index: 3;
clear: both;
}
.header div.menu {
overflow: hidden;
background-color: #fff;
padding: 20px 0 0 0;
-webkit-box-shadow: 0px 5px 3px -3px rgba(136,136,136,1); /* My code */
-moz-box-shadow: 0px 5px 3px -3px rgba(136,136,136,1); /* My code */
box-shadow: 0px 5px 3px -3px rgba(136,136,136,1); /* My code */
z-index: 99999999;
}
.header img {
vertical-align: baseline;
}
.header div.menu ul.menu-links {
margin: 0;
padding: 0;
list-style: none;
}
.menu-col-one {
width: 25%;
float: left;
position: relative;
padding-bottom: 60px;
}
.menu-col-two {
width: 25%;
float: left;
position: relative;
padding-bottom: 60px;
}
.menu-col-three {
width: 25%;
float: left;
position: relative;
padding-bottom: 60px;
}
.menu-col-four {
width: 25%;
float: left;
position: relative;
padding-bottom: 60px;
}
.menu-col-five {
display: none;
}
.header div.menu ul.menu-links li a {
display: block;
padding: 20px 0 0 0;
}
.header .menu {
clear: both;
max-height: 0;
transition: max-height .2s ease-out;
width: calc(100% - 17px); /* My code */
position: fixed;
left: 0;
}
.header .menu-icon {
cursor: pointer;
display: inline-block;
padding: 31px 32px 25px 0;
position: relative;
}
.header .menu-icon .navicon {
background: #00539D;
display: block;
height: 2px;
position: relative;
transition: background .2s ease-out;
width: 40px;
}
.header .menu-icon .navicon:before, .header .menu-icon .navicon:after {
background: #00539D;
content: '';
display: block;
height: 100%;
position: absolute;
transition: all .2s ease-out;
width: 100%;
}
.header .menu-icon .navicon:before {
top: 12px;
}
.header .menu-icon .navicon:after {
top: -12px;
}
.header .menu-btn {
display: none;
}
.header .menu-btn:checked ~ .menu {
max-height: calc(100% - 20px); /* My code */
overflow: auto; /* My code */
}
.header .menu-btn:checked ~ .menu-icon .navicon {
background: transparent;
}
.header .menu-btn:checked ~ .menu-icon .navicon:before {
transform: rotate(-45deg);
}
.header .menu-btn:checked ~ .menu-icon .navicon:after {
transform: rotate(45deg);
}
.header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:before, .header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:after {
top: 0;
}
.ac-container {
width: 1170px;
margin: 40px auto 30px auto;
text-align: left;
}
.ac-container article {
overflow: visible;
padding-right: 30px;
}
.ac-container input {
display: none;
}
.ac-container label {
position: relative;
z-index: 20;
display: block;
cursor: pointer;
font-size: 25px;
}
#media only screen and (max-width: 1169px) {
.header {
margin: 0 2%;
width: 96%;
padding-right: 0;
}
.ac-container {
width: 96%;
padding: 0 2%;
}
}
#media only screen and (max-width: 970px) {
.global-nav {
padding: 14px 0 0 0;
}
.header .menu-icon {
padding: 31px 1% 25px 0;
}
.header-content-right {
display: none;
}
.header div.menu {
margin-top: 0px;
}
.header div.menu ul.menu-links {
margin: 0;
}
.menu-col-one {
width: 100%;
border-bottom: 1px solid #f1f1f1;
margin-left: 0%;
margin-bottom: 30px;
padding-bottom: 25px;
}
.menu-col-two {
width: 100%;
border-bottom: 1px solid #f1f1f1;
margin-bottom: 30px;
padding-bottom: 25px;
}
.menu-col-three {
width: 100%;
border-bottom: 1px solid #f1f1f1;
margin-bottom: 30px;
padding-bottom: 25px;
}
.menu-col-four {
width: 100%;
margin-right: 0%;
margin-bottom: 30px;
padding-bottom: 25px;
}
.menu-col-five {
width: 100%;
margin-right: 0%;
display: block;
}
.header div.menu ul li.list-header {
display: block !important;
}
.header div.menu ul li.list-item {
display: none;
}
.ac-container label {
font-size: 16px;
color: #636c76;
font-weight: bold;
letter-spacing: 0.2px;
}
.ac-container input:checked + label, .ac-container input:checked + label:hover {
color: #454545;
}
.ac-container input + label:after {
content: '';
position: absolute;
width: 24px;
height: 24px;
right: 13px;
top: -6px;
}
.ac-container article {
background: rgba(255, 255, 255, 0.5);
margin-top: -1px;
overflow: hidden;
position: relative;
z-index: 10;
-webkit-transition: max-height 0.3s ease-out, box-shadow 0.6s linear;
-moz-transition: max-height 0.3s ease-out, box-shadow 0.6s linear;
-o-transition: max-height 0.3s ease-out, box-shadow 0.6s linear;
-ms-transition: max-height 0.3s ease-out, box-shadow 0.6s linear;
transition: max-height 0.3s ease-out, box-shadow 0.6s linear;
max-height: 0;
font-size: 14px;
}
.ac-container article a {
color: #636c76;
}
.ac-container article p {
line-height: 23px;
font-size: 14px;
padding: 20px;
}
.ac-container article ul li {
padding: 10px 0;
}
.ac-container article ul li span {
display: none;
}
.ac-container input:checked ~ article {
-webkit-transition: max-height 0.5s ease-in, box-shadow 0.1s linear;
-moz-transition: max-height 0.5s ease-in, box-shadow 0.1s linear;
-o-transition: max-height 0.5s ease-in, box-shadow 0.1s linear;
-ms-transition: max-height 0.5s ease-in, box-shadow 0.1s linear;
transition: max-height 0.5s ease-in, box-shadow 0.1s linear;
max-height: 500px;/*added*/
}
}
<!-- [Start] Header Section-->
<section class="global-nav" role="region" aria-label="globalnav">
<header class="header" role="banner">
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn"><span class="navicon"></span></label>
<div class="menu">
<section class="ac-container">
<div class="menu-col-one">
<input id="ac-1" name="accordion-1" type="checkbox" />
<label for="ac-1">DD 1</label>
<article class="ac-small">
<ul class="menu-links">
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
</ul>
</article>
</div>
<div class="menu-col-two">
<input id="ac-2" name="accordion-1" type="checkbox" />
<label for="ac-2">DD 2</label>
<article class="ac-medium">
<ul class="menu-links">
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
</ul>
</article>
</div>
<div class="menu-col-three">
<input id="ac-3" name="accordion-1" type="checkbox" />
<label for="ac-3">DD 3</label>
<article class="ac-large">
<ul class="menu-links">
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
</ul>
</article>
</div>
<div class="menu-col-four">
<input id="ac-4" name="accordion-1" type="checkbox" />
<label for="ac-4">DD 4</label>
<article class="ac-large">
<ul class="menu-links">
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
<li>Link <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span></li>
</ul>
</article>
</div>
<div class="menu-col-five">
<div class="btn-group">
<button class="btn">Button</button>
<button class="btn">Button</button>
<button class="btn">Button</button>
</div>
</div>
</section>
</div>
</header>
</section>
<!-- [End] Header Section-->
<!-- [Start] Main Content -->
<main role="main">
<p><span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span> Nullam velit nulla, sagittis non massa et, volutpat ullamcorper nunc. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque in dui quis justo consectetur feugiat et a dui. Integer eget justo eleifend, mattis lectus dictum, fermentum urna. Integer vitae elit non sem vehicula euismod sed non massa. Sed ac lacus tempus, pharetra lectus vel, vehicula felis. Sed pharetra viverra nisi sed euismod.</p>
<p>Nam sodales, massa non eleifend dignissim, diam felis suscipit eros, at semper diam justo ut arcu. Duis molestie nec nisi a maximus. Vestibulum in congue risus. Suspendisse potenti. Aliquam sodales neque ac pulvinar facilisis. Curabitur a lacinia ante. Mauris tempus risus lorem, vitae fermentum dolor congue in. Fusce at tristique dolor. Etiam pellentesque lectus malesuada risus malesuada luctus. Pellentesque quis quam vulputate, sagittis orci eget, egestas purus. Proin pulvinar felis et risus placerat lacinia.</p>
<p>In condimentum fermentum efficitur. Mauris non eros ac leo aliquam euismod eget ac metus. Aenean nec eros quis orci eleifend scelerisque. Aliquam finibus vestibulum efficitur. Quisque faucibus id tortor ac gravida. Maecenas eros sapien, mollis eu libero id, faucibus viverra velit. Fusce id blandit quam. Nullam vitae mi lorem. Cras vitae tortor placerat, viverra tellus ut, mattis enim. Aenean sit amet ante tortor. Pellentesque et dignissim urna.</p>
<p>Morbi in mollis neque, et elementum libero. Sed luctus, metus a posuere tempor, magna ante tempor leo, tempus ultrices nulla est sit amet ipsum. Curabitur bibendum aliquet erat eget interdum. Duis a egestas mi, et molestie lacus. Quisque in lorem nisi. Nulla vestibulum arcu est. Morbi blandit lacinia eleifend.</p>
<p>Quisque malesuada ex non dui dapibus, vitae pellentesque lacus hendrerit. Pellentesque euismod id elit non auctor. Sed tempus cursus vulputate. Praesent posuere ligula nunc. Fusce libero tellus, semper in justo fringilla, dignissim accumsan nulla. Nunc semper magna metus, sit amet vehicula urna aliquet id. Donec urna sem, pellentesque id justo a, rutrum maximus dui. Fusce vel condimentum purus. Vestibulum ultricies, massa eget aliquet imperdiet, orci quam luctus ante, in ornare tortor dui at lectus. Vivamus eget luctus felis. Sed pretium ornare vulputate. Nam in vulputate nisi. Fusce magna nibh, placerat et nulla eu, vulputate posuere sapien. Suspendisse sagittis enim ut semper efficitur. Fusce dignissim enim sed magna gravida, et pretium erat ultrices. Nulla dui augue, scelerisque vel leo nec, tempor auctor purus. </p>
<p><span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span> Nullam velit nulla, sagittis non massa et, volutpat ullamcorper nunc. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque in dui quis justo consectetur feugiat et a dui. Integer eget justo eleifend, mattis lectus dictum, fermentum urna. Integer vitae elit non sem vehicula euismod sed non massa. Sed ac lacus tempus, pharetra lectus vel, vehicula felis. Sed pharetra viverra nisi sed euismod.</p>
<p>Nam sodales, massa non eleifend dignissim, diam felis suscipit eros, at semper diam justo ut arcu. Duis molestie nec nisi a maximus. Vestibulum in congue risus. Suspendisse potenti. Aliquam sodales neque ac pulvinar facilisis. Curabitur a lacinia ante. Mauris tempus risus lorem, vitae fermentum dolor congue in. Fusce at tristique dolor. Etiam pellentesque lectus malesuada risus malesuada luctus. Pellentesque quis quam vulputate, sagittis orci eget, egestas purus. Proin pulvinar felis et risus placerat lacinia.</p>
<p>In condimentum fermentum efficitur. Mauris non eros ac leo aliquam euismod eget ac metus. Aenean nec eros quis orci eleifend scelerisque. Aliquam finibus vestibulum efficitur. Quisque faucibus id tortor ac gravida. Maecenas eros sapien, mollis eu libero id, faucibus viverra velit. Fusce id blandit quam. Nullam vitae mi lorem. Cras vitae tortor placerat, viverra tellus ut, mattis enim. Aenean sit amet ante tortor. Pellentesque et dignissim urna.</p>
<p>Morbi in mollis neque, et elementum libero. Sed luctus, metus a posuere tempor, magna ante tempor leo, tempus ultrices nulla est sit amet ipsum. Curabitur bibendum aliquet erat eget interdum. Duis a egestas mi, et molestie lacus. Quisque in lorem nisi. Nulla vestibulum arcu est. Morbi blandit lacinia eleifend.</p>
<p>Quisque malesuada ex non dui dapibus, vitae pellentesque lacus hendrerit. Pellentesque euismod id elit non auctor. Sed tempus cursus vulputate. Praesent posuere ligula nunc. Fusce libero tellus, semper in justo fringilla, dignissim accumsan nulla. Nunc semper magna metus, sit amet vehicula urna aliquet id. Donec urna sem, pellentesque id justo a, rutrum maximus dui. Fusce vel condimentum purus. Vestibulum ultricies, massa eget aliquet imperdiet, orci quam luctus ante, in ornare tortor dui at lectus. Vivamus eget luctus felis. Sed pretium ornare vulputate. Nam in vulputate nisi. Fusce magna nibh, placerat et nulla eu, vulputate posuere sapien. Suspendisse sagittis enim ut semper efficitur. Fusce dignissim enim sed magna gravida, et pretium erat ultrices. Nulla dui augue, scelerisque vel leo nec, tempor auctor purus. </p>
<p><span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span> Nullam velit nulla, sagittis non massa et, volutpat ullamcorper nunc. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque in dui quis justo consectetur feugiat et a dui. Integer eget justo eleifend, mattis lectus dictum, fermentum urna. Integer vitae elit non sem vehicula euismod sed non massa. Sed ac lacus tempus, pharetra lectus vel, vehicula felis. Sed pharetra viverra nisi sed euismod.</p>
<p>Nam sodales, massa non eleifend dignissim, diam felis suscipit eros, at semper diam justo ut arcu. Duis molestie nec nisi a maximus. Vestibulum in congue risus. Suspendisse potenti. Aliquam sodales neque ac pulvinar facilisis. Curabitur a lacinia ante. Mauris tempus risus lorem, vitae fermentum dolor congue in. Fusce at tristique dolor. Etiam pellentesque lectus malesuada risus malesuada luctus. Pellentesque quis quam vulputate, sagittis orci eget, egestas purus. Proin pulvinar felis et risus placerat lacinia.</p>
<p>In condimentum fermentum efficitur. Mauris non eros ac leo aliquam euismod eget ac metus. Aenean nec eros quis orci eleifend scelerisque. Aliquam finibus vestibulum efficitur. Quisque faucibus id tortor ac gravida. Maecenas eros sapien, mollis eu libero id, faucibus viverra velit. Fusce id blandit quam. Nullam vitae mi lorem. Cras vitae tortor placerat, viverra tellus ut, mattis enim. Aenean sit amet ante tortor. Pellentesque et dignissim urna.</p>
<p>Morbi in mollis neque, et elementum libero. Sed luctus, metus a posuere tempor, magna ante tempor leo, tempus ultrices nulla est sit amet ipsum. Curabitur bibendum aliquet erat eget interdum. Duis a egestas mi, et molestie lacus. Quisque in lorem nisi. Nulla vestibulum arcu est. Morbi blandit lacinia eleifend.</p>
<p>Quisque malesuada ex non dui dapibus, vitae pellentesque lacus hendrerit. Pellentesque euismod id elit non auctor. Sed tempus cursus vulputate. Praesent posuere ligula nunc. Fusce libero tellus, semper in justo fringilla, dignissim accumsan nulla. Nunc semper magna metus, sit amet vehicula urna aliquet id. Donec urna sem, pellentesque id justo a, rutrum maximus dui. Fusce vel condimentum purus. Vestibulum ultricies, massa eget aliquet imperdiet, orci quam luctus ante, in ornare tortor dui at lectus. Vivamus eget luctus felis. Sed pretium ornare vulputate. Nam in vulputate nisi. Fusce magna nibh, placerat et nulla eu, vulputate posuere sapien. Suspendisse sagittis enim ut semper efficitur. Fusce dignissim enim sed magna gravida, et pretium erat ultrices. Nulla dui augue, scelerisque vel leo nec, tempor auctor purus. </p>
<!-- [End] Main Content -->
</main>
I'm working on a responsive horizontal accordion that have images with text overlays. What I want to do is have the titles on each image display on the left side of each image, so that the text will be displayed without the user having to hover over it, like this:
When the user hovers over the image, I'd like it to stay on the left side, and display the description. My issue is getting the title to display on the left side. I can see that it is animated on hover; it goes from -90deg to 0.
CSS/HTML:
.accordion {
width: 100%;
max-width: 2100px;
height: 350px;
overflow: hidden;
margin: 50px auto;
}
.accordion ul {
width: 100%;
display: table;
table-layout: fixed;
margin: 0;
padding: 0;
}
.accordion ul li {
display: table-cell;
vertical-align: bottom;
position: relative;
width: 16.666%;
height: 350px;
background-repeat: no-repeat;
background-position: center center;
transition: all 500ms ease;
}
.accordion ul li div a h2 {
display: block;
overflow: auto;
-ms-transform: rotate(270deg); /* IE 9 */
-webkit-transform: rotate(270deg); /* Chrome, Safari, Opera */
transform: rotate(270deg);
background-color: rgba(255,255,255,.5);
width: 100%;
}
.accordion ul li div a {
display: block;
height: 350px;
width: 100%;
position: relative;
z-index: 3;
vertical-align: bottom;
padding: 15px 20px;
box-sizing: border-box;
color: #000;
text-decoration: none;
transition: all 200ms ease;
}
.accordion ul li div a * {
opacity: 0;
margin: 0;
width: 100%;
position: relative;
z-index: 5;
overflow: fill;
-webkit-transform: translateX(-20px);
transform: translateX(-20px);
-webkit-transition: all 400ms ease;
transition: all 400ms ease;
background-color: rgba(255,255,255,.5);
padding: 5px;
}
.accordion ul li div a h2 {
text-overflow: clip;
font-size: 24px;
text-transform: uppercase;
margin-bottom: 2px;
top: 60px;
}
.accordion ul li div a p {
top: 80px;
font-size: 14px;
height: 100px;
}
.accordion ul li:nth-child(1) { background-image: url("http://placehold.it/1350x350"); }
.accordion ul li:nth-child(2) { background-image: url("http://placehold.it/1350x350"); }
.accordion ul li:nth-child(3) { background-image: url("http://placehold.it/1350x350"); }
.accordion ul li:nth-child(4) { background-image: url("http://placehold.it/1350x350"); }
.accordion ul:hover li { width: 8%; }
.accordion ul:hover li:hover { width: 60%; }
.accordion ul:hover li:hover a { background: rgba(0, 0, 0, 0.4); }
.accordion ul:hover li:hover a * {
opacity: 1;
-webkit-transform: translateX(0);
transform: translateX(0);
}
#media screen and (max-width: 600px) {
body { margin: 0; }
.accordion { height: auto; }
.accordion ul li,
.accordion ul li:hover,
.accordion ul:hover li,
.accordion ul:hover li:hover {
position: relative;
display: table;
table-layout: fixed;
width: 100%;
-webkit-transition: none;
transition: none;
}
}
<div class="accordion w3-center">
<ul>
<li>
<div> <a href="#">
<h2>HEADER</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ut eros tortor. Proin tellus enim, cursus sed blandit sit amet, accumsan ac sapien. Nunc ornare dapibus vestibulum. Nunc vulputate luctus magna quis lobortis. Praesent nec commodo libero. Nunc auctor, metus non tincidunt faucibus, tortor eros lacinia neque, ac bibendum urna felis quis nisl. Duis imperdiet odio non fermentum pharetra. Aliquam erat volutpat. Pellentesque ac faucibus diam. Phasellus porttitor tortor lacus, a scelerisque purus accumsan sit amet.<br>
<button class="w3-button w3-green" style="width: 25%; margin-top: 15px;">BUTTON NAME</button></p>
</a> </div>
</li>
<li>
<div> <a href="#">
<h2>HEADER</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ut eros tortor. Proin tellus enim, cursus sed blandit sit amet, accumsan ac sapien. Nunc ornare dapibus vestibulum. Nunc vulputate luctus magna quis lobortis. Praesent nec commodo libero. Nunc auctor, metus non tincidunt faucibus, tortor eros lacinia neque, ac bibendum urna felis quis nisl. Duis imperdiet odio non fermentum pharetra. Aliquam erat volutpat. Pellentesque ac faucibus diam. Phasellus porttitor tortor lacus, a scelerisque purus accumsan sit amet.<br>
<button class="w3-button w3-green" style="width: 25%; margin-top: 15px;">BUTTON NAME</button></p>
</a> </div>
</li>
<li>
<div> <a href="#">
<h2>HEADER</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ut eros tortor. Proin tellus enim, cursus sed blandit sit amet, accumsan ac sapien. Nunc ornare dapibus vestibulum. Nunc vulputate luctus magna quis lobortis. Praesent nec commodo libero. Nunc auctor, metus non tincidunt faucibus, tortor eros lacinia neque, ac bibendum urna felis quis nisl. Duis imperdiet odio non fermentum pharetra. Aliquam erat volutpat. Pellentesque ac faucibus diam. Phasellus porttitor tortor lacus, a scelerisque purus accumsan sit amet.<br>
<button class="w3-button w3-green" style="width: 25%; margin-top: 15px;">BUTTON NAME</button></p>
</a> </div>
</li>
<li>
<div> <a href="#">
<h2>HEADER</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ut eros tortor. Proin tellus enim, cursus sed blandit sit amet, accumsan ac sapien. Nunc ornare dapibus vestibulum. Nunc vulputate luctus magna quis lobortis. Praesent nec commodo libero. Nunc auctor, metus non tincidunt faucibus, tortor eros lacinia neque, ac bibendum urna felis quis nisl. Duis imperdiet odio non fermentum pharetra. Aliquam erat volutpat. Pellentesque ac faucibus diam. Phasellus porttitor tortor lacus, a scelerisque purus accumsan sit amet.<br>
<button class="w3-button w3-green" style="width: 25%; margin-top: 15px;">BUTTON NAME</button></p>
</a> </div>
</li>
</ul>
</div>
Code pen:
http://codepen.io/xxdash/pen/pPrwBw
First, let me explain the using of a universal selector which is * in CSS matches any element type. It can be implied (and therefore omitted) if it isn’t the only component of the simple selector. Below is the example shows both are equivalent:
*.module {
display: block;
}
.module {
display: block;
}
In my opinion, it is not recommended to use the Universal in CSS unless you want to reset all the elements.
I have seen your code and reviewed and found a bit complex coding for the display method in descendants. For example, you can use adjacent sibling selector for your heading element as done in my code.
.accordion ul li div + h2 {
your declaration
}
I have removed the h2 element which was a child of an anchor element which is forcing to transform with the hover case. I have wrapped the h2 element with the span element and transformed its direction to a vertical position with negative positioning from the bottom and left as when rotating element at an angle, the edge of the element also rotated leaving a gap so we need to fix that with negative/position margins.
Here is the modified code.
Hope this is what you are looking for.
.accordion {
width: 100%;
max-width: 1000px;
height: 300px;
margin: 0 auto;
}
.accordion ul {
width: 100%;
display: table;
table-layout: fixed;
margin: 0;
padding: 0;
}
.accordion ul li {
display: table-cell;
vertical-align: bottom;
position: relative;
width: 16.666%;
height: 300px;
background-repeat: no-repeat;
background-position: center center;
transition: all 500ms ease;
}
.accordion ul li div {
position: relative;
}
.accordion ul li div span {
background-color: rgba(255, 0, 0, .5);
font-size: 20px;
line-height: 34px;
font-weight: 300;
position: absolute;
display: block;
width: 300px;
height: 30px;
-webkit-transform: rotate(-90deg) translateX(-50%) translateY(-150px);
-moz-transform: rotate(-90deg) translateX(-50%) translateY(-150px);
-ms-transform: rotate(-90deg) translateX(-50%) translateY(-150px);
transform: rotate(-90deg) translateX(-50%) translateY(-150px);
left: 15px;
top: -15px;
white-space: nowrap;
z-index: 10000;
cursor: default !important;
}
.accordion h2 {
font-size: 20px;
margin: 0;
}
.accordion ul li div a {
display: block;
height: 300px;
width: 100%;
position: relative;
z-index: 3;
vertical-align: bottom;
padding: 15px 20px;
box-sizing: border-box;
color: #000;
text-decoration: none;
transition: all 200ms ease;
}
.accordion ul li div a * {
opacity: 0;
margin: 0;
width: 100%;
position: relative;
z-index: 5;
overflow: fill;
-webkit-transform: translateX(-20px);
transform: translateX(-20px);
-webkit-transition: all 400ms ease;
transition: all 400ms ease;
background-color: rgba(255, 255, 255, .5);
padding: 0px;
}
.accordion ul li div a p {
top: 0;
font-size: 14px;
}
.accordion ul li:nth-child(1) {
background-image: url("http://placehold.it/1350x350");
}
.accordion ul li:nth-child(2) {
background-image: url("http://placehold.it/1350x350");
}
.accordion ul li:nth-child(3) {
background-image: url("http://placehold.it/1350x350");
}
.accordion ul li:nth-child(4) {
background-image: url("http://placehold.it/1350x350");
}
.accordion ul:hover li {
width: 8%;
}
.accordion ul:hover li:hover {
width: 60%;
}
.accordion ul:hover li:hover a {
background: rgba(0, 0, 0, 0.4);
}
.accordion ul:hover li:hover a * {
opacity: 1;
-webkit-transform: translateX(0);
transform: translateX(0);
}
#media screen and (max-width: 600px) {
body {
margin: 0;
}
.accordion ul li,
.accordion ul li:hover,
.accordion ul:hover li,
.accordion ul:hover li:hover {
position: relative;
display: table;
table-layout: fixed;
width: 100%;
-webkit-transition: none;
transition: none;
}
}
<div class="accordion w3-center">
<ul>
<li>
<div><span><h2>HEADER With Longer Text</h2></span>
<a href="#">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ut eros tortor. Proin tellus enim, cursus sed blandit sit amet, accumsan ac sapien. Nunc ornare dapibus vestibulum. Nunc vulputate luctus magna quis lobortis. Praesent nec commodo
libero. Nunc auctor, metus non tincidunt faucibus, tortor eros lacinia neque, ac bibendum urna felis quis nisl. Duis imperdiet odio non fermentum pharetra. Aliquam erat volutpat. Pellentesque ac faucibus diam. Phasellus porttitor tortor lacus,
a scelerisque purus accumsan sit amet.<br>
<button class="w3-button w3-green" style="width: 25%; margin-top: 15px;">BUTTON NAME</button></p>
</a>
</div>
</li>
<li>
<div><span><h2>HEADER with longer text</h2></span>
<a href="#">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ut eros tortor. Proin tellus enim, cursus sed blandit sit amet, accumsan ac sapien. Nunc ornare dapibus vestibulum. Nunc vulputate luctus magna quis lobortis. Praesent nec commodo
libero. Nunc auctor, metus non tincidunt faucibus, tortor eros lacinia neque, ac bibendum urna felis quis nisl. Duis imperdiet odio non fermentum pharetra. Aliquam erat volutpat. Pellentesque ac faucibus diam. Phasellus porttitor tortor lacus,
a scelerisque purus accumsan sit amet.<br>
<button class="w3-button w3-green" style="width: 25%; margin-top: 15px;">BUTTON NAME</button></p>
</a>
</div>
</li>
<li>
<div><span><h2>HEADER</h2></span>
<a href="#">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ut eros tortor. Proin tellus enim, cursus sed blandit sit amet, accumsan ac sapien. Nunc ornare dapibus vestibulum. Nunc vulputate luctus magna quis lobortis. Praesent nec commodo
libero. Nunc auctor, metus non tincidunt faucibus, tortor eros lacinia neque, ac bibendum urna felis quis nisl. Duis imperdiet odio non fermentum pharetra. Aliquam erat volutpat. Pellentesque ac faucibus diam. Phasellus porttitor tortor lacus,
a scelerisque purus accumsan sit amet.<br>
<button class="w3-button w3-green" style="width: 25%; margin-top: 15px;">BUTTON NAME</button></p>
</a>
</div>
</li>
<li>
<div><span><h2>HEADER</h2></span>
<a href="#">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ut eros tortor. Proin tellus enim, cursus sed blandit sit amet, accumsan ac sapien. Nunc ornare dapibus vestibulum. Nunc vulputate luctus magna quis lobortis. Praesent nec commodo
libero. Nunc auctor, metus non tincidunt faucibus, tortor eros lacinia neque, ac bibendum urna felis quis nisl. Duis imperdiet odio non fermentum pharetra. Aliquam erat volutpat. Pellentesque ac faucibus diam. Phasellus porttitor tortor lacus,
a scelerisque purus accumsan sit amet.<br>
<button class="w3-button w3-green" style="width: 25%; margin-top: 15px;">BUTTON NAME</button></p>
</a>
</div>
</li>
</ul>
</div>
I was experience a problem with the following code. I have a spoiler button who show a spoiler text that initially is showed with text-shadow to hide the content.
In Chrome, when I put the cursor over the spoiler button, it doesn't work well as you can see, it's difficult to click to show the spoiler.
If I remove the text-shadow property from span.show-spoiler-text it works ok.
I think this only happen in Webkit navigators, because I tried in Firefox and works perfectly.
How could I fix it?
Thank you in advance.
$(function()
{
$("span.spoiler-text .show-spoiler-text").click(function() {
var show_spoiler = $(this);
var spoiler = show_spoiler.closest('span.spoiler-text');
if (spoiler.hasClass('showing')) {
spoiler.removeClass("showing");
} else {
spoiler.addClass("showing");
}
});
});
span.show-spoiler-text {
background: #610B0B;
color: white;
text-transform: uppercase;
font-size: 10px;
padding: 5px;
border-radius: 5px;
margin-right: 5px;
cursor: pointer;
text-shadow: 0 0 0px #610B0B;
}
span.show-spoiler-text:hover, .spoiler-text.showing span.show-spoiler-text {
font-weight: bold;
}
.spoiler-text .spoiler-text-content {
text-shadow: 0 0 15px #610B0B;
color: transparent;
-webkit-transition: text-shadow 0.2s linear;
-moz-transition: text-shadow 0.2s linear;
-ms-transition: text-shadow 0.2s linear;
-o-transition: text-shadow 0.2s linear;
transition: text-shadow 0.2s linear;
}
.spoiler-text.showing .spoiler-text-content
{
text-shadow: 0 0 0px #610B0B;
color: #610B0B;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="entry-text">Lorem ipsum dolor <span class="spoiler-text"><span class="show-spoiler-text">Spoiler</span><span class="spoiler-text-content"> sit amet, consectetur adipiscing elit. Nullam luctus eu felis tristique facilisis. Nullam ut tristique tortor, vel varius tortor.</span></span>Nullam nibh nunc, ultricies at luctus quis, sodales posuere risus. Proin sagittis consectetur neque, ut laoreet nibh fringilla sit amet. Quisque tempor metus erat, at blandit mi rhoncus a. Mauris elementum mollis mollis. Quisque sit amet sollicitudin tortor, id aliquet mi. Donec convallis elit nec turpis volutpat, quis ornare leo lacinia. Proin dictum at mauris et tincidunt. Integer semper sed massa non tincidunt. Fusce facilisis, tellus vitae rhoncus aliquam, mi felis cursus tortor, non finibus augue ligula id enim. Sed ullamcorper enim quis pharetra sagittis.</p>
For the span to display the way you want, you have to set it to display: block;, set it's width and use float: left on the spoiler and on the span before. Also, you should always use span to place text, it's easier to manipulate with javascript.
$(function()
{
$("span.spoiler-text .show-spoiler-text").click(function() {
var show_spoiler = $(this);
var spoiler = show_spoiler.closest('span.spoiler-text');
if (spoiler.hasClass('showing')) {
spoiler.removeClass("showing");
} else {
spoiler.addClass("showing");
}
});
$(".spoiler-text").prev().css("float", "left");
});
span.show-spoiler-text {
background: #610B0B;
color: white;
text-transform: uppercase;
font-size: 10px;
padding: 3px;
border-radius: 5px;
margin: 0 5px;
cursor: pointer;
text-shadow: 0 0 0px #610B0B;
display: block;
width: 44px;
float: left;
}
span.show-spoiler-text:hover, .spoiler-text.showing span.show-spoiler-text {
font-weight: bold;
}
.spoiler-text .spoiler-text-content {
text-shadow: 0 0 15px #610B0B;
color: transparent;
-webkit-transition: text-shadow 0.2s linear;
-moz-transition: text-shadow 0.2s linear;
-ms-transition: text-shadow 0.2s linear;
-o-transition: text-shadow 0.2s linear;
transition: text-shadow 0.2s linear;
}
.spoiler-text.showing .spoiler-text-content
{
text-shadow: 0 0 0px #610B0B;
color: #610B0B;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<p class="entry-text">
<span>Lorem ipsum dolor</span>
<span class="spoiler-text">
<span class="show-spoiler-text">Spoiler</span>
<span class="spoiler-text-content"> sit amet, consectetur adipiscing elit. Nullam luctus eu felis tristique facilisis. Nullam ut tristique tortor, vel varius tortor.
</span>
</span>
Nullam nibh nunc, ultricies at luctus quis, sodales posuere risus. Proin sagittis consectetur neque, ut laoreet nibh fringilla sit amet. Quisque tempor metus erat, at blandit mi rhoncus a. Mauris elementum mollis mollis. Quisque sit amet sollicitudin tortor, id aliquet mi. Donec convallis elit nec turpis volutpat, quis ornare leo lacinia. Proin dictum at mauris et tincidunt. Integer semper sed massa non tincidunt. Fusce facilisis, tellus vitae rhoncus aliquam, mi felis cursus tortor, non finibus augue ligula id enim. Sed ullamcorper enim quis pharetra sagittis.</p>
Finally, I can solve putting position:relative in the .spoiler-text .spoiler-text-content element.
$(function()
{
$("span.spoiler-text .show-spoiler-text").click(function() {
var show_spoiler = $(this);
var spoiler = show_spoiler.closest('span.spoiler-text');
if (spoiler.hasClass('showing')) {
spoiler.removeClass("showing");
} else {
spoiler.addClass("showing");
}
});
});
span.show-spoiler-text {
background: #610B0B;
color: white;
text-transform: uppercase;
font-size: 10px;
padding: 5px;
border-radius: 5px;
margin-right: 5px;
cursor: pointer;
text-shadow: 0 0 0px #610B0B;
}
span.show-spoiler-text:hover, .spoiler-text.showing span.show-spoiler-text {
font-weight: bold;
}
.spoiler-text .spoiler-text-content {
text-shadow: 0px 0 15px #610B0B;
color: transparent;
-webkit-transition: text-shadow 0.2s linear;
-moz-transition: text-shadow 0.2s linear;
-ms-transition: text-shadow 0.2s linear;
-o-transition: text-shadow 0.2s linear;
transition: text-shadow 0.2s linear;
position:relative;
}
.spoiler-text.showing .spoiler-text-content
{
text-shadow: 0 0 0px #610B0B;
color: #610B0B;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="entry-text">
<span>Lorem ipsum dolor
Nullam nibh nunc, ultricies at luctus quis, sodales posuere risus. Proin sagittis consectetur neque, ut laoreet nibh fringilla sit amet. Quisque tempor metus erat, at blandit mi rhoncus a. Mauris elementum mollis mollis. Quisque sit amet sollicitudin tortor, id aliquet mi.</span><span class="spoiler-text">
<span class="show-spoiler-text">Spoiler</span>
<span class="spoiler-text-content"> sit amet, consectetur adipiscing elit. Nullam luctus eu felis tristique facilisis. Nullam ut tristique tortor, vel varius tortor. aaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</span>
</span> Donec convallis elit nec turpis volutpat, quis ornare leo lacinia. Proin dictum at mauris et tincidunt. Integer semper sed massa non tincidunt. Fusce facilisis, tellus vitae rhoncus aliquam, mi felis cursus tortor, non finibus augue ligula id enim. Sed ullamcorper enim quis pharetra sagittis.</p>