Navigation bar follows scroll when fixed - html

I have a product page on a website.
I have a top menu with like home, about etc....
then I'm trying to have a menu on the left that stays fixed with the product list.
See the image:
With my current code however the menu on the left follows the scrolling here is the code:
<div id="product-list">
<ul>
<li>item 1</li>
<li>item 1</li>
<li>item 1</li>
<li>item 1</li>
<li>item 1</li>
<li>item 1</li>
</ul>
</div>
#product-list{
position:fixed;
}
#product-list ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 12%;
background-color: #FFF;
position:fixed;
height: 100%;
overflow: hidden;
text-overflow: ellipsis;
padding-top:10%;
}
#product-list li{
overflow: hidden;
text-overflow: ellipsis;
}
#product-list li a {
display: block;
color: #000;
padding: 8px 0 8px 16px;
text-decoration: none;
}
#product-list li a:hover:not(.active) {
background-color: #555;
color: white;
}

Plunkr Example
Changes I made
There's a few things I did on your code.
In your style definition, I removed some repetitive code. You had a few places for the #product-list that made it a fixed element, which got annoying.
I added a "special case" class, #product-list.fixed which removes the padding on the top of the list and changes it's position to fixed, with a top offset of 0.
I changed your HTML a little bit. I removed the wrapper div for the product list ul and added the #product-list id to the ul instead.
I also added in some javacript to add in/remove the .fixed class to your #product-list element if the scroll is greater than your item's original position.
I added a transition:all linear 0.3 element to smooth out the change from when we add in the fixed class
in the code below I just changed the images that popup to placehold.it images so that I wouldn't be using your bandwidth.
Edit Changed the z-index to allow the side menu to slip under the footer.
Code
The order for the code below is
Javascript (I used jQuery, which is a super popular framework)
CSS (you may want to look into a CSS framework like Bootstrap which could cut down your development times)
HTML
$(document).ready(function() {
var side_offset = $('#product-list').offset();
//Initial offset.
$(document).on('scroll', function() {
$('#product-list').toggleClass('fixed', $(document).scrollTop() > side_offset.top);
});
})
#charset "utf-8";
/* CSS Document */
html * {
font-family: verdana;
!important;
}
#header {
background-color: #565656;
color: white;
text-align: center;
height: 10%;
position: relative;
z-index: 999;
}
#header ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
text-align: center;
vertical-align: middle;
}
#header li {
display: inline;
}
#header li a {
display: inline-block;
color: white;
text-align: center;
padding: 14px 30px;
text-decoration: none;
vertical-align: middle;
}
#header li a.active {
text-decoration: underline;
}
#header li a:hover {
background-color: #111;
}
#header li a.a-no-hover:hover {
background-color: transparent;
}
#product-list {
list-style-type: none;
margin: 0;
padding: 0;
width: 12%;
background-color: #FFF;
position: absolute;
height: 100%;
overflow: hidden;
text-overflow: ellipsis;
padding-top: 10%;
z-index: 100;
transition: all linear 0.3s;
}
#product-list.fixed {
position: fixed !important;
padding-top: 0;
top: 0;
}
#product-list li {
overflow: hidden;
text-overflow: ellipsis;
}
#product-list li a {
display: block;
color: #000;
padding: 8px 0 8px 16px;
text-decoration: none;
}
#product-list li a:hover:not(.active) {
background-color: #555;
color: white;
}
#nav {
line-height: 30px;
background-color: #eeeeee;
height: 300px;
width: 100px;
float: left;
padding: 5px;
}
#section1 {
width: 90%;
height: auto;
overflow: hidden;
margin: 0 auto;
text-align: center;
}
#section1 img {
width: 100%;
height: auto;
opacity: 1;
transition: opacity 0.5s linear;
}
#section3 {
width: 90%;
margin: 0 auto;
text-align: center;
/*float:left;
padding:10px;*/
margin-bottom: 2%;
}
#section2 {
width: 50%;
height: auto;
margin-top: 5%;
margin-bottom: 5%;
margin-left: auto;
margin-right: auto;
text-align: left;
/*float:left;*/
text-align: justify;
text-justify: inter-word;
}
.centerer {
text-align: center;
}
#section5 {
width: 90%;
height: auto;
margin-top: 5%;
margin-bottom: 5%;
margin-left: auto;
margin-right: auto;
text-align: center;
vertical-align: middle;
margin-left: 10%;
}
img {
max-width: 100%;
max-height: 100%;
}
.container {
width: 70%;
margin: 10px auto;
position: relative;
text-align: center;
}
.block {
height: auto;
width: auto;
display: inline-block;
margin: 2%;
vertical-align: middle;
padding-left: 2%;
padding-right: 2%;
font-size: 1.2em;
}
.floating-product {
display: inline-block;
width: 20%;
height: 20%;
/*border: 3px solid #565656;*/
padding: 1%;
margin: 0 auto;
margin-top: 2%;
margin-bottom: 2%;
text-align: center;
vertical-align: middle;
}
.floating-product img {
margin: 0 auto;
max-width: 100%;
max-height: 100%;
display: block;
}
.floating-product a {
color: #000;
}
.floating-product a:hover {
color: #565656;
}
.block a {
color: #000;
}
.block a:hover {
color: #565656;
}
#footer {
background-color: #565656;
color: white;
overflow: auto;
/*clear: both;*/
text-align: left;
padding: 1% 5%;
height: 10%;
vertical-align: middle;
position: relative;
z-index: 999;
}
hr {
width: 70%;
}
h1 {
text-align: left;
font-size: 1.5em;
margin-left: 11%;
}
.margin {
margin-left: 11%;
}
span {
background: transparent;
}
table {
margin-top: 5%;
}
.tg {
border-collapse: collapse;
border-spacing: 0;
width: 99%;
margin: 0 auto;
font-size: 1.1em;
font-weight: 100;
}
.tg td {
padding: 5px 10px;
border-style: none;
border-width: 1px;
overflow: hidden;
word-break: normal;
font-weight: 100;
}
.tg th {
font-weight: 100;
padding: 5px 10px;
border-style: none;
border-width: 1px;
overflow: hidden;
word-break: normal;
}
.tg .tg-lqy6 {
text-align: right;
vertical-align: top;
padding-right: 3%;
}
.tg .tg-yw4l {
vertical-align: top;
text-align: left;
padding-left: 3%;
}
a.fancybox img {
border: none;
box-shadow: 0 1px 7px rgba(0, 0, 0, 0.6);
-o-transform: scale(1, 1);
-ms-transform: scale(1, 1);
-moz-transform: scale(1, 1);
-webkit-transform: scale(1, 1);
transform: scale(1, 1);
-o-transition: all 0.2s ease-in-out;
-ms-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
a.fancybox:hover img {
position: relative;
z-index: 999;
-o-transform: scale(1.03, 1.03);
-ms-transform: scale(1.03, 1.03);
-moz-transform: scale(1.03, 1.03);
-webkit-transform: scale(1.03, 1.03);
transform: scale(1.03, 1.03);
}
.imager {
display: inline-block;
width: 15%;
height: 10%;
padding: 1%;
margin: 0 auto;
margin-top: 2%;
margin-bottom: 2%;
text-align: center;
vertical-align: middle;
}
.imager img {
margin: 0 auto;
max-width: 100%;
max-height: 100%;
display: block;
}
.black a {
float: right;
color: #000
}
.black a:hover {
color: #565656;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="header">
<ul>
<li>
<a class="a-no-hover" href="index.html">
<img src="placehold.it/300x300" />
</a>
</li>
<li>
HOME
</li>
<li>
<a class="active" href="product.html">PRODUCTS</a>
</li>
<li>
ORDER
</li>
<li>
ABOUT US
</li>
<li>
CONTACT US
</li>
</ul>
</div>
<ul id="product-list">
<li>
Composite Bag Filter Media
</li>
<li>
High Dust-Loading Bag Filter Media
</li>
<li>
Laminated Composite Filter Media
</li>
<li>
Polyester Synthetic Fibre Filter Media
</li>
<li>
Polypropylene Melt-Blown Filter Media
</li>
<li>
Wire Mesh Backed Composite Filter Media
</li>
</ul>
<div id="section5">
<h1>Product Listing</h1>
<div class="floating-product">
<a href="bfm.html">
<img class="displayed" src="//placehold.it/300x300" />
<br />
<h4>Composite Bag Filter Media</h4>
</a>
<p>
<a style="color:#06F" href="bfm.html">Read more...</a>
</p>
</div>
<div class="floating-product">
<a href="hbm.html">
<img class="displayed" src="//placehold.it/300x300" />
<br />
<h4>High Dust-Loading Bag Filter Media</h4>
</a>
<p>
<a style="color:#06F" href="hbm.html">Read more...</a>
</p>
</div>
<div class="floating-product">
<a href="laminated.html">
<img class="displayed" src="//placehold.it/300x300" />
<br />
<h4>Laminated Composite Filter Media</h4>
</a>
<p>
<a style="color:#06F" href="laminated.html">Read more...</a>
</p>
</div>
<div class="floating-product">
<a href="ps.html">
<img class="displayed" src="//placehold.it/300x300" />
<br />
<h4>Polyester Synthetic Fibre Filter Media</h4>
</a>
<p>
<a style="color:#06F" href="ps.html">Read more...</a>
</p>
</div>
<div class="floating-product">
<a href="pm.html">
<img class="displayed" src="//placehold.it/300x300" />
<br />
<h4>Polypropylene Melt-Blown Filter Media</h4>
</a>
<p>
<a style="color:#06F" href="pm.html">Read more...</a>
</p>
</div>
<div class="floating-product">
<a href="wm.html">
<img class="displayed" src="//placehold.it/300x300" />
<br />
<h4>Wire Mesh Backed Composite Filter Media</h4>
</a>
<p>
<a style="color:#06F" href="wm.html">Read more...</a>
</p>
</div>
</div>
<div id="footer">
<span style="float:left;">
<b>Contact Us</b>
<br />
Email: contact#dongguanhy.com <br />
Contact Phone: +86-769-23150100 <br />
Contact Fax: +86-769-23152700 <br />
Company Address: Liu Yong Wei Industry Area, DongGuan, GuandDong Province, China <br />
</span>
<span style="float:right;">
<b>Follow Us</b>
<br />
<br />
<a href="http://facebook.com/dongguanhy/" target="_blank">
<img src="placehold.it/300x300" />
</a>
<!--<img src="http://mmo-stream.net/dong/images/linkedin.png"/>-->
</span>
</div>

Related

Asp.net Core MVC Render Body Problem after Implementing Responsive Side Bar

After implementing sidebar its fridge my other page and didn't able to scroll the page in Asp.net Core MVC. I think the problem is comes from the _layout.cshtml file. as it has a container which render my other page. Please help me to solve this problem.
Here is My _Layout.cshtm File. The header is the side bar.
<header>
<div class="sidebar">
<div class="logo_content">
<div class="logo">
<i class='bx bxl-c-plus-plus'></i>
<div class="logo_name">dgInfoSys</div>
</div>
<i class='bx bx-menu' id="btn"></i>
</div>
<ul class="nav_list">
<li>
<i class='bx bx-search-alt'></i>
<input class="text" placeholder="Search...">
<span class="tooltip">Search</span>
</li>
<li>
<a href="#">
<i class='bx bx-grid-alt'></i>
<span class="links_name">Dashboard</span>
</a>
<span class="tooltip">Dashboard</span>
</li>
<li>
<a href="#">
<i class='bx bx-user'></i>
<span class="links_name">User</span>
<i class='bx bxs-chevron-down htmlcss-arrow arrow '></i>
</a>
<span class="tooltip">User</span>
</li>
<li>
<a href="#">
<i class='bx bxs-user-badge'></i>
<span class="links_name">Super Admin</span>
</a>
<span class="tooltip">Super Admin</span>
</li>
<li>
<a href="#">
<i class='bx bx-line-chart'></i>
<span class="links_name">Analytics</span>
</a>
<span class="tooltip">Analytics</span>
</li>
<li>
<a asp-controller="BTBTable" asp-action="Index">
<i class='bx bxs-report'></i>
<span class="links_name">Files</span>
</a>
<span class="tooltip">Files</span>
</li>
<li>
<a href="#">
<i class='bx bx-cog'></i>
<span class="links_name">Setting</span>
</a>
<span class="tooltip">Setting</span>
</li>
</ul>
<div class="profile_content">
<div class="profile">
<div class="profile_details">
#*<img src="" alt="" />*#
<div class="name_job">
<div class="name">Masum Rayhan</div>
<div class="job">Developer</div>
</div>
</div>
<i class='bx bx-log-out' id="log_out"></i>
</div>
</div>
</div>
</header>
<div id="main">
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰
</span>
</div>
<div class="container">
<main role="main" class="pb-3">
#RenderBody()
</main>
</div>
And side bar css is given below:
#import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins", sans-serif;
}
body {
position: relative;
min-height: 100vh;
width: 100%;
overflow: hidden;
}
.sidebar {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 78px;
/*width: 240px;*/
background: #11101d;
padding: 6px 14px;
transition: all 0.5s ease;
}
.sidebar.active {
width: 240px;
}
.sidebar .logo_content .logo {
color: #fff;
display: flex;
height: 50px;
width: 100%;
align-items: center;
opacity: 0;
pointer-events: none;
transition: all 0.5s ease;
}
.sidebar.active .logo_content .logo {
opacity: 1;
pointer-events: none;
}
.logo_content .logo i {
font-size: 28px;
margin-right: 5px;
}
.logo_content .logo .logo_name {
font-size: 20px;
font-weight: 400;
}
.sidebar #btn {
position: absolute;
color: #fff;
left: 50%;
top: 6px;
font-size: 20px;
height: 50px;
width: 50px;
text-align: center;
line-height: 50px;
transform: translateX(-50%);
}
.sidebar.active #btn {
left: 90%;
}
.sidebar ul {
margin-top: 20px;
}
.sidebar ul li {
position: relative;
height: 50px;
width: 100%;
margin: 0 5px;
list-style: none;
line-height: 50px;
}
.sidebar ul li .tooltip {
position: absolute;
left: 122px;
height: 35px;
width: 122px;
top: 50%;
transform: translate(-50%, -50%);
border-radius: 6px;
line-height: 35px;
text-align: center;
background: #fff;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
transition: 0s;
opacity: 0;
pointer-events: none;
}
.sidebar.active ul li .tooltip {
display: none;
}
.sidebar ul li:hover .tooltip {
transition: all 0.5s ease;
opacity: 1;
top: 50%
}
.sidebar ul li input {
position: absolute;
height: 100%;
width: 100%;
left: 0;
top: 0;
border-radius: 12px;
outline: none;
border: none;
background: #1d1b31;
padding-left: 50px;
font-size: 18px;
color: #fff;
}
.sidebar ul li .bx-search {
position: absolute;
z-index: 99;
color: #fff;
font-size: 22px;
transition: all 0.5s ease;
}
.sidebar ul li .bx-search:hover {
background: #fff;
color: #1d1b31;
}
.sidebar ul li a {
color: #fff;
display: flex;
align-items: center;
text-decoration: none;
transition: all 0.4s ease;
border-radius: 12px;
white-space: nowrap;
}
.sidebar ul li a:hover {
color: #11101d;
background: #fff;
}
.sidebar ul li a i {
height: 50px;
min-width: 50px;
border-radius: 12px;
line-height: 50px;
text-align: center;
}
.sidebar .links_name {
opacity: 0;
pointer-events: none;
transition: all 0.5s ease;
}
.sidebar.active .links_name {
opacity: 1;
pointer-events: auto;
}
.sidebar .profile_content {
position: absolute;
color: #fff;
bottom: 0;
left: 0;
width: 100%;
}
.sidebar .profile_content .profile {
position: relative;
padding: 10px 6px;
height: 60px;
background: none;
transition: all 0.4s ease;
}
.sidebar.active .profile_content .profile {
background: #1d1b31;
}
.profile_content .profile .profile_details {
display: flex;
align-items: center;
opacity: 0;
pointer-events: none;
white-space: nowrap;
}
.sidebar.active .profile .profile_details {
opacity: 1;
pointer-events: auto;
}
.profile .profile_details img {
height: 45px;
width: 45px;
object-fit: cover;
border-radius: 12px;
}
.profile .profile_details .name_job {
margin-left: 10px;
}
.profile .profile_details .name {
font-size: 15px;
font-weight: 400;
}
.profile .profile_details .job {
font-size: 12px;
}
.profile #log_out {
position: absolute;
bottom: 5px;
left: 50%;
transform: translateX(-50%);
min-width: 50px;
line-height: 50px;
font-size: 20px;
border-radius: 12px;
text-align: center;
transition: all 0.4s ease;
background: #1d1b31;
}
.sidebar.active .profile #log_out {
left: 80%
}
.sidebar.active .profile #log_out {
background: none;
}
.home_content {
position: absolute;
height: 100%;
width: calc(100% -78px);
left: 78px;
transition: all 0.5s ease;
}
.home_content .text {
font-size: 25px;
font-weight: 500;
color: #1d1b31;
margin: 12px;
}
.sidebar.active ~ .home_content {
width: calc(100% -240px);
left: 240px;
}
Check your Css code:
body {
position: relative;
min-height: 100vh;
width: 100%;
overflow: hidden;
}
The overflow property specifies whether to clip the content or to add scrollbars when the content of an element is too big to fit in the specified area
The overflow property has the following values:
visible - Default. The overflow is not clipped. The content renders
outside the element's box
hidden - The overflow is clipped, and the rest of the content will
be invisible
scroll - The overflow is clipped, and a scrollbar is added to see
the rest of the content
auto - Similar to scroll, but it adds scrollbars only when
necessary
So in your code, you just need to delete overflow: hidden; or change it as the property whtich you need.

how can I get my footer to stay at the bottom? [duplicate]

This question already has answers here:
How do you get the footer to stay at the bottom of a Web page?
(32 answers)
Closed 3 years ago.
I was wondering how I can get my footer to stay at the bottom. Sorry I am still new to this and still learning. If you guys see anything in my code I could do better on just let me know. I was messing around with the positioning a lot. I think the next website I design I will be using flexbox lol. If anyone has any suggestions or some tips for me to do better please let me know. I tried making the body relative and made the footer absolute with bottom set to 0 but that didn't work
#font-face{
font-family: 'HeadingFont';
src: url(../fonts/KaushanScript-Regular.otf);
font-style: normal;
}
body{
font: 15px/1.5 Arial, Helvetica, sans-serif;
padding: 0;
margin: 0;
width: 100%;
height: 100%;
overflow-x: hidden;
background: #ffffff;
box-sizing: border-box;
}
/* global */
.container{
width: 100%;
margin: 5px 0 15px 0;
overflow-x: hidden;
}
#wrapper{
padding: 60px 155px ;
}
ul{
text-align: left;
list-style-type: square;
}
.button_1{
height: 38px;
background: #e8491d;
border: 0;
padding-left: 20px;
padding-right: 20px;
color: #ffffff;
}
/* header */
header{
background: #35424a;
color: #ffffff;
padding: 30px 10px 0 20px;
min-height: 70px;
border-bottom: #eB491d 3px solid;
}
header #branding{
float: left;
font-family: 'HeadingFont' , 'Times New Roman', Times, serif;
font-size: 0.9rem;
}
header #branding h1{
margin: 0;
}
.navbar a{
color: white;
padding-right: 20px;
}
.navbar{
padding-right: 20px;
}
.side-nav{
height: 100%;
width: 0;
position: fixed;
z-index: 1;
right: 0;
background: #35424a;
opacity: 0.9;
overflow-x: hidden;
padding-top: 70px;
transition: 0.5s;
}
.side-nav a{
padding: 20px 30px 20px 10px;
text-decoration: none;
text-transform: uppercase;
font-size: 16px;
color: #ffffff;
display: block;
transition: 0.3s;
}
.side-nav .btn-close{
position: absolute;
top: 20px;
left: -50px;
font-size: 36px;
margin-left: 50px;
padding: 10px;
}
.fas{
float: right;
font-size: 30px;
}
header .highlight, header .current a{
color: #e8491d;
font-weight: bold;
}
header a:hover{
color: #cccccc;
transition: all 0.3s ease;
font-weight: bold;
}
/*Slider*/
.slider-inner{
width: 90%;
height:400px;
position:relative;
overflow:hidden;
float:left;
padding:3px;
}
.slider-inner img{
display:none;
width:100%;
height:500px;
}
.slider-inner img.active{
display:inline-block;
}
.prev,.next{
float:left;
margin-top:130px;
cursor: pointer;
}
.prev{
position:relative;
margin-right:-45px;
z-index:100;
}
.next{
position:relative;
margin-left:-45px;
z-index:100;
}
/*Homepage packages*/
#boxes{
margin-top: 20px;
}
#boxes .box{
float: left;
text-align: center;
width: 30%;
padding: 10px;
}
#boxes .bronze{
color: #cd7f32; /*Bronze*/
text-align: center;
}
#boxes .silver{
color: #C0C0C0; /*silver*/
}
#boxes .gold{
color: #CFB53B; /*Gold*/
}
/*Gallery Page*/
#gallery{
max-width: 90%;
padding: 50px;
}
.image{
border-radius: 5px;
width: 70%;
background: #35424a;
margin: 0 auto;
padding: 50px;
}
.image img{
width: 200px;
padding: 10px;
}
.image img:hover{
transform: scale(1.2);
}
/*Contact Page*/
form {
border-radius: 5px;
background: #35424a;
color: white;
width:70%;
padding: 50px;
margin: 0 auto;
}
#contact{
width: 90%;
}
input[type=text], [type=email], select, textarea{
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
resize: vertical;
}
input[type=submit] {
background-color: #4CAF50;
color: white;
padding: 12px 30px;
border: none;
border-radius: 4px;
cursor: pointer;
float: right;
width: 100px;
}
.submit:hover{
color: black;
background: rgb(60, 255, 0);
transition: all 0.9s ease;
}
label {
padding: 12px 12px 12px 0;
display: inline-block;
}
#contact{
padding: 50px;
line-height: 3em;
}
/*footer*/
footer{
width: 100%;
height: 30px;
padding: 10px;
color: white;
background-color: #e8491d;
text-align: center;
}
/*Media Queries*/
#media only screen and (max-width: 940px){
#wrapper{
padding: 0;
margin: 0;
}
#boxes .box{
float: left;
text-align: center;
width: 100%;
padding: 5px;
}
header{
padding: 10px;
}
header nav{
margin: 0;
float: left;
}
.image{
width: 450px;
margin: 0 auto;
}
#gallery{
width: 100%;
}
#contact{
padding-left: 10px;
width: 100%;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width-device-width">
<title>photagraphy - Welcome</title>
<link rel="stylesheet" href="./css/style.css">
<script
src="https://code.jquery.com/jquery-3.1.1.js"
integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA="
crossorigin="anonymous"></script>
<script src="jqslider/js/main.js"></script>
<script src="https://kit.fontawesome.com/01fc06f1b4.js" crossorigin="anonymous"></script>
<script src="navigation.js"></script>
</head>
<body>
<header>
<div class="container">
<div id="branding">
<h1> <span class="highlight">Jamie's</span> photagraphy</h1>
</div>
<nav class="navbar">
<span class="open-slide">
<a href="#" onclick="openSlideMenu()">
<i class="fas fa-bars"></i>
</a>
</span>
</nav>
<div id="side-menu" class="side-nav">
×
Home
Gallery
Contact Us
</div>
</div>
</header>
<div id="wrapper">
<div class="container">
<div class="slider-outer">
<img src="jqslider/images/arrow-left.png" class="prev" alt="Prev">
<div class="slider-inner">
<img src="jqslider/images/image1.jpg" class="active">
<img src="jqslider/images/image2.jpg">
<img src="jqslider/images/image3.jpg">
<img src="jqslider/images/image4.jpg">
</div>
<img src="jqslider/images/arrow-right.png" class="next" alt="Next">
</div>
</div>
<section id="boxes">
<div class="container">
<div class="box">
<h3 class="bronze">Bronze</h3>
<ul>
<li>Full Day coverage of your wedding.</li>
<li>Unlimited Photographers time on Wedding day.</li>
<li>Includes 2 hour Engagement session or subtract $200 if not needed. Includes 25 Digital Photos, two 8x10s and three 5x7s.</li>
<li>1 hour Bridal Portrait session with 1 16x20 Canvas and 8x8 photo book with 10 sides or subtract $200 if not needed.</li>
<li> Video of photos from Engagement session and Bridal Session to use on your wedding day.</li>
</ul>
</div>
<div class="box">
<h3 class="silver">Silver</h3>
<ul>
<li>
Up to 8 hours photography for pre-wedding, wedding, and reception photographs.
</li>
<li>
Includes 1 hour Engagement session with 1 16x20 print and 2 8x10 prints. (Subtract $100 if not needed)
</li>
<li>
1 hour Bridal Portrait session with 1 16x20 and 2 8x10 custom prints. (Subtract $100 if not needed)
</li>
<li>
OPTION - Engagement Session and Bridal Session or COPY OF 200 DIGITAL PHOTOS of your choice.
</li>
<li>
Online proofs.
</li>
</ul>
</div>
<div class="box">
<h3 class="gold">Gold</h3>
<ul>
<li>Up to 6 Hours of photography for pre-wedding, wedding, and reception photographs. (ask about additional time)</li>
<li>Online proofs.</li>
<li>Two photographers</li>
<li>One 16x20 Print!</li>
<li>Four 8x10s, Eight 5x7s, 10 4x6s</li>
<li>Custom Hard Cover Photo Book.</li>
<li>15 full format images of your choice, copyright free.</li>
</ul>
</div>
</div>
</section>
</div>
<footer>
<p>Created by Justin Hamilton. Copyright © 2019</p>
</footer>
</body>
</html>
I Use:
.footer{
width: 100%;
height: 4rem;
bottom: 0;
left: 0;
position: absolute;
}
Your Css had:
footer{
width: 100%;
height: 30px;
padding: 10px;
color: white;
background-color: #e8491d;
text-align: center;
}
You can make your footer fixed
make sure you add z-index value so that other element don't overlaps the footer.
footer {
position: fixed;
bottom: 0;
width: 100%;
z-index: 5;
}
Making your footer position: fixed will help you achieve this. You may have to watch out for other elements near the bottom colliding and overlapping. You can use margins to help with that. Also, using a high z-index will prevent other elements from being displayed over top of it.
You can read more about fixed positioning here.
#font-face {
font-family: 'HeadingFont';
src: url(../fonts/KaushanScript-Regular.otf);
font-style: normal;
}
body {
font: 15px/1.5 Arial, Helvetica, sans-serif;
padding: 0;
margin: 0;
width: 100%;
height: 100%;
overflow-x: hidden;
background: #ffffff;
box-sizing: border-box;
}
/* global */
.container {
width: 100%;
margin: 5px 0 15px 0;
overflow-x: hidden;
}
#wrapper {
padding: 60px 155px;
}
ul {
text-align: left;
list-style-type: square;
}
.button_1 {
height: 38px;
background: #e8491d;
border: 0;
padding-left: 20px;
padding-right: 20px;
color: #ffffff;
}
/* header */
header {
background: #35424a;
color: #ffffff;
padding: 30px 10px 0 20px;
min-height: 70px;
border-bottom: #eB491d 3px solid;
}
header #branding {
float: left;
font-family: 'HeadingFont', 'Times New Roman', Times, serif;
font-size: 0.9rem;
}
header #branding h1 {
margin: 0;
}
.navbar a {
color: white;
padding-right: 20px;
}
.navbar {
padding-right: 20px;
}
.side-nav {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
right: 0;
background: #35424a;
opacity: 0.9;
overflow-x: hidden;
padding-top: 70px;
transition: 0.5s;
}
.side-nav a {
padding: 20px 30px 20px 10px;
text-decoration: none;
text-transform: uppercase;
font-size: 16px;
color: #ffffff;
display: block;
transition: 0.3s;
}
.side-nav .btn-close {
position: absolute;
top: 20px;
left: -50px;
font-size: 36px;
margin-left: 50px;
padding: 10px;
}
.fas {
float: right;
font-size: 30px;
}
header .highlight,
header .current a {
color: #e8491d;
font-weight: bold;
}
header a:hover {
color: #cccccc;
transition: all 0.3s ease;
font-weight: bold;
}
/*Slider*/
.slider-inner {
width: 90%;
height: 400px;
position: relative;
overflow: hidden;
float: left;
padding: 3px;
}
.slider-inner img {
display: none;
width: 100%;
height: 500px;
}
.slider-inner img.active {
display: inline-block;
}
.prev,
.next {
float: left;
margin-top: 130px;
cursor: pointer;
}
.prev {
position: relative;
margin-right: -45px;
z-index: 100;
}
.next {
position: relative;
margin-left: -45px;
z-index: 100;
}
/*Homepage packages*/
#boxes {
margin-top: 20px;
}
#boxes .box {
float: left;
text-align: center;
width: 30%;
padding: 10px;
}
#boxes .bronze {
color: #cd7f32;
/*Bronze*/
text-align: center;
}
#boxes .silver {
color: #C0C0C0;
/*silver*/
}
#boxes .gold {
color: #CFB53B;
/*Gold*/
}
/*Gallery Page*/
#gallery {
max-width: 90%;
padding: 50px;
}
.image {
border-radius: 5px;
width: 70%;
background: #35424a;
margin: 0 auto;
padding: 50px;
}
.image img {
width: 200px;
padding: 10px;
}
.image img:hover {
transform: scale(1.2);
}
/*Contact Page*/
form {
border-radius: 5px;
background: #35424a;
color: white;
width: 70%;
padding: 50px;
margin: 0 auto;
}
#contact {
width: 90%;
}
input[type=text],
[type=email],
select,
textarea {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
resize: vertical;
}
input[type=submit] {
background-color: #4CAF50;
color: white;
padding: 12px 30px;
border: none;
border-radius: 4px;
cursor: pointer;
float: right;
width: 100px;
}
.submit:hover {
color: black;
background: rgb(60, 255, 0);
transition: all 0.9s ease;
}
label {
padding: 12px 12px 12px 0;
display: inline-block;
}
#contact {
padding: 50px;
line-height: 3em;
}
/*footer*/
footer {
width: 100%;
height: 30px;
padding: 10px;
color: white;
background-color: #e8491d;
text-align: center;
position: fixed;
bottom: 0;
}
/*Media Queries*/
#media only screen and (max-width: 940px) {
#wrapper {
padding: 0;
margin: 0;
}
#boxes .box {
float: left;
text-align: center;
width: 100%;
padding: 5px;
}
header {
padding: 10px;
}
header nav {
margin: 0;
float: left;
}
.image {
width: 450px;
margin: 0 auto;
}
#gallery {
width: 100%;
}
#contact {
padding-left: 10px;
width: 100%;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width-device-width">
<title>photagraphy - Welcome</title>
<link rel="stylesheet" href="./css/style.css">
<script src="https://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous"></script>
<script src="jqslider/js/main.js"></script>
<script src="https://kit.fontawesome.com/01fc06f1b4.js" crossorigin="anonymous"></script>
<script src="navigation.js"></script>
</head>
<body>
<header>
<div class="container">
<div id="branding">
<h1> <span class="highlight">Jamie's</span> photagraphy</h1>
</div>
<nav class="navbar">
<span class="open-slide">
<a href="#" onclick="openSlideMenu()">
<i class="fas fa-bars"></i>
</a>
</span>
</nav>
<div id="side-menu" class="side-nav">
×
Home
Gallery
Contact Us
</div>
</div>
</header>
<div id="wrapper">
<div class="container">
<div class="slider-outer">
<img src="jqslider/images/arrow-left.png" class="prev" alt="Prev">
<div class="slider-inner">
<img src="jqslider/images/image1.jpg" class="active">
<img src="jqslider/images/image2.jpg">
<img src="jqslider/images/image3.jpg">
<img src="jqslider/images/image4.jpg">
</div>
<img src="jqslider/images/arrow-right.png" class="next" alt="Next">
</div>
</div>
<section id="boxes">
<div class="container">
<div class="box">
<h3 class="bronze">Bronze</h3>
<ul>
<li>Full Day coverage of your wedding.</li>
<li>Unlimited Photographers time on Wedding day.</li>
<li>Includes 2 hour Engagement session or subtract $200 if not needed. Includes 25 Digital Photos, two 8x10s and three 5x7s.</li>
<li>1 hour Bridal Portrait session with 1 16x20 Canvas and 8x8 photo book with 10 sides or subtract $200 if not needed.</li>
<li> Video of photos from Engagement session and Bridal Session to use on your wedding day.</li>
</ul>
</div>
<div class="box">
<h3 class="silver">Silver</h3>
<ul>
<li>
Up to 8 hours photography for pre-wedding, wedding, and reception photographs.
</li>
<li>
Includes 1 hour Engagement session with 1 16x20 print and 2 8x10 prints. (Subtract $100 if not needed)
</li>
<li>
1 hour Bridal Portrait session with 1 16x20 and 2 8x10 custom prints. (Subtract $100 if not needed)
</li>
<li>
OPTION - Engagement Session and Bridal Session or COPY OF 200 DIGITAL PHOTOS of your choice.
</li>
<li>
Online proofs.
</li>
</ul>
</div>
<div class="box">
<h3 class="gold">Gold</h3>
<ul>
<li>Up to 6 Hours of photography for pre-wedding, wedding, and reception photographs. (ask about additional time)</li>
<li>Online proofs.</li>
<li>Two photographers</li>
<li>One 16x20 Print!</li>
<li>Four 8x10s, Eight 5x7s, 10 4x6s</li>
<li>Custom Hard Cover Photo Book.</li>
<li>15 full format images of your choice, copyright free.</li>
</ul>
</div>
</div>
</section>
</div>
<footer>
<p>Created by Justin Hamilton. Copyright © 2019</p>
</footer>
</body>
</html>
#container {
position: relative;
min-height: 100vh;
}
#content {
padding-bottom: 2.5rem; /* Footer height */
}
#footer {
position: absolute;
bottom: 0;
width: 100%;
height: 2.5rem; /* Footer height */
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="main.css" />
</head>
<body>
<div id="container">
<div id="content">
<!-- all other page content -->
</div>
<footer id="footer"></footer>
</div>
</body>
</html>

How to wrap text within an image overlay

I am currently working on a school project. As of this moment I am in the first steps of creating a product page. I am using an image overlay to show a description of the product while hover. My issue is the text does not wrap, it continues outside of the container. I would appreciate any feedback. Thanks!
.container2 {
position: relative;
width: 15%;
height: 15%;
margin-left: 50px;
}
.image {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
bottom: 100%;
left: 0;
right: 0;
background-color: #4CAF50;
overflow: hidden;
width: 100%;
height:0;
transition: .5s ease;
}
.container2:hover .overlay {
bottom: 0;
height: 100%;
}
.text {
white-space: nowrap;
color: white;
font-size: 20px;
position: absolute;
overflow: hidden;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}
.container {
overflow: hidden;
}
.column2 {
float: center;
margin: 20px;
background-color: #333;
padding-bottom: 100%;
margin-bottom: -100%;
color: aliceblue;
font-family: roboto;
}
.column1 {
text-align: center;
float: center;
margin: 20px;
background-color: #333;
padding-bottom: 100%;
margin-bottom: -100%;
color:aliceblue;
font-family: roboto;
}
br {
text-align: center;
}
a {
text-decoration: none;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: #111;
}
li {
color: darkgreen;
font-size: 20px;
font-weight: bold;
}
.active {
background-color: #4CAF50;
}
<!DOCTYPE html>
<html>
<head>
<title>Shopping Page</title>
<link rel="stylesheet" href="styles.css">
<link rel="shortcut icon" type="image/png" href="images/favicongreen.png" />
</head>
<body>
<ul>
<li>
Home
</li>
<li>
<a class="active" href="products.html">Products</a>
</li>
<li>
Contact
</li>
<li>
About
</li>
<li>
Shopping Cart
</li>
<li>
<img src="images/bolt2.png" width="40px" height="40px" />
</li>
</ul>
<div style="padding:20px;margin-top:30px;background-color:#1abc9c;height:1500px;">
<h1>Products</h1>
<div class="container">
<div class="column1">
<br>
<br>
<p>
<b>Electric Energy Electronics Product Index</b>
</p>
<br>
<div class="container2">
<img src="images/solar.jpg" alt="Avatar" class="image" height="50px" width="50px">
<div class="overlay">
<div class="text">250PX Solar Panel
<br> This solar panel is a great way to harness clean energy from the sun.</div>
</div>
</div>
<div class="column2">
Shopping cart Div
</div>
</div>
</div>
</body>
</html>
Replace your css .text class with this.
.text {
width: 80%;
text-align: center;
color: white;
font-size: 20px;
position: absolute;
overflow: hidden;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}

How to Center my Nav bar, and put the social media icons on the side

https://jsfiddle.net/qnw7a9zk/
I'm attempting to put the nav bar in the center, and the social media icons on the side. I've looked up other solutions to this problem, but none also want to put the icons on the side.
If I try to float the nav bar to the left, and the icons to the right, it kind of works, but the nav bar isn't in the center, and if I were to change the size of the window (responsiveness) the bar kind of breaks.
I can only get the icons to the right, but not on the same row as the nav bar, and they are stuck below it.
<div class="wrapper">
<img class="logo" src="Logo.png" />
<nav>
<ul class="nav">
<li class="navlist">Properties</li>
<li class="navlist">The Team</li>
<li class="navlist">Contact Us</li>
</ul>
<div class="imgs">
<img src="Instagram.png" />
<img src="Facebook.png" />
<img src="Twitter.png" />
</div>
</nav>
</div>
<footer>
<p class="buttons">Real estate</p>
</footer>
</body>
body {
background-color: #ffffff;
margin: 0;
display: table;
height: 100%;
width: 100%;
background-image: url(nice.jpg);
background-size: 100% 100%;
overflow: auto;
}
.wrapper {
text-align: center;
padding: 0px;
height: auto;
width: 100%;
}
footer {
background-color: #cbb492;
display: table-row;
height: 2px;
text-align: center;
}
li a {
text-decoration: none;
font-variant: small-caps;
color: black;
}
li:hover {
background-color: #cbb492;
}
nav {
width: 100%;
position: absolute;
top: 0px;
padding-bottom: 2px;
padding-top: 2px;
background-color: whitesmoke;
}
.logo {
height: 28px;
width: 90px;
padding-top: 50px;
}
p {
color: white;
font-size: 6px;
text-align: left;
padding-left: 20px;
}
.navlist {
display: inline;
padding-left: 30px;
margin-left: 10px;
margin-right: 10px;
padding-right: 30px;
padding-top: 3px;
padding-bottom: 2.4px;
}
.nav {
list-style: none;
padding: 0;
width: 100%;
margin: 0;
top: 0px;
}
.imgs {
list-style: none;
margin: 0;
display: block;
padding-left: 0px;
float: right;
width: 30%;
}
.imgs img {
width: 9%;
height: 9%;
}
You should try to move the .imgs-div one level higher. Than it should be easier. One approach could be the flexbox model. So the wrapper-container gets
display: flex;
flex-direction: row;
justify-content: space-between;
I just did some more edits. Is this what you wanted to achive?
https://jsfiddle.net/qnw7a9zk/6/
You have given width:100% to .nav so it is taking full width and pushes images down. Keep the width ratio maintained in navigation and image. Like 80% navidation and 20 % images, see fiddle
https://jsfiddle.net/qnw7a9zk/5/
You may do it by display: inline-block
body {
background-color: #ffffff;
margin: 0;
display: table;
height: 100%;
width: 100%;
background-image: url(nice.jpg);
background-size: 100% 100%;
overflow: auto;
}
.wrapper {
text-align: center;
padding: 0px;
height: auto;
width: 100%;
}
footer {
background-color: #cbb492;
display: table-row;
height: 2px;
text-align: center;
}
li a {
text-decoration: none;
font-variant: small-caps;
color: black;
}
li:hover {
background-color: #cbb492;
}
nav {
padding-bottom: 2px;
padding-top: 2px;
background-color: whitesmoke;
text-align: center
}
.logo {
height: 28px;
width: 90px;
}
p {
color: white;
font-size: 6px;
text-align: left;
padding-left: 20px;
}
.navlist {
display: inline;
padding-left: 30px;
margin-left: 10px;
margin-right: 10px;
padding-right: 30px;
padding-top: 3px;
padding-bottom: 2.4px;
}
.nav {
list-style: none;
padding: 0;
margin: 0;
display: inline-block;
}
.imgs {
list-style: none;
margin: 0;
display: inline-block;
padding-left: 0;
}
<div class="wrapper">
<nav>
<ul class="nav">
<li class="navlist">Properties</li>
<li class="navlist">The Team</li>
<li class="navlist">Contact Us</li>
</ul>
<div class="imgs">
<img src="Instagram.png" />
<img src="Facebook.png" />
<img src="Twitter.png" />
</div>
</nav>
<img class="logo" src="Logo.png" />
</div>
<footer>
<p class="buttons">Real estate</p>
</footer>
</body>

Vertical align elements of different heights with top/bottom margin

I have been trying to vertical align links in a list, where all but one of the links has background color/border (to look like a button).
Even though the code on this fiddle works, it doesn't respect the reduced height of that link (the Sign In link).
html body,
ul,
div,
li,
a {
padding: 0;
margin: 0;
}
.left {
float: left;
}
.right {
float: right;
}
.inner {
height: 75px;
background-color: grey;
}
a {
color: white;
text-decoration: none;
font-weight: normal;
}
.logo {
display: block;
background-image: url(http://static1.tme.eu/pics/icons/no-image-placeholder-big.png);
background-size: 150px 20px;
background-position: left center;
background-repeat: no-repeat;
height: 100%;
width: 150px;
}
.right-nav {
height: 100%;
display: inline-block;
float: right;
}
ul {
height: 100%;
margin: 0;
}
ul li {
height: 100%;
float: left;
display: table;
margin: 0;
padding: 0;
line-height: 46px;
margin-left: 20px;
}
ul li a {
display: table-cell;
vertical-align: middle;
line-height: 46px;
}
.icon-user:before {
content: "\e745";
}
a.button {
height: 60px;
background-color: #f38060;
border-radius: 3px;
border: 1px solid #f38060;
box-sizing: border-box;
color: white;
display: table-cell;
font-size: 14px;
font-weight: normal;
line-height: 20px;
padding-bottom: 12px;
padding-left: 16px;
padding-right: 16px;
padding-top: 12px;
text-align: left;
vertical-align: middle;
}
<div class="inner">
<ul class="left">
<li>
<a class="logo" href="/"></a>
</li>
</ul>
<div class="right-nav">
<a class="mobile-menu right" href="#"><span class="icon-menu"></span>
</a>
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>
<a class="button" href="#" style="height: 60px;">Sign In
<span class="icon-user"></span>
</a>
</li>
</ul>
</div>
</div>
JSFiddle link: http://jsfiddle.net/6er3aguk/
What I would like to achieve is basically to have some sort of top/bottom margin on that Sign In link, so it doesn't stick to the top and bottom of the surrounding div.
Any ideas on how I can achieve that?
This is how I would create the effect that you're looking for.
This will vertically center the links, clear the parent properly. And irregardless of the browsers font-setting, at it's minimum width it will stop contracting with 15px of spacing between each element and the sides of the container if the window is smaller than the nav, instead of overlapping or moving to new lines.
This also completely avoids the use of floats and display: table hacks.
JSFiddle
*, *:before, *:after {
box-sizing: border-box;
}
html body, ul, div, li, a {
padding: 0;
margin: 0;
}
.left, .right {
position: absolute;
top: 0; bottom: 0;
white-space: nowrap;
}
.left {
position: absolute;
left: 15px;
}
.right {
text-align: right;
position: absolute;
left: 172.5px;
right: 0;
}
.inner {
position: relative;
height: 75px;
background-color: grey;
}
ul {
height: 100%;
font-size: 0;
}
ul:before {
content: " ";
height: 100%;
}
ul:before,
ul li {
display: inline-block;
vertical-align: middle;
}
ul li a {
font-size: 12pt;
display: block;
vertical-align: middle;
color: white;
text-decoration: none;
font-weight: normal;
padding: 10px 7.5px;
}
.right li:last-child {
padding-left: 7.5px;
padding-right: 15px;
}
.right a {
border-radius: 3px;
}
.right a:hover {
background: #888;
}
.icon-user:before {
content:"\e745";
}
a.button {
background: #f38060;
color: white;
padding: 10px 15px;
}
a.button:hover {
background: #f98666;
}
a.logo {
background-image: url(//placehold.it/150x20);
background-size: 150px 20px;
height: 20px;
width: 150px;
padding: 0px;
}
<div class="inner">
<ul class="left">
<li><a class="logo" href="/"></a></li>
</ul>
<div class="right">
<a class="mobile-menu" href="#">
<span class="icon-menu"></span>
</a>
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>
<a class="button" href="#">Sign In
<span class="icon-user"></span>
</a>
</li>
</ul>
</div>
</div>
You can achieve the preferred style by putting the Sign In text and the span inside a div and applying the same styles you did for a.button to that div.
html body,
ul,
div,
li,
a {
padding: 0;
margin: 0;
}
.left {
float: left;
}
.right {
float: right;
}
.inner {
height: 75px;
background-color: grey;
}
a {
color: white;
text-decoration: none;
font-weight: normal;
}
.logo {
display: block;
background-image: url(http://static1.tme.eu/pics/icons/no-image-placeholder-big.png);
background-size: 150px 20px;
background-position: left center;
background-repeat: no-repeat;
height: 100%;
width: 150px;
}
.right-nav {
height: 100%;
display: inline-block;
float: right;
}
ul {
height: 100%;
margin: 0;
}
ul li {
height: 100%;
float: left;
display: table;
margin: 0;
padding: 0;
line-height: 46px;
margin-left: 20px;
}
ul li a {
display: table-cell;
vertical-align: middle;
line-height: 46px;
}
.icon-user:before {
content: "\e745";
}
#signin {
max-height: 60px;
background-color: #f38060;
border-radius: 3px;
border: 1px solid #f38060;
box-sizing: border-box;
color: white;
display: table-cell;
font-size: 14px;
font-weight: normal;
line-height: 20px;
padding-bottom: 12px;
padding-left: 16px;
padding-right: 16px;
padding-top: 12px;
text-align: left;
vertical-align: middle;
}
<div class="inner">
<ul class="left">
<li>
<a class="logo" href="/"></a>
</li>
</ul>
<div class="right-nav">
<a class="mobile-menu right" href="#"><span class="icon-menu"></span>
</a>
<ul>
<li>Link 1
</li>
<li>Link 2
</li>
<li>Link 3
</li>
<li>
<a class="button" href="#" style="
height: 60px;
">
<div id="signin">Sign In<span class="icon-user"></span>
</div>
</a>
</li>
</ul>
</div>
</div>