I have a header on my website and I want to be able to set my canvas to fill all of the remaining height.
This is the Code:
<div include-html="../global/navbar.html">
<ul class="navbar">
<li class="navbar">Ben</li>
<li class="navbar">Projects</li>
</ul>
</div>
<div class="CanvasContainer">
<canvas id="Canvas" height="440" width="200">
</canvas>
</div>
canvas {
padding: 0;
margin: auto;
display: block;
width: 400px;
}
body {
padding: 0;
margin: 0;
background-color: #17141d;
color: white;
font-family: 'DM Mono', monospace;
}
ul.navbar {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #17141d;
}
li.navbar {
float: left;
}
li.navbar a{
display: block;
padding: 14px 16px;
}
a {
font-size: 20px;
text-align: center;
text-decoration: none;
background-color: #17141d;
color: white;
}
a:hover {
background-color: #262130;
background: linear-gradient(90deg,#ff8a00,#e52e71);
-webkit-text-fill-color: transparent;
background-clip: text;
-webkit-background-clip: text;
}
function LoadCanvas(){
var canvas = document.getElementById("Canvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(0, 0, 150, 75);
}
height:100%; sets the height to the height of the window
Filler so stackoverflow lets me save the edit:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
One way to take up the remaining space with the canvas would be to use flexbox.
In the following I use the property flex: 1 to tell the container to take the remaining space.
function LoadCanvas() {
var canvas = document.getElementById("Canvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(0, 0, 150, 75);
}
canvas {
padding: 0;
margin: auto;
display: block;
width: 400px;
height: 100%;
}
body {
padding: 0;
margin: 0;
background-color: #17141d;
color: white;
font-family: "DM Mono", monospace;
display: flex;
height: 100vh;
flex-direction: column;
}
.CanvasContainer {
display: flex;
flex: 1;
}
ul.navbar {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #17141d;
}
li.navbar {
float: left;
}
li.navbar a {
display: block;
padding: 14px 16px;
}
a {
font-size: 20px;
text-align: center;
text-decoration: none;
background-color: #17141d;
color: white;
}
a:hover {
background-color: #262130;
background: linear-gradient(90deg, #ff8a00, #e52e71);
-webkit-text-fill-color: transparent;
background-clip: text;
-webkit-background-clip: text;
}
<div include-html="../global/navbar.html">
<ul class="navbar">
<li class="navbar">Ben</li>
<li class="navbar">Projects</li>
</ul>
</div>
<div class="CanvasContainer">
<canvas id="Canvas"> </canvas>
</div>
Related
Is there any way I can get these collapsible boxes to be in a row but still open the full content on the page? They also need to be in three columns. before opening but when opened it should show its full content.
It also has to work in mobile view also. Here is some code to help you out but this would be very useful to know due to using a system that doesn't like Java
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type='text/css'>
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.center-content {
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.left {
-webkit-box-align: left;
-ms-flex-align: left;
align-items: left;
}
.right {
-webkit-box-align: right;
-ms-flex-align: right;
align-items: right;
}
.container {
display: flex;
align-items: center;
justify-content: left
}
img {
max-width: 100%
}
.image {
flex-basis: 40%
}
.text {
font-size: 20px;
padding-left: 0px;
}
/* Create two equal columns that float next to each other */
.column2 {
float: left;
width: 50%;
padding: 1%;
}
/* Create three equal columns that float next to each other */
.column3 {
float: left;
width: 33.33%;
padding: 1%;
}
/* Create four equal columns that float next to each other */
.column4 {
float: left;
width: 25%;
padding: 1%;
}
/* Create five equal columns that float next to each other */
.column5 {
float: left;
width: 20%;
padding: 1%;
}
/* Create six equal columns that float next to each other */
.column6 {
float: left;
width: 16.66666%;
padding: 1%;
}
/* Create seven equal columns that float next to each other */
.column7 {
float: left;
width: 16.5%;
padding: 0.5%;
}
/* Create eight equal columns that float next to each other */
.column8 {
float: left;
width: 12.5%;
padding: 0.5%;
}
/* Create nine equal columns that float next to each other */
.column9 {
float: left;
width: 11.1111%;
padding: 0.5%;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column2 {
width: 100%;
}
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column3 {
width: 100%;
}
}
/* Responsive layout - makes the four columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column4 {
width: 100%;
}
}
/* Responsive layout - makes the five columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column5 {
width: 100%;
}
}
/* Responsive layout - makes the six columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column6 {
width: 100%;
}
}
/* Responsive layout - makes the seven columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column7 {
width: 100%;
}
}
/* Responsive layout - makes the eight columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column8 {
width: 100%;
}
}
/* Responsive layout - makes the nine columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column9 {
width: 100%;
}
}
/* Responsive layout - makes two columns of different widths stack on top of each other instead of next to each other */
.first-column {
width: 30%;
padding: 1vw;
float: left;
}
.second-column {
width: 70%;
padding: 1vw;
float: right;
}
/* Responsive layout - another example where two columns of different widths stack on top of each other instead of next to each other */
.first-column1 {
width: 75%;
padding: 1vw;
float: left;
}
.second-column1 {
width: 25%;
padding: 1vw;
float: right;
}
/* Responsive layout - another example where two columns of different widths stack on top of each other instead of next to each other */
.first-columnheader {
width: 55%;
padding: 1vw;
float: left;
}
.second-columnheader {
width: 45%;
padding: 1vw;
float: right;
}
/* Responsive layout - makes two columns of different widths stack on top of each other instead of next to each other */
.first-columntext {
width: 100%;
padding: 1vw;
float: left;
}
.second-columntext {
width: 100%;
padding: 1vw;
float: right;
}
/* the next section defines what you want the columns to look like in mobile view - all are linked to the column set ups in the rows above */
#media only screen and (max-width: 768px) {
/* links to row 93 */
.first-column {
width: 100%;
padding-bottom: 10px;
float: none;
}
.second-column {
width: 100%;
padding-bottom: 10px;
float: none;
}
/* links to row 107 */
.first-column1 {
width: 100%;
padding-bottom: 10px;
float: none;
}
.second-column1 {
width: 100%;
padding-bottom: 10px;
float: none;
}
/* links to row 137 */
.first-columnheader {
width: 100%;
padding-bottom: 2px;
float: none;
}
.second-columnheader {
width: 100%;
padding-bottom: 2px;
float: none;
}
/* links to row 151 */
.first-columntext {
width: 100%;
padding-bottom: 10px;
float: none;
}
.second-columntext {
width: 100%;
padding-bottom: 10px;
float: none;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
}
#media (min-width: 140px)
{
.style1
{
font-size:11px;
}
.style2
{
font-size:11.5px;
}
.style3
{
font-size:12px;
}
.style4
{
font-size:12.5px;
}
.style5
{
font-size:14px;
}
.style6
{
font-size:16px;
}
#media (min-width: 768px)
{
.style1
{
font-size:11px;
}
.style2
{
font-size:12px;
}
.style3
{
font-size:14px;
}
.style4
{
font-size:18px;
}
.style5
{
font-size:24px;
}
.style6
{
font-size:32px;
}
}
#media (min-width: 1400px)
{
.style1
{
font-size:18px;
}
.style2
{
font-size:20px;
}
.style3
{
font-size:24px;
}
.style4
{
font-size:28px;
}
.style5
{
font-size:32px;
}
.style6
{
font-size:36px;
}
}
.center-text {
text-align: center;
}
.bg-rbgreen {
background-color: #50bc08;
}
.bg-rbpalegreen {
background-color: #95ea5c;
}
.bg-rbgray {
background-color: #969696;
}
.bg-rbpalegray {
background-color: #cacaca;
}
.bg-rbred {
background-color: #e03a40;
}
.bg-rboffwhite {
background-color: #f4f4f4;
}
.bg-rbblue {
background-color: #131f6b;
}
.bg-rbpaleblue {
background-color: #A4CFEA;
}
.border-dark {
border: 0.5rem solid #202223;
}
.border-thindarkgray {
border: 0.1rem solid #867d72;
}
.border-mediumdark {
border: 0.3rem solid #202223; border-radius: 25px;
}
.border-mediumlight {
border: 0.3rem solid #ffffff; border-radius: 25px;
}
.border-roundlight {
border: 0.3rem solid #ffffff; border-radius: 25px;
}
.border-light {
border: 0.5rem solid #ffffff;
}
.border-thicklight {
border: 1.3rem solid #ffffff;
}
.border-thinlight {
border: 0.5rem solid #ffffff;
}
.same-height {
-webkit-box-align: stretch;
-ms-flex-align: stretch;
align-items: stretch;
}
.tab {
margin-left: 5%;
}
.space-around {
margin: 0.5rem;
}
.space-around1 {
margin: 0rem;
}
.space-around2 {
margin: 0.5rem 0rem 0rem 0rem;
}
.space-around3 {
margin: 0.5rem 0rem 0rem 0.5rem;
}
.no-bottom-padding {
padding-bottom: 0px !important;
}
.text-white {
color: white;
}
.text-charcoal {
color: #3b3535;
}
/* img sizing */
img.xsmall {
width: 10% !important;
}
img.small {
width: 25% !important;
}
img.medium {
width: 50% !important;
}
img.large {
width: 75% !important;
}
img.xlarge {
width: 100% !important;
}
img.center {
margin: auto;
}
img.fill {
height: 100%;
width: 100%;
}
a {
text-decoration: none;
}
/* contain a tag within contents*/
a.contain {
display: contents !important;
}
/* ALLOW ITEMS IN BOX TO STACK */
.stacked {
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-flow: column;
flex-flow: column;
}
.layout {
height: 100%;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
width: 100%;
}
.layout .box {
/* FLEX BOXES (can apply flex styles like columns) */
/*display: inline-flex; */
position: relative;
-webkit-box-flex: 1;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
min-height: 100px;
width: 100%;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
.layout .box > p {
-webkit-box-flex: 0;
-ms-flex: none;
flex: none;
display: block;
}
.layout .box > img {
width: 100%;
display: block;
-ms-flex-item-align: center;
-ms-grid-row-align: center;
align-self: center;
}
.layout .box > a {
width: 100%;
display: block;
-ms-flex-item-align: center;
-ms-grid-row-align: center;
align-self: center;
}
.layout .box > a > * {
width: 100%;
display: block;
-ms-flex-item-align: center;
-ms-grid-row-align: center;
align-self: center;
}
.layout .box.p1 {
padding: 0.5rem;
}
.layout .box.p2 {
padding: 1rem;
}
.layout .box.p3 {
padding: 1.5rem;
}
.layout .box.p4 {
padding: 4rem;
}
.layout .box.p5 {
padding: 0.2rem;
}
.layout .box.pmxd {
padding: 0rem 0rem 0rem 2rem;
}
.layout .box.pmxd1 {
padding: 0rem 0rem 0rem 7rem;
}
.layout .box.pmxd2 {
padding: 0rem 0rem 0rem 1rem;
}
.layout.two {
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-flow: row;
flex-flow: row;
}
.layout.two.split_25_75 > .box, .layout.two.split_2575 > .box, .layout.two.split2575 > .box {
width: 25%;
}
.layout.two.split_25_75 > .box:nth-child(2n), .layout.two.split_2575 > .box:nth-child(2n), .layout.two.split2575 > .box:nth-child(2n) {
width: 75%;
}
.layout.two.split_80_20 > .box, .layout.two.split_8020 > .box, .layout.two.split8020 > .box {
width: 80%;
}
.layout.two.split_80_20 > .box:nth-child(2n), .layout.two.split_8020 > .box:nth-child(2n), .layout.two.split8020 > .box:nth-child(2n) {
width: 20%;
}
.layout.two.split_60_40 > .box, .layout.two.split_6040 > .box, .layout.two.split6040 > .box {
width: 60%;
}
.layout.two.split_60_40 > .box:nth-child(2n), .layout.two.split_6040 > .box:nth-child(2n), .layout.two.split6040 > .box:nth-child(2n) {
width: 40%;
}
.layout.two > .box {
width: 50%;
}
.layout.three > .box {
width: 33.333%;
}
.layout.four > .box {
width: 25%;
}
.layout.three.split_25_50_25 > .box, .layout.three.split25_50_25 > .box, .layout.three.split_255025 > .box, .layout.three.split255025 > .box {
width: 25%;
}
.layout.three.split_25_50_25 > .box:nth-child(2n), .layout.three.split25_50_25 > .box:nth-child(2n), .layout.three.split_255025 > .box:nth-child(2n), .layout.three.split255025 > .box:nth-child(2n) {
width: 50%;
}
.bottomRight {
position: absolute;
right: -1rem;
bottom: -1rem;
width: 50% !important;
}
/*
CSS for the main interaction
*/
.accordion > input[type="checkbox"] {
position: absolute;
left: -100vw;
}
.accordion .content {
overflow-y: hidden;
height: 0;
transition: height 0.3s ease;
}
.accordion > input[type="checkbox"]:checked ~ .content {
height: auto;
overflow: visible;
}
.accordion label {
display: block;
}
/*
Styling
*/
.accordion {
margin-bottom: 1em;
height: auto;
}
.accordion > input[type="checkbox"]:checked ~ .content {
padding: 15px;
border-top: 0;
}
.accordion .handle {
margin: 0;
font-size: 1.125em;
line-height: 1.2em;
}
.accordion label {
color: #000;
cursor: pointer;
font-weight: bold;
padding: 15px;
background: #14b1e8;
margin: 0em 65.5em 0em 1.5em;
}
.accordion label:hover,
.accordion label:focus {
background: #50bc08;
color: #fff;
}
.accordion .handle label:before {
content: "+";
display: inline-block;
margin-right: 10px;
font-size: .58em;
line-height: 1.556em;
vertical-align: middle;
}
.accordion > input[type="checkbox"]:checked ~ .handle label:before {
content: "-";
}
/*
CSS for the main interaction
*/
.accordion1 > input[type="checkbox"] {
position: absolute;
left: -100vw;
}
.accordion1 .content {
overflow-y: hidden;
height: 0;
transition: height 0.3s ease;
}
.accordion1 > input[type="checkbox"]:checked ~ .content {
height: auto;
overflow: visible;
}
.accordion1 label {
display: block;
}
/*
Styling
*/
.accordion1 {
margin-bottom: 1em;
height: auto;
}
.accordion1 > input[type="checkbox"]:checked ~ .content {
padding: 15px;
border-top: 0;
}
.accordion1 .handle {
margin: 0;
font-size: 1.125em;
line-height: 1.2em;
}
.accordion1 label {
color: #000;
cursor: pointer;
font-weight: bold;
padding: 15px;
background: #14b1e8;
margin: 0em 65.5em 0em 1.5em;
}
.accordion1 label:hover,
.accordion1 label:focus {
background: #50bc08;
color: #fff;
}
.accordion1 .handle label:before {
content: "+";
display: inline-block;
margin-right: 10px;
font-size: .58em;
line-height: 1.556em;
vertical-align: middle;
}
.accordion1 > input[type="checkbox"]:checked ~ .handle label:before {
content: "-";
}
/*
CSS for the main interaction
*/
.accordion2 > input[type="checkbox"] {
position: absolute;
left: -100vw;
}
.accordion2 .content {
overflow-y: hidden;
height: 0;
transition: height 0.3s ease;
}
.accordion2 > input[type="checkbox"]:checked ~ .content {
height: auto;
overflow: visible;
}
.accordion2 label {
display: block;
}
/*
Styling
*/
.accordion2 {
margin-bottom: 1em;
height: auto;
}
.accordion2 > input[type="checkbox"]:checked ~ .content {
padding: 15px;
border-top: 0;
}
.accordion2 .handle {
margin: 0;
font-size: 1.125em;
line-height: 1.2em;
}
.accordion2 label {
color: #000;
cursor: pointer;
font-weight: bold;
padding: 15px;
background: #14b1e8;
margin: 0em 65.5em 0em 1.5em;
}
.accordion2 label:hover,
.accordion2 label:focus {
background: #50bc08;
color: #fff;
}
.accordion2 .handle label:before {
content: "+";
display: inline-block;
margin-right: 10px;
font-size: .58em;
line-height: 1.556em;
vertical-align: middle;
}
.accordion2 > input[type="checkbox"]:checked ~ .handle label:before {
content: "-";
}
html {
height: 1800px;
}
#media (max-width: 800px) {
html {
height: 3200px;
}
}
/*# sourceMappingURL=base.css.map */
</style>
</head>
<body>
<div class="page" style="font-family: 'lato',helvetica;">
<div class="layout one">
<div class="border-thinlight style1" style="color: #131f6b; padding: 1vw;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
<section class="accordion">
<input type="checkbox" name="collapse" id="handle1">
<h2 class="handle">
<label for="handle1">Headers</label>
</h2>
<div class="content">
<div class="layout one">
<div class="column4 style1 bg-rboffwhite border-thinlight" style="min-height: 66vw; height: 100%; color: #002060; padding: 1vw;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="column4 style1 bg-rboffwhite border-thinlight" style="min-height: 66vw; height: 100%; color: #131f6b; padding: 1vw;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="column4 style1 bg-rboffwhite border-thinlight" style="min-height: 66vw; height: 100%; color: #131f6b; padding: 1vw;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<span class="style1" style="color: #ff0000;"><strong>Header</strong></span><br /><br />
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
<div class="column4 style1 bg-rboffwhite border-thinlight" style="min-height: 66vw; height: 100%; color: #131f6b; padding: 1vw;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
</div>
</section>
<section class="accordion1">
<input type="checkbox" name="collapse2" id="handle2">
<h2 class="handle">
<label for="handle2">Header</label>
</h2>
<div class="content">
<div class="layout one">
<div class="first-column" style="min-height: 20vw; height: 100%; padding: 1vw;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
<div class="second-column style1 bg-rboffwhite border-thinlight" style="min-height: 20vw; height: 100%; padding: 1vw; color: #002060;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
</div>
</section>
<section class="accordion2">
<input type="checkbox" name="collapse3" id="handle3">
<h2 class="handle">
<label for="handle3">Header</label>
</h2>
<div class="content">
<div class="layout one">
<div class="first-column style1 bg-rboffwhite border-thinlight" style="min-height: 42.5vw; height: 100%; padding: 1vw; color: #002060;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class="second-column style1 bg-rboffwhite border-thinlight" style="min-height: 42.5vw; height: 100%; padding: 1vw; color: #002060;">
<span style="color: #ff0000;"><strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
</div>
</section>
</div>
</body>
</html>
.accordion1 .content {
overflow-y: hidden;
height: 0;
transition: height 0.3s ease;
background-color: transparent;
position: absolute;
width: 100%;
z-index: -1;
border-radius: 6px;
left: 0;
I have found the answer it took a while but separate each column, then add left:0 then all the content goes to the left, but now got another problem, the content once selected is showing over one another. Just trying to find out how to stop it, I have tried removing the Z-index but it still does it. If there is any resolve for this would be greatly helpful
*Hello, I want to have text below the image like in the example, but I can't figure out what is wrong, i took the code from
W3Schools: https://www.w3schools.com
/css/tryit.asp?filename=trycss_ex_images_card
Can someone help? Thanks
Example Image: https://imgur.com/a/P86DVjW
What It Looks Like: https://imgur.com/a/JOXpAJI*
```{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body {
background: #32053d;
}
header {
position: absolute;
top: 0;
Left: 0;
width: 100%;
padding: 30px 100px;
display: flex;
justify-content: space-between;
align-items: center
}
header .logo
{
color: #fff;
font-weight: 700;
text-decoration: none;
font-size: 2em;
text-transform: uppercase;
letter-spacing: 2px;
}
header ul
{
display: flex;
justify-content: center;
align-items: center;
}
header ul li
{
list-style: none;
margin-left: 20px;
}
header ul li a
{
text-decoration: none;
padding: 6px 15px;
color: #fff;
border-radius: 20px;
}
header ul li a:hover,
header ul li a.active
{
background: #fff;
color: #4a2880;
}
h1 {
color: white;
margin-top: 250px;
margin-left: 270px;
}
p {
color:white;
margin-left: 60px;
text-align: center;
font-size: 15px;
}
.sec {
margin-right: 80px;
}
div.polaroid {
width: 80%;
background-color: white;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
margin-bottom: 25px;
}
div.container {
text-align: center;
padding: 10px 20px;
}
```<!DOCTYPE html>
<html>
<h1>ABC</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<center><img src="images/ArrowDown.webp" id="arrow" width="200"></center>
<div class="sec">
<center> <div class="polaroid">
<img src="Images/Darbs1.png" alt="Darbs1" style="width:100%">
<div class="container">
<p>Code</p>
</div>
</div> </center>
<center> <div class="polaroid">
<img src="images/Darbs1.png" alt="Darbs2" style="width:100%">
<div class="container">
<p>Code</p>
</div>
</div> </center>
<head>
<title>Projects</title>
<link rel="stylesheet" type="text/css" href="Website.css"
</head>
<body>
<header>
Logo
<ul>
<li>Home</li>
<li>About</li>
<li>Work</li>
<li>Contact</li>
</ul>
</header>
</body>
</html>```
The problem is with the css. You have set the p tag color:white that is why it is not showing. Set color:black
p {
color:black;
margin-left: 60px;
text-align: center;
font-size: 15px;
}
I approve of Usama's answer, the description is written in white on a white background.
You can add a specific rule:
.polaroid .container p {
color:black;
}
PS: Can you reformat your code?
Use 4 spaces or the button {} in the text editor
I'd like to simulate a "scan" light that will reveal words in a box, this is my code by now:
const e = document.getElementsByClassName('scan')[0];
document.onmousemove = function(event){
e.style.left = `${event.clientX}px`;
};
*{
margin: 0;
padding: 0;
}
html, body{
width: 100%;
min-height: 100vh;
overflow-x: hidden;
display: flex;
}
.banner{
width: 100vw;
height: 100vh;
display: flex;
flex-grow: 1;
flex-direction: row;
align-items: center;
background-color: #031321;
}
.banner .scan{
width: 7px;
height: 80%;
position: absolute;
left: 30px;
z-index: 3;
transition: left 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner .description{
width: 100%;
color: white;
font-size: 3em;
text-align: center;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
<div class="banner">
<div class="scan"></div>
<div class="description">
Just trying something
</div>
</div>
The idea is the show the words in the .description div according to the scan light position. If possible I'd like to use CSS only to make this effect, and use JavaScript only to move the scan (which will further become a CSS animation). I tried to use some pseudo elements, but it didn't work well. Here's an example of how this animation should work.
You can use transparent text with gradient background. I used background-attachment: fixed and a CSS variable to control background position.
You can increase the background-size (500px in this example) to increase transition smoothing.
const e = document.getElementsByClassName('scan')[0];
const hidden = document.getElementsByClassName('hidden')[0];
document.onmousemove = function(event) {
e.style.left = `${event.clientX}px`; // ↓ background width (500px) / 2
hidden.style.setProperty("--pos", `${event.clientX - 250}px`);
};
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
min-height: 100vh;
overflow-x: hidden;
display: flex;
}
.banner {
width: 100vw;
height: 100vh;
display: flex;
flex-grow: 1;
flex-direction: row;
align-items: center;
background-color: #031321;
}
.banner .scan {
width: 7px;
height: 80%;
position: absolute;
left: 30px;
z-index: 3;
transition: left 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow: 0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff;
/* outer cyan */
}
.banner .description {
width: 100%;
color: white;
font-size: 3em;
text-align: center;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
.hidden {
background: radial-gradient(dodgerblue 10%, #031321 50%) var(--pos) 50% / 500px 500px no-repeat fixed;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
<div class="banner">
<div class="scan"></div>
<div class="description">
Just <span class="hidden">hidden</span> something
</div>
</div>
Here is another example with very long paragraph and multiple hidden text. We control both X and Y axis in here.
const hiddens = document.querySelectorAll('.hidden');
document.addEventListener("mousemove", e => {
hiddens.forEach(p => {
// ↓ background width (400px) / 2
p.style.setProperty("--posX", `${e.clientX - 200}px`);
p.style.setProperty("--posY", `${e.clientY - 200}px`);
});
});
html,
body {
width: 100%;
overflow-x: hidden;
}
body {
background: #031321;
color: #fff;
font-size: 3rem;
line-height: 1.5;
padding: 20px;
box-sizing: border-box;
}
.hidden {
background: radial-gradient(dodgerblue 10%, #031321 50%) var(--posX) var(--posY) / 400px 400px no-repeat fixed;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
Lorem ipsum dolor sit amet, <span class="hidden">consectetur</span> adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. <span class="hidden">Excepteur sint</span> occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum
dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit
in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea <span class="hidden">commodo</span> consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim
id est laborum.
Here is an idea using transformation to have better performance
document.onmousemove = function(event){
document.body.style.setProperty("--p", `${event.clientX}px`);
};
body{
margin: 0;
overflow:hidden;
}
.banner{
height: 100vh;
display: flex;
align-items: center;
background-color: #031321;
}
.banner::before{
content:"";
width: 7px;
height: 80%;
position: absolute;
left: 0;
transform:translateX(var(--p,30px));
z-index: 3;
transition: transform 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner .description{
color: white;
font-size: 3em;
text-align: center;
width:100%;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
overflow:hidden;
position:relative;
}
.banner .description::before {
content:"";
position:absolute;
top:0;
right:0;
bottom:0;
width:200%;
background:linear-gradient(to right,#031321 40%,transparent,#031321 60%);
transform:translateX(var(--p,0px));
}
<div class="banner">
<div class="description">
Just trying something
</div>
</div>
To apply it to only few words, you play with z-index
document.onmousemove = function(event){
document.body.style.setProperty("--p", `${event.clientX}px`);
};
body{
margin: 0;
overflow:hidden;
}
.banner{
height: 100vh;
display: flex;
align-items: center;
background-color: #031321;
}
.banner::before{
content:"";
width: 7px;
height: 80%;
position: absolute;
left: 0;
transform:translateX(var(--p,30px));
z-index: 3;
transition: transform 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner .description{
color: white;
font-size: 3em;
text-align: center;
width:100%;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
overflow:hidden;
position:relative;
z-index:0;
}
.banner .description::before {
content:"";
position:absolute;
z-index:-1;
top:0;
right:0;
bottom:0;
width:200%;
background:linear-gradient(to right,#031321 40%,transparent,#031321 60%);
transform:translateX(var(--p,0px));
}
.banner .description > span {
position:relative;
z-index:-2;
color:lightblue;
font-weight:bold;
}
<div class="banner">
<div class="description">
Just <span>trying</span> something <span>cool</span>
</div>
</div>
Another idea to make it working with any background in case you want transparency:
document.onmousemove = function(event){
document.body.style.setProperty("--p", `${event.clientX}px`);
};
body{
margin: 0;
overflow:hidden;
}
.banner{
height: 100vh;
display: flex;
align-items: center;
justify-content:center;
color: white;
font-size: 3em;
background: url(https://picsum.photos/id/1018/800/800) center/cover;
position:relative;
z-index:0;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
.banner::before{
content:"";
width: 7px;
height: 80%;
position: absolute;
left: 0;
transform:translateX(var(--p,30px));
z-index: 3;
transition: transform 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner::after {
content:"";
position:absolute;
z-index:-1;
top:0;
right:0;
bottom:0;
left:0;
background:inherit;
-webkit-mask:
linear-gradient(to right,#fff 45%,transparent,#fff 55%)
right calc(-1*var(--p,0px)) top 0/200% 100% no-repeat;
}
.banner > span {
position:relative;
z-index:-2;
color:red;
font-weight:bold;
}
<div class="banner">
Just <span>trying</span> something <span>cool</span>
</div>
Cool glow stick!
I'm assuming that this is for a logo, and that the text should continue to be shown when the glow stick has passed the text.
I would use a pseudo-element on the description element, place it on top and use a gradient-background going from transparent to the darkblue background color. By using a gradient, you can achieve a nice fade in of the text.
I would then set the starting point of the dark background color with a CSS variable that I update through your onmousemove method.
The code doesn't take different screen sizes into account, so you probably need to convert pixels to percentage, if you want your animation to be responsive.
I also changed your classes to id. I think it's more appropriate to show, by using ids, that the element is somehow used by javascript. It's easier to bind the elements to variables too.
const scanEl = document.getElementById('scan');
const descEl = document.getElementById("description")
document.onmousemove = function(event){
let descriptionDisplacement = 100;
scanEl.style.left = `${event.clientX}px`;
descEl.style.setProperty("--background-shift", `${event.clientX + descriptionDisplacement}px`);
};
*{
margin: 0;
padding: 0;
}
html, body{
width: 100%;
min-height: 100vh;
overflow-x: hidden;
display: flex;
}
.banner{
width: 100vw;
height: 100vh;
display: flex;
flex-grow: 1;
flex-direction: row;
align-items: center;
background-color: #031321;
}
.banner > #scan{
width: 7px;
height: 80%;
position: absolute;
left: 30px;
z-index: 3;
transition: left 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner > #description{
width: 100%;
color: white;
font-size: 3em;
text-align: center;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
/* ADDED */
--background-shift: 0px;
--background-shift-transparent: calc(var(--background-shift) - 150px);
position: relative;
}
.banner > #description::before {
content: '';
background: linear-gradient(to right, transparent var(--background-shift-transparent), #031321 var(--background-shift));
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
<div class="banner">
<div id="scan"></div>
<div id="description">
Just trying something
</div>
</div>
I just tried clipPath. Technically it does what you need but the performance of the animated clipPath is quite poor when combined with the glow effect (but much better without!). Possibly building the glow from something like an image instead of a box-shadow would improve this. (as could reducing the size of the outer most box shadow)
const e = document.getElementsByClassName('scan')[0];
const description = document.getElementsByClassName('description')[0];
document.onmousemove = function(event){
// comment out to compare performance
e.style.left = `${event.clientX}px`;
description.style.clipPath = `polygon(0 0, ${event.clientX}px 0, ${event.clientX}px 100%, 0 100%)`;
};
*{
margin: 0;
padding: 0;
}
html, body{
width: 100%;
min-height: 100vh;
overflow-x: hidden;
display: flex;
}
.banner{
width: 100vw;
height: 100vh;
display: flex;
flex-grow: 1;
flex-direction: row;
align-items: center;
background-color: #031321;
}
.banner .scan{
width: 7px;
height: 80%;
position: absolute;
left: 30px;
z-index: 3;
transition: left 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner .description{
width: 100%;
color: white;
font-size: 3em;
text-align: center;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
<div class="banner">
<div class="scan"></div>
<div class="description">
Just trying something
</div>
</div>
Try like this:
const e = document.getElementsByClassName('cover')[0];
e.addEventListener('click', animate);
function animate() {
e.classList.add('scanning');
}
*{
margin: 0;
padding: 0;
}
html, body{
width: 100%;
min-height: 100vh;
overflow-x: hidden;
display: flex;
}
.banner{
width: 100vw;
height: 100vh;
display: flex;
flex-grow: 1;
flex-direction: row;
align-items: center;
background-color: #031321;
}
.banner .cover{
position: absolute;
left: 30px;
z-index: 3;
height: 80%;
width:100vw;
background-color: #031321;
transition: left 700ms ease-out 0s;
}
.banner .cover.scanning {
left: calc(100% - 30px);
}
.banner .scan{
width: 7px;
height:100%;
transition: left 50ms ease-out 0s;
border-radius: 15px;
background-color: #fff;
box-shadow:
0 0 15px 5px #fff, /* inner white */
0 0 35px 15px #008cff, /* inner blue */
0 0 350px 20px #0ff; /* outer cyan */
}
.banner .description{
width: 100%;
color: white;
font-size: 3em;
text-align: center;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
<div class="banner">
<div class="cover">
<div class="scan">
</div>
</div>
<div class="description">
Just trying something
</div>
</div>
This solution uses a cover to the right of the scan with the same background colour as the banner. The cover moves with the scan, so when the scan moves to the right, it reveals the text on the left. It works by clicking on it in this demo, but you can initiate it in JavaScript however is best for you.
Seems a little tricky. The first solution that comes to mind is maybe using a linear gradient with a dynamic "stopping point" at the light bar position. The gradient goes from dark -> transparent (light bar position) -> dark. The code will maybe look something like:
.description-overlay {
/*
Replace 50% with the position of the light bar. Get brighter and more
transparent as you approach the position of the light bar.
*/
background: linear-gradient(to right, #000, 50% hsla(0, 0%, 100%, 0.2), #000);
}
Not sure if this will work and it would probably need a box-shadow thrown in somewhere, but maybe it'll give you some ideas.
I'm trying to make a vertical navbar on the left of the page which is as long as the website (i.e. stretches down to the footer). However, it is only the right height when there is nothing above it - when I add the site's title, the navbar gets longer than the site.
body{
padding: 0px;
margin: 10px auto 0 auto;
font-family: 'corbel','arial';
background: #fff;
color: #444; /* text colour */
max-width: 1500px;
height: auto;
position: relative;
}
footer{
background: #333;
color: #fff;
padding: .1em 3em;
width: auto;
margin-left: 130px;
}
h1{
text-align: center;
font-size: 85px;
padding: 10px;
margin: auto;
margin-top: 10px;
}
#content{
margin-left: 150px;
}
/* Navbar */
#navbar{
background-color: #599;
list-style-type: none;
overflow: hidden;
width: 130px;
margin: 0px;
font-family: 'corbel','arial';
text-align: center;
padding-left: 0px;
height: 100%;
float: left;
position: absolute;
}
#nav_li{
text-align: center;
}
#nav_a{
text-decoration: none;
margin: 10px;
display: inline-block;
color: white;
}
<h1>Website Title</h1>
<body>
<ul id='navbar'>
<li id='nav_li'><a id='nav_a' href='index.html'>Home</a></li>
<li id='nav_li'><a id='nav_a' href='gallery.html'>Gallery</a></li>
<li id='nav_li'><a id='nav_a' href='reviews.html'>Our reviews</a></li>
</ul>
<div id='nav_fill'> </div>
<div id='content'>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<footer>
<p>Content © Business Name - Website design ©</p>
</footer>
</body>
Big thanks to anyone who can help!
There are multiple ways of fixing this problem - the easiest is to just put the html, body background color as the sidebar in CSS (with height: 100%), then add a sticky header and footer at the top and bottom, and put a background-color on the container-element.
Something like this:
* { margin: 0; padding: 0;}
html, body {
height: 100%;
background: blue;
}
#content {
background: white;
}
h1 {
background: white;
position: absolute;
top: 0;
left: 0;
right: 0;
height: 3em;
}
#menu {
margin-top: 3.5em;
float: left;
width: 7em;
color: white;
}
#content {
background: white;
height: 100%;
margin: 3em 0 4em 7em;
padding-top: 3.5em;
}
footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 4em;
background: gray;
}
<body>
<h1>This is a heading</h1>
<ul id="menu">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<div id="content">
<p>Something goes in here</p>
</div>
<footer>This is the footer</footer>
</body>
Try using position:fixed, and min/max-height i also suggest to use calc(), to calculate good size of navbar.
Here You have jsfiddle
I am unable to put " a:hover " on my home button in menu bar. even unable to remove the text-decoration.
while i was trying my hands on media queries , just got puzzled.
****stack overflow settings is not allowing me to post question unless i add more details*****
body {
background-image: url("blue-bokeh.jpeg");
width: 100%;
height: 100%;
}
.wrap {
height: auto;
width: 90%;
margin: auto;
}
header {
background: #333;
color: white;
height: auto;
width:100%;
float: left;
}
header nav {
width: 100%;
height: auto;
}
header nav ul {
list-style: none;
height: auto;
width: auto; /* what happens if i change the value to 100% */
float: right;
margin-right:30px;
}
header nav ul li {
display: inline;
padding: 15px 30px;
float: left;
border-radius: 5px;
}
header nav ul li a.active {
text-decoration: none;
}
header nav ul li:hover {
background-color: #111;
}
header nav ul li a.active:active {
background-color: #4caf50;
}
.mainbody {
/*background: tomato;*/ /* get the code checked , if its repeated in .top class */
float: left;
margin-top: 20px;
border-radius: 10px;
/*padding: 20px 20px;*/
height: auto;
width: 60%;
margin-right: 2%;
}
.top {
background: tomato;
margin-bottom: 10px;
float: left;
border-radius: 10px;
padding: 20px 20px;
}
.top h3 {
color: darkslategray
}
.bottom {
background: tomato;
margin-bottom: 50px;
float: left;
border-radius: 10px;
padding: 20px 20px;
}
.bottom h3 {
color: darkslategray
}
.sidebar {
float: left;
height: auto;
width: 38%;
margin-top: 20px;
}
.topside {
background: orangered;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
.middleside {
background: orangered;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
.bottomside {
background: orangered;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
footer {
background: darkslategray;
float: left;
width: 100%;
height: auto;
border-radius: 10px;
}
footer p {
padding-left: 50px;
}
/* ------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------MEDIA QUERY STARTS HERE---------------------------------------------------------------*/
#media screen and (max-width: 700px) {
body {
background-image: url("blue-bokeh.jpeg");
width: 100%;
height: 100%;
}
.wrap {
height: auto;
width: 90%;
margin: auto;
}
header {
background: #444;
color: white;
height: auto;
width:100%;
}
header nav {
width: 100%;
height: auto;
}
header nav ul {
list-style: none;
height: auto;
width: 100%; /* what happens if i change the value to 100% */
margin: 0;
padding: 0;
text-align: center;
}
header nav ul li {
display: block;
padding: 15px 30px;
float: none;
}
header nav ul li:hover {
background-color: #111;
}
header nav ul li a.active:active {
background-color: #4caf50;
}
.mainbody {
/*background: tomato;*/ /* get the code checked , if its repeated in .top class */
margin-top: 20px;
border-radius: 10px;
/*padding: 20px 20px;*/
height: auto;
width: 100%;
}
.top {
background: tomato;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
.top h3 {
color: darkslategray
}
.bottom {
background: tomato;
border-radius: 10px;
padding: 20px 20px;
}
.bottom h3 {
color: darkslategray
}
.sidebar {
height: auto;
width: 100%;
}
.topside {
background: orangered;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
.middleside {
background: orangered;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
.bottomside {
background: orangered;
margin-bottom: 10px;
border-radius: 10px;
padding: 20px 20px;
}
footer {
background: darkslategray;
float: left;
width: 100%;
height: auto;
border-radius: 10px;
}
footer p {
padding-left: 50px;
}
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href="restheme.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="wrap">
<header>
<nav>
<ul>
<li><a class="active" href="#home">Home</a></li>
<li>Portfolio</li>
<li>Blog</li>
<li>Contact Us</li>
</ul>
</nav>
</header>
<div class="mainbody">
<article class="top">
<h3>First Post</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</article>
<article class="bottom">
<h3>Second Post</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</article>
</div>
<div class="sidebar">
<aside class="topside">
<h3>Top Sidebar</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</aside>
<aside class="middleside">
<h3>Middle Sidebar</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</aside>
<aside class="bottomside">
<h3>Bottom Sidebar</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</aside>
</div>
<footer>
<p>Copyright © 2016 Faltoo Webdesigns</p>
</footer>
</div>
</body>
</html>
If I understand you right, you want to achive something like this?
https://jsfiddle.net/j7j54Lta/1/
I did some improvements and changed the structure. The li gets the .active-class and not the anchor. If the anchor in the active li is hovered it changes the color (or whatever you want to achive):
header nav ul li.active a:hover{
color: red;
/* or whatever*/
}
Moreover there is no text-decoration:
header nav ul li.active a {
text-decoration: none;
cursor: default;
}