Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="content-overlay"></div>
<div class="page-box pure-g">
	<div class="pure-u-1 header-img-box">

	</div>
	<div class="pure-u-1 page-title-header-box">
		<div class="flex-page-title">	
			<h1>Title</h1>
			<div class="menu-icon-box">
				<i class="fa fa-2x fa-bars" id="menu-icon"></i>
			</div>
		</div>
	</div>
	<div class="menu-box pure-u-1-4">
		<ul>
			<li>
				<h3><span class="icon-dashboard"></span>Dashboard</h3>
				<ul>
					<li><a href="#">Reports</a></li>
					<li><a href="#">Search</a></li>
					<li><a href="#">Graphs</a></li>
					<li><a href="#">Settings</a></li>
				</ul>
			</li>
		<!-- we will keep this LI open by default -->
			<li class="active">
				<h3><span class="icon-tasks"></span>Tasks</h3>
				<ul>
					<li><a href="#">Today's tasks</a></li>
					<li><a href="#">Urgent</a></li>
					<li><a href="#">Overdues</a></li>
					<li><a href="#">Recurring</a></li>
					<li><a href="#">Settings</a></li>
				</ul>
			</li>
			<li>
				<h3><span class="icon-calendar"></span>Calendar</h3>
				<ul>
					<li><a href="#">Current Month</a></li>
					<li><a href="#">Current Week</a></li>
					<li><a href="#">Previous Month</a></li>
					<li><a href="#">Previous Week</a></li>
					<li><a href="#">Next Month</a></li>
					<li><a href="#">Next Week</a></li>
					<li><a href="#">Team Calendar</a></li>
					<li><a href="#">Private Calendar</a></li>
					<li><a href="#">Settings</a></li>
				</ul>
			</li>
			<li>
				<h3><span class="icon-heart"></span>Favourites</h3>
				<ul>
					<li><a href="#">Global favs</a></li>
					<li><a href="#">My favs</a></li>
					<li><a href="#">Team favs</a></li>
					<li><a href="#">Settings</a></li>
				</ul>
			</li>
		</ul>
	</div>

	<div class="pure-u-1 page-content-box">
		<p>
			"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."
		</p>
		<p>
			"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."
		</p>
		<p>
			"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."
		</p>
		<h3>Credentials</h3>
	</div>
	<div class="pure-u-1">
		<div class="pure-g neighbours-box">
			<div class="pure-u-1-2 prev-article">
				<h3>Читать предыдущий пост</h3>
			</div>
			<div class="pure-u-1-2 next-article">
				<h3>Читать следующий пост</h3>
			</div>
		</div>
	</div>
	<div class="pure-u-1">
		<div class="pure-g same-posts-box">
			<div class="pure-u-1-4 same-post-item">
				<h4>Same post 1</h4>
			</div>
			<div class="pure-u-1-4 same-post-item">
				<h4>Same post 2</h4>
			</div>
			<div class="pure-u-1-4 same-post-item">
				<h4>Same post 3</h4>
			</div>
			<div class="pure-u-1-4 same-post-item">
				<h4>Same post 4</h4>
			</div>
		</div>
	</div>
</div>
              
            
!

CSS

              
                * {box-sizing:border-box;}
ul, ul li {
	padding:0;
	margin:0;
}
.stop-scrolling {
	overflow:hidden;
}
.page-box {
	color:black;
	font-family:Roboto;
	
}

.menu-box {
	position:fixed;
	width:30%;
	height:100%;
	background:black;
	left:0;
	top:0;
	display:block;
	margin-left:-30%;
	z-index:9999;
	font-family: Nunito, arial, verdana;
}

.menu-box ul,
.menu-box ul li {
	list-style:none;
	width:100%;
	display:flex;
	flex-flow:row wrap;
}

.menu-box h3 {
	padding:0.8em 1em;
	margin:0;
	font-size:18px;
	color:white;
	cursor:pointer;
	transition: background 0.3s;
	width:100%;
}

.menu-box h3:hover {
	color:black;
	background:white;
	text-shadow: 0 0 1px rgba(0, 0, 0, 0.7);
}
.menu-box a {
	text-decoration:none;
	color:white;
	padding:0.5em 1.2em;
	margin:0;
	transition:background 0.3s;
	width:100%;
}

.menu-box a:hover {
	background:grey;
}
.menu-box ul ul {
	display:none;
}

.menu-box li.active ul {
	display:flex;
}

.header-img-box {
	height:250px;
	background:red;
}

.header-img-box img {
	display:block;
	height:100%;
	margin-top:-40%;
}

.page-title-header-box {
	padding:0 5em;
	color:white;
	background:black;
	display:flex;
	justify-content:center;
	align-items:center;
	z-index:9999;
}

.flex-page-title {
	display:flex;
	justify-content:space-between;
	align-items:center;
	width:100%;
}

.page-header-box-sticky {
	position:fixed;
	top:0px;
	left:0px;
}

.menu-icon-box i:hover {
	cursor:pointer;
	transform:scale(1.3);
}

.page-content-box {
	height:auto;	
}

.page-content-box p,
.page-content-box > h3 {
	padding:2em 20%;
}

.content-overlay {
	display:none;
}
.content-overlay-active {
	display:block;
	position:fixed;
	top: 0;
   right: 0;
   bottom: 0;
   left: 0;
   z-index: 9998;
   background-color: rgba(0,0,0,0.5);
   -webkit-animation: fade 500ms;
   -moz-animation: fade 500ms;
   -ms-animation: fade 500ms;
   -o-animation: fade 500ms;
   animation: fade 1000ms;
}

.neighbours-box {
	background:grey;
}

.prev-article {
	justify-content:flex-start;
	padding-left:10%;
}

.next-article {
	justify-content:flex-end;
	padding-right:10%;
}

.next-article h3,
.prev-article h3{
	margin:0 10%;
	padding:1.5em 3em;
	background:transparent;
	color:black;
	box-shadow:none;
	transition:background 0.2s;
	
}

.next-article h3:hover,
.prev-article h3:hover {
	cursor:pointer;
	color:white;
	background:black;	
}


.next-article, .prev-article {
	display:flex;	
}

.same-posts-box {
	text-align:center;
}

.same-post-item {}
              
            
!

JS

              
                $(document).ready(function(){
	var pageTitle = $(".page-header-box");
	var headerImgHeight = $(".header-img-box").outerHeight(true);
	var initialTitleOffset = $(".page-header-box").offset().top;
	var headerBox = $(".header-img-box");
	var currOffset = pageTitle.offset().top;
	var menuIcon = $(".page-header-icons i#menu-icon");
	var menuBox = $(".menu-box");
	var menuItem = $(".menu-item");
	var overlay = $(".content-overlay");
	menuBox.css({"top":pageTitle.outerHeight(true)+"px"});
	var menuSlideOffset = "-100%";
	var bigScreen = false;
	if ((window.matchMedia("(max-width:1279px)").matches)&(window.matchMedia("(min-width:601px)").matches)) {
        menuSlideOffset = "-40%";
    }
    if (window.matchMedia("(min-width:1280px)").matches) {
        menuSlideOffset = "-20%";
        bigScreen = true;
    }
	$(window).resize(function(){
	    menuBox.css({"top":pageTitle.outerHeight(true)+"px"});
	    if ((window.matchMedia("(max-width:1279px)").matches)&(window.matchMedia("(min-width:601px)").matches)) {
            menuSlideOffset = "-40%";
        }
        if (window.matchMedia("(min-width:1280px)").matches) {
            menuSlideOffset = "-20%";
            bigScreen = true;
        }
        if (window.matchMedia("(max-width:600px)").matches) {
            menuSlideOffset = "-100%";
            menuBox.css({"margin-left":menuSlideOffset}); // Костыль, пока не придумаем, как это поизящнее решить.
        } 
	});
	$(window).scroll(function(){
	    if (bigScreen){	
		    if  (!headerBox.hasClass("hidden-box")){
			    if (!(pageTitle.hasClass("page-header-box-sticky"))&($(window).scrollTop() >= headerImgHeight)){
				    pageTitle.toggleClass( "page-header-box-sticky" );
			    }
			    if ((pageTitle.hasClass("page-header-box-sticky"))&($(window).scrollTop() < headerImgHeight)){
				    pageTitle.toggleClass( "page-header-box-sticky" );
			    }			
		    }
	    }
	    else {
	        if (!(pageTitle.hasClass("page-header-box-sticky"))&($(window).scrollTop() > 1)){
				pageTitle.toggleClass( "page-header-box-sticky" );
			}
			if ((pageTitle.hasClass("page-header-box-sticky"))&($(window).scrollTop() < 1)) {
				pageTitle.toggleClass( "page-header-box-sticky" );
			}
	    }
	})		

	menuIcon.click(function(){
		
		if (($(window).scrollTop() == 0)&(bigScreen)){
			if (pageTitle.hasClass("page-header-box-sticky")){
				pageTitle.toggleClass("page-header-box-sticky");
			}
			if (!menuBox.hasClass("open-menu-box")){
				$(".header-img-box").slideToggle(700, "swing", function(){
					$(".header-img-box").toggleClass("hidden-box");
					overlay.toggleClass("content-overlay-active");
					$("body").toggleClass("stop-scrolling");					
					menuBox.toggleClass("open-menu-box");
					menuBox.animate({marginLeft: '0'}, 700);
					if (!pageTitle.hasClass("page-header-box-sticky")){
						pageTitle.toggleClass("page-header-box-sticky");
					}
				});				
			}
			else {
				menuBox.toggleClass("open-menu-box");
				$("body").toggleClass("stop-scrolling");
				overlay.toggleClass("content-overlay-active");
				menuBox.animate({marginLeft:menuSlideOffset}, 700).promise().done(function(){
					$(".header-img-box").slideToggle(700, "swing", function(){
						$(".header-img-box").toggleClass("hidden-box");						
					});
				});					
			}			
		}
		if (($(window).scrollTop() < initialTitleOffset)&($(window).scrollTop() > 0)&(bigScreen)) {
			/* И вот хз, надо ли в этом случае что то делать или не надо*/	
			var targetHeight = ($(window).scrollTop());
			if (!menuBox.hasClass("open-menu-box")){
				$(".header-img-box").animate({height:0}, {
					duration:700,
					easing:"swing",
					step:function(currentHeight){
					if ((currentHeight <= targetHeight)&(!pageTitle.hasClass("page-header-box-sticky"))){
						pageTitle.toggleClass("page-header-box-sticky");
						$(".header-img-box").toggleClass("hidden-box");
						}
					}
				}).promise().done(function(){
					overlay.toggleClass("content-overlay-active");
					$("body").toggleClass("stop-scrolling");					
					menuBox.toggleClass("open-menu-box");
					menuBox.animate({marginLeft: '0'}, 700);
				});
			}
			else{
				menuBox.toggleClass("open-menu-box");
				$("body").toggleClass("stop-scrolling");
				overlay.toggleClass("content-overlay-active");				
				menuBox.animate({marginLeft:menuSlideOffset}, 700).promise().done(function(){
					$(".header-img-box").animate({height:headerImgHeight}, {
							duration:700,
							easing:"swing",
						//Сделать нужно через step, также вычисляя текущую высоту блока хедера, и пока он меньше скролла, не переключать класс заголовка	
							step:function(currentHeight){
								if ((currentHeight >= targetHeight)&(pageTitle.hasClass("page-header-box-sticky"))){
									$(".header-img-box").toggleClass("hidden-box");
									pageTitle.toggleClass("page-header-box-sticky");									
								}
							}
					});
				});
			}					
			
		}
		if (($(window).scrollTop() >= initialTitleOffset)&(bigScreen)) {
			//menuBox.css({"top":(pageTitle.outerHeight(true))+"px"});
			if (!menuBox.hasClass("open-menu-box")){
				menuBox.animate({marginLeft: '0'}, 700).promise().done(function(){
					overlay.toggleClass("content-overlay-active");	
					$("body").toggleClass("stop-scrolling");				
					menuBox.toggleClass("open-menu-box");	
				});				
				
			}
			else {				
				menuBox.toggleClass("open-menu-box");	
				$("body").toggleClass("stop-scrolling");
				overlay.toggleClass("content-overlay-active");
				menuBox.animate({marginLeft:menuSlideOffset}, 700);
			}			
		}
		
		if (!bigScreen) {
		    if (!menuBox.hasClass("open-menu-box")){
				menuBox.animate({marginLeft: '0'}, 700).promise().done(function(){
					overlay.toggleClass("content-overlay-active");	
					$("body").toggleClass("stop-scrolling");				
					menuBox.toggleClass("open-menu-box");	
				});
                console.log("Alert 1");
				
			}
			else {				
				menuBox.toggleClass("open-menu-box");
				$("body").toggleClass("stop-scrolling");
				overlay.toggleClass("content-overlay-active");
				menuBox.animate({marginLeft:menuSlideOffset}, 700);
                console.log("Alert 2");
			}
		}
	});
	
	$(".menu-box h3").click(function(){
		//slide up all the link lists
		$(".menu-box ul ul").slideUp();
		//slide down the link list below the h3 clicked - only if its closed
		if(!$(this).next().is(":visible"))
		{
			$(this).next().slideDown();
		}
	})

})
              
            
!
999px

Console