I have placed some media queries into my code to state if the screen resolution is less than 768px; the .sideBar disappears like so, leaving the .main section.
#media (max-width: 768px) {
.sideBar {
display: none !important;
}
}
What I would like to achieve is when the screen resolution is like this, I would like a hamburger icon to appear that allows me to toggle open/close the .sideBar.
How would I go about this in code-wise?
If there are any previous tutorials like this, please attach.
Original Code attached:
/* Copyright (c) myEd (made by students, for students.) 2018. */
body { /* General Body Properties */
font-family: Trebuchet MS, Georgia, Helvetica, sans-serif;
margin: 0;
overflow: hidden;
}
* { /* Key element to aligning <divs> (DO NOT REMOVE) */
box-sizing: border-box;
}
#wrapper {
bottom: 0;
left: 0;
overflow: hidden;
position: absolute;
right: 0;
top: 0
}
.header { /* Header properties featuring myEd and school emblems */
padding: 30px;
text-align: center; /* Aligns links in the navBar */
background-image: url(/Default/Img/backgroundHeader-4K.jpg);
background-size: cover;
background-repeat: no-repeat;
}
.myEd-reverse {
width: 240px;
height: 70px;
float: left;
margin-left: -60px;
margin-top: -40px;
}
.navBar { /* Sticky navBar, either relative or fixed, depending on the scroll position of the site */
overflow: hidden;
background-color: #333;
position: sticky;
position: -webkit-sticky;
top: 0;
z-index: 100000;
}
.navBar a { /* Style the navBar links */
float: left;
display: block;
color: #fff;
text-align: center;
padding: 6px 12px;
text-decoration: none;
}
.navBar a.right { /* Float Quick Links, Help and Log-out navBar directory items to the right of the navBar */
float: right;
}
.navBar a:hover { /* Change color on hover */
background-color: #ddd;
color: #000;
}
.navBar a.active { /* Active Link */
background-color: #666;
color: #fff;
}
.modalDialog { /* Modal Properties for all modals in myEd */
position: fixed;
font-family: Trebuchet MS, Georgia, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
opacity:0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}
.modalDialog:target { /* Modal Properties for all modals in myEd */
opacity:1;
pointer-events: auto;
}
.modalDialog > div { /* Modal Properties for all modals in myEd */
width: 400px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #d7d7d7;
background: -moz-linear-gradient(#ddd, #666);
background: -webkit-linear-gradient(#ddd, #666);
background: -o-linear-gradient(#ddd, #666);
}
.close { /* Modal Properties for all modals in myEd */
background: #606061;
color: #FFFFFF;
line-height: 10px;
position: absolute;
right: -5px;
text-align: center;
top: -10px;
width: -5px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}
.close:hover { background: #00d9ff; } /* Modal Properties for all modals in myEd */
.textModalh2 { /* Text preferences of the modal box directed from the navBar */
margin-top: 18px;
margin-bottom: -15px;
}
.textModalh5 { /* Text preferences of the modal box directed from the navBar */
margin-bottom: -15px;
}
.CARTHmodal { /* Image preferences of CARTH in the modal box directed from the navBar */
border-radius: 50%;
height: 130px;
width: 120px;
float: left;
margin-right: 40px;
margin-top: 15px
}
.row { /* Alignment between sideBar and main */
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.sideBar { /* sideBar alignment properties */
-ms-flex: 20%;
flex: 20%;
background-color: #a7a7a7;
padding: 0px;
height: 5000px; /* As standard to work on all screen resolutions, overflow hides excess */
overflow-y: scroll; /* Allows myEd news to scroll */
overflow: hidden;
position: relative;
}
#newsmyEd {
position: absolute;
width: 100%;
height: calc(100vh - 120px);
top: 0;
right: 0;
}
.main { /* Main Column */
-ms-flex: 80%;
flex: 80%;
background-color: #a7a7a7;
padding: 0px;
height: 5000px; /* As standard to work on all screen resolutions, overflow hides excess */
overflow-y: scroll; /* Allows embedded iFrame to scroll */
position: relative;
overflow: hidden;
}
.frameMain { /* Frame Properties */
position: absolute;
top: 0;
left: 0;
border: 0;
height: calc(100vh - 120px);
}
.footer { /* Footer properties */
position: fixed;
bottom: 0;
left: 0;
right: 0;
background-color: #333;
}
.footer a { /* Footer navBar properties */
float: right;
display: block;
color: #fff;
text-align: center;
padding: 6px 12px;
text-decoration: none;
}
.footer a:hover { /* Change color on hover */
background-color: #ddd;
color: #000;
}
.footer a.active { /* Active Link */
background-color: #666;
color: #fff;
}
#media (max-width: 768px) {
.sideBar {
display: none !important;
}
}
<!DOCTYPE HTML>
<!-- Copyright (c) myEd (made by students, for students.) 2018. -->
<html lang="en">
<head>
<title>Welcome | myEd</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="/Home/Welcome/Style/style.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz" crossorigin="anonymous">
<link rel="shortcut icon" href="/Default/Img/faviconmyEd-16x16.png">
</head>
<body>
<script> // Required scripts for certain activities on myEd, each entry will be noted for understanding
</script>
<div id="wrapper"> <!-- Wrapper fitting website to all screen resolutions -->
<div class="header"> <!-- Header featuring 4K Background, myEd and school emblems -->
<img src="/Default/Img/myEd-reverse.png" class="myEd-reverse" alt="myEd" title="myEd Software"> <!-- myEd Software -->
</div>
<div class="navBar"> <!-- Main sticky navBar with categories listed -->
<i class="fa fa-home"></i> <!-- Home -->
<i class="fa fa-book"></i> <!-- Learning -->
<i class="fa fa-user"></i> <!-- Student Management -->
<i class="fa fa-globe"></i> <!-- Portals -->
<i class="fas fa-sign-out-alt"></i> <!-- Log-out (right to left) -->
<i class="fa fa-question-circle"></i> <!-- Help (right to left) -->
<i class="fa fa-bookmark"></i> <!-- Quick Links (right to left) -->
<div id="modalQL" class="modalDialog">
<div>
X
<h3>Quick Links</h3>
<h6>SEQTA Learn</h6>
<h6>SEQTA Engage</h6>
<h6>Adventist Schools Australia</h6>
<br>
<h6><em>The links above are not available via the Portal Pages of myEd as they are unable to be embedded into the software.</em></h6>
</div>
</div>
<i class="fas fa-caret-down"></i> <!-- Profile dropDown (right to left) -->
<div id="modalPO" class="modalDialog">
<div>
X
<img class="CARTHmodal" src="/Default/Img/CARTH.jpg" title="Carpenter, Tom" alt="CARTH">
<h2 class="textModalh2">Tom Carpenter</h2>
<h5 class="textModalh5" title="tom.carpenter#kas.nsw.edu.au">tom.carpenter#kas.nsw.edu.au</h5>
<h5 class="textModalh5" title="Student ID: #714020 (CARTH)">#714020 (CARTH)</h5>
<h5 class="textModalh5" title="Year Group: Year 11 (11B)">Year 11 (11B)</h5>
<h5>Kempsey Adventist School</h5>
</div>
</div>
</div>
<div class="row"> <!-- Format for alignment of the sideBar and main panels -->
<div class="main"> <!-- Main learning or collaborative workspace -->
<iframe class="frameMain" width="100%" src="/Home/Welcome/iFrame/index.html"></iframe> <!-- Embedded frame -->
</div>
<div class="sideBar"> <!-- sideBar featuring Profile, myEd News and directory -->
<iframe id="newsmyEd" frameborder="0" src="/Default/News/index.html"></iframe> <!-- myEd News -->
</div>
</div>
<div class="footer"> <!-- Featuring Site Navigation and myEd News navBar links -->
<i class="far fa-newspaper"></i> <!-- myEd News -->
<i class="fa fa-location-arrow"></i> <!-- Site Navigation -->
</div>
</div>
</body>
</html>
Thanks, Tom
I guess this is what you are looking for, to make a clear view I took the google map iframe and wrapper it with a div. Then I am toggling the wrapper for icon clicks.
Here is the codepen
$(document).ready(function() {
$('.mobile-menu-icon i.open').click(function() {
$('.sidebar-wrapper').fadeIn();
$(this).hide();
$('.mobile-menu-icon i.close').fadeIn();
});
$('.mobile-menu-icon i.close').click(function() {
$('.sidebar-wrapper').fadeOut();
$(this).hide();
$('.mobile-menu-icon i.open').fadeIn();
});
});
.mobile-menu-icon i.close {
display: none;
}
#media (min-width:768px) {
.mobile-menu-icon {
display: none;
}
}
#media (max-width:767px) {
.mobile-menu-icon {
display: block;
}
.sidebar-wrapper {
display: none;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="sideBar">
<!-- sideBar featuring Profile, myEd News and directory -->
<div class="mobile-menu-icon">
<i class="fa fa-bars open" aria-hidden="true"></i>
<i class="fa fa-times close" aria-hidden="true"></i>
</div>
<div class="sidebar-wrapper">
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d15775.879464660959!2d81.17930883590694!3d8.694411361230227!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3afbbfb5c9304551%3A0xc6d99d1084095189!2sNilaveli!5e0!3m2!1sen!2slk!4v1542627461123"
width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
<!-- myEd News -->
</div>
</div>
Related
I do not want to use anything except css and html. What can be changed to fix the text from coming outside of the card? My text keeps overflowing outside of my card. I want it all to fit in without compromising the card size as well. I have tried resizing. I am also new to coding. I would accept all and any feedback. If you have links or videos please share those also.
* {
margin:0;
padding: 0;
}
body {
color: #fff;
-webkit-font-smoothing: antialiased;
font-size: 25px;
background-color: #b4b4b4;
}
/* Header Start */
#vanta-canvas {
width: 100vw;
height: 50vh;
}
.inner_header {
width: 100%;
height: 100%;
margin: 0 auto;
text-align: center;
position: relative;
top: 75px;
}
.flex {
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
flex-wrap: nowrap;
align-content: normal;
}
header p {
color: #b4b4b4;
font-family: cursive;
-webkit-font-smoothing: antialiased;
font-size: 50px;
}
.highlight {
color: blue;
-webkit-font-smoothing: antialiased;
}
button {
background-color: transparent;
border-radius: 45% 3px;
color: #b4b4b4;
padding: 10px 20px;
text-decoration: none;
display: inline-block;
font-size: 20px;
cursor: pointer;
margin: 0 auto;
text-align: center;
position: relative;
top: 25px;
-webkit-font-smoothing: antialiased;
transition: all 0.3s;
}
button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.3s;
}
button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.3s;
}
button:hover, button:focus{
background-color: grey;
color: blue;
}
button:hover span {
padding-right: 25px;
}
button:hover span:after{
opacity: 1;
right: 0;
}
/* Header End */
/* navigation Start */
nav {
background: blue;
border-bottom: solid 2px;
border-bottom-color: white;
}
nav li {
display: inline-block;
margin-left: 30px;
}
nav a {
text-decoration: none;
color: #fff;
}
/* Navigation End */
/* Section About Start */
section {
box-align: center;
}
section h2 {
text-align: center;
margin-top: 100px;
/* border-bottom: solid 3px; */
color: black;
position: relative;
left: 50%;
transform: translateX(-50%)
}
section h2::after {
content:"";
height: 3px;
width: 70px;
position: absolute;
background: #000000;
margin: auto;
bottom: -5px;
left: 0;
right: 0;
}
section p {
padding: 20px;
text-align: center;
position: relative;
margin: auto;
}
/* Section About End */
/* Section Portfolio Start */
.flip-card {
background-color: transparent;
width: 300px;
height: 200px;
border: 1px solid #f1f1f1;
perspective: 1000px;
}
.flip-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-card:hover .flip-card-inner{
transform: rotateY(180deg);
}
.flip-card-front, .flip-card-back {
position: absolute;
width: 100%;
height: 100%;
-webkit-backgrace-visibility: hidden;
backface-visibility: hidden;
}
.flip-card-back {
background-color: transparent;
color: white;
transform: rotateY(180deg);
}
/* #media screen and (max-width: 600px){ */
/* .column {
width: 100%;
display: block;
margin-bottom: 20px;
}
} */
<!DOCTYPE html>
<html lang="en_US">
<head>
<meta charset="UTF-8" />
<title>Portfolio</title>
<link rel="stylesheet" href="./assets/css/style.css" >
</head>
<body>
<!-- Header Start -->
<div id="vanta-canvas">
<header>
<h1 class="inner_header" class="flex" id="Home">
<p>
Hello, I'm
<span class="highlight">Brian Mojica.</span>
<br>
I'm a full-stack web developer.
<button class="flex" style="vertical-align:middle"><span>
View My Work
</span></button>
</p>
</h1>
</header>
</div>
</header>
<!--Header End-->
<!-- Navigation Start -->
<nav>
<ul>
<li>
HOME
</li>
<li>
ABOUT
</li>
<li>
PORTFOLIO
</li>
<li>
BLOG
</li>
<li>
CONTACT
</li>
<li>
RESUME
</li>
</ul>
</nav>
<!--Navigation End-->
<!--Section About-->
<section>
<h2 id="About">ABOUT</h2>
<p>
I'm a full stack developer seeking employment.
I have a passion developing webpages that are responsive, dynamic, and accessbile.
Animations and UI effects are skills I hope to sharpen. I will continually expand my knowledge in different platforms such as Python, JavaScript, and React.
</p>
</section>
<!--Section Portfolio-->
<section>
<h2 id="Portfolio">PORTFOLIO</h2>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="assets/images/run-buddy-card.png" alt="Webpage" style="width:100%" height="100%">
</div>
<div class="flip-card-back">
<h1>Run Buddy</h1>
<p class="highlight"> HTML / CSS</p>
<p>A webpage for Run Buddy. They are a company that matches runners with personal trainers. </p>
<button class="flex" style="vertical-align:middle"><span> View</span></button>
</div>
</div>
</div>
</section>
<!--Section Blog-->
<section>
<h2 id="Blog">BLOG</h2>
<p>Under Construction</p>
</section>
<!--Section Contact-->
<section>
<h2 id="Contact">CONTACT</h2>
</section>
<!--Section Resume-->
<section>
<a id="resume" href="https://drive.google.com/file/d/1uVWXW7AULRBQBeXEblFfHNawPX-pHrJC/view?usp=sharing"></a>
</section>
<!--script for header background Start-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r121/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta#latest/dist/vanta.waves.min.js"></script>
<script>
VANTA.WAVES({
el: "#vanta-canvas",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 100.00,
minWidth: 100.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x102
})
</script>
<!--script for header background End-->
</body>
</html>
You can use overflow: hidden or overflow: scroll properties in the .flip-card-back class to either hide the content that isn't fitting or make it scrollable. You should also keep in mind the size of the content, it's too much for the card's dimensions. Styling properly the text inside the card would be the best approach.
I changed your code. Please check. the important point is to use font-size: 6vmin in here for #vanta-canvas. I used that instead of h1. It causes a font-size based on screen size.
Note: https://css-tricks.com/viewport-sized-typography/
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
color: #fff;
-webkit-font-smoothing: antialiased;
font-size: 25px;
background-color: #b4b4b4;
}
/* Header Start */
#vanta-canvas {
width: 100%;
height: 50vh;
display: flex;
align-items: center;
border: solid;
font-weight: bold;
font-size: 6vmin; /* here */
}
.inner_header {
width: 100%;
margin: 0 auto;
text-align: center;
}
.flex {
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
flex-wrap: nowrap;
align-content: normal;
}
.inner_header p {
color: #b4b4b4;
font-family: cursive;
-webkit-font-smoothing: antialiased;
}
.highlight {
color: blue;
-webkit-font-smoothing: antialiased;
}
button {
background-color: transparent;
border-radius: 45% 3px;
color: #b4b4b4;
padding: 10px 20px;
text-decoration: none;
display: inline-block;
font-size: 20px;
cursor: pointer;
margin: 0 auto;
text-align: center;
position: relative;
top: 25px;
-webkit-font-smoothing: antialiased;
transition: all 0.3s;
}
button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.3s;
}
button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.3s;
}
button:hover,
button:focus {
background-color: grey;
color: blue;
}
button:hover span {
padding-right: 25px;
}
button:hover span:after {
opacity: 1;
right: 0;
}
/* Header End */
/* navigation Start */
nav {
background: blue;
border-bottom: solid 2px;
border-bottom-color: white;
}
nav li {
display: inline-block;
margin-left: 30px;
}
nav a {
text-decoration: none;
color: #fff;
}
/* Navigation End */
/* Section About Start */
section {
box-align: center;
}
section h2 {
text-align: center;
margin-top: 100px;
/* border-bottom: solid 3px; */
color: black;
position: relative;
left: 50%;
transform: translateX(-50%)
}
section h2::after {
content: "";
height: 3px;
width: 70px;
position: absolute;
background: #000000;
margin: auto;
bottom: -5px;
left: 0;
right: 0;
}
section p {
padding: 20px;
text-align: center;
position: relative;
margin: auto;
}
/* Section About End */
/* Section Portfolio Start */
.flip-card {
background-color: transparent;
width: 300px;
height: 200px;
border: 1px solid #f1f1f1;
perspective: 1000px;
}
.flip-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-card:hover .flip-card-inner {
transform: rotateY(180deg);
}
.flip-card-front,
.flip-card-back {
position: absolute;
width: 100%;
height: 100%;
-webkit-backgrace-visibility: hidden;
backface-visibility: hidden;
}
.flip-card-back {
background-color: transparent;
color: white;
transform: rotateY(180deg);
}
/* #media screen and (max-width: 600px){ */
/* .column {
width: 100%;
display: block;
margin-bottom: 20px;
}
} */
<!-- Header Start -->
<div id="vanta-canvas">
<div class="inner_header" class="flex" id="Home">
<p>
Hello, I'm
<span class="highlight">Brian Mojica.</span>
<br> I'm a full-stack web developer.
<button class="flex" style="vertical-align:middle"><span>
View My Work
</span></button>
</p>
</div>
</div>
</header>
<!--Header End-->
<!-- Navigation Start -->
<nav>
<ul>
<li>
HOME
</li>
<li>
ABOUT
</li>
<li>
PORTFOLIO
</li>
<li>
BLOG
</li>
<li>
CONTACT
</li>
<li>
RESUME
</li>
</ul>
</nav>
<!--Navigation End-->
<!--Section About-->
<section>
<h2 id="About">ABOUT</h2>
<p>
I'm a full stack developer seeking employment. I have a passion developing webpages that are responsive, dynamic, and accessbile. Animations and UI effects are skills I hope to sharpen. I will continually expand my knowledge in different platforms such
as Python, JavaScript, and React.
</p>
</section>
<!--Section Portfolio-->
<section>
<h2 id="Portfolio">PORTFOLIO</h2>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="assets/images/run-buddy-card.png" alt="Webpage" style="width:100%" height="100%">
</div>
<div class="flip-card-back">
<h1>Run Buddy</h1>
<p class="highlight"> HTML / CSS</p>
<p>A webpage for Run Buddy. They are a company that matches runners with personal trainers. </p>
<button class="flex" style="vertical-align:middle"><span> View</span></button>
</div>
</div>
</div>
</section>
<!--Section Blog-->
<section>
<h2 id="Blog">BLOG</h2>
<p>Under Construction</p>
</section>
<!--Section Contact-->
<section>
<h2 id="Contact">CONTACT</h2>
</section>
<!--Section Resume-->
<section>
<a id="resume" href="https://drive.google.com/file/d/1uVWXW7AULRBQBeXEblFfHNawPX-pHrJC/view?usp=sharing"></a>
</section>
<!--script for header background Start-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r121/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta#latest/dist/vanta.waves.min.js"></script>
<script>
VANTA.WAVES({
el: "#vanta-canvas",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 100.00,
minWidth: 100.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x102
})
</script>
<!--script for header background End-->
On larger screen size:
On smaller screen size:
I have put down below my HTML and CSS. I can't figure out why the gap is there and the bottom. I will put a picture in as well.
My Code :
/*
Landon Byrd
Fall 2021
Light Blue #06aed5
Darker Blue #086788
Cream White #f2f4f3
Yellow #f0c808
Rich Red #dd1c1a
Black #333
*/
/* Global Settings */
h1 {text-align: center}
h2 {text-align: center; color: #086788;}
h3 {text-align: center; color: #086788; text-decoration: underline #f2f4f3; text-shadow: 2px 2px #f2f4f3;}
.wrapper{width:85%; margin:0 auto; max-width: 960px; }
/* Nav Section */
/* Add a black background color to the top navigation */
.topnav {
position: relative;
background-color: #333;
overflow: hidden;
}
/* Style the links inside the navigation bar */
.topnav a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/* Change the color of links on hover */
.topnav a:hover {
background-color: #ddd;
color: black;
opacity: 0.5;
}
/* Add a color to the active/current link */
.topnav a.active {
background-color: #f0c808;
color: white;
}
/* Centered section inside the top navigation */
.topnav-centered a {
float: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
/* Right-aligned section inside the top navigation */
.topnav-right {
float: right;
}
/* Responsive navigation menu - display links on top of each other instead of next to each other (for mobile devices) */
#media screen and (max-width: 600px) {
.topnav a, .topnav-right {
float: none;
display: block;
}
.topnav-centered a {
position: relative;
top: 0;
left: 0;
transform: none;
}
}
/* Main Section */
.banner{justify-content: center;background-color: #333; border-radius: 2pt; color: #f2f4f3; border-radius: 5%;}
.name{font-weight: bold; color: #f0c808}
.column {
float: left;
width: 50%;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
.img1 {float:left; width: 300px; height: 350px; margin:15px; border-radius: 20%;}
.img2 {float: right; width: 330px; height: 350px; border-radius: 20%;}
body {
background-image: url("images/background.jpg");
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
font-size: 16px
}
/* Footer Section */
*{box-sizing: border-box;}
.footer{text-align: center; background-color: #333; color: #f2f4f3; }
.box{float:left; width: 33.33%;}
.footer::after{content: ""; clear:both; display:table;}
/* copyright section */
.copyright {text-align: center; background-color: #333; color: #f2f4f3; }
/* Menu */
.container {
max-width: 1200px;
margin: 0 auto;
padding: 1.5em;
}
.menu {
font-family: "Inter", sans-serif;
font-size: 14px;
}
.menu-group-heading {
margin: 0;
padding-bottom: 1em;
border-bottom: 2px solid #ccc;
}
.menu-group {
display: grid;
grid-template-columns: 1fr;
gap: 1.5em;
padding: 1.5em 0;
}
.menu-item {
display: flex;
}
.menu-item-image {
width: 80px;
height: 80px;
flex-shrink: 0;
object-fit: cover;
margin-right: 1.5em;
}
.menu-item-text {
flex-grow: 1;
}
.menu-item-heading {
display: flex;
justify-content: space-between;
margin: 0;
}
.menu-item-name {
margin-right: 1.5em;
}
.menu-item-description {
line-height: 1.6;
}
#media screen and (min-width: 992px) {
.menu {
font-size: 16px;
}
.menu-group {
grid-template-columns: repeat(2, 1fr);
}
.menu-item-image {
width: 125px;
height: 125px;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>SuperRestraunt</title>
<meta charset="utf-8">
<link href="Style.css" rel="stylesheet">
</head>
<body>
<!-- Top navigation -->
<div class="topnav">
<!-- Centered link -->
<div class="topnav-centered">
Home
</div>
<!-- Left-aligned links (default) -->
Menu
Contact
<!-- Right-aligned links -->
<div class="topnav-right">
Search
About
</div>
</div>
<main class="wrapper">
<div class="banner">
<h1><span class="name">SuperRestraunt</span></h1>
<h2>Serving the best food in Macon since 2015.</h2>
<h3>Coupons and Weekly Advertisement.</h3>
<div class="row">
<div class="column">
<img src="images/coupon1.jpg" alt="Snow" style="width:100%">
</div>
<div class="column">
<img src="images/coupon2.jpg" alt="Forest" style="width:100%">
</div>
</div>
<br>
</div>
<div class="row">
<div class="column"></div>
<img class="img1" src="images/burger.jpg" alt="burger">
<div class="column"></div>
<p> Are you looking for the best southern cooking in all of middle Georgia? If so, you have looked in the right place!</p>
<p> Our chefs have over 30 years in combined experience</p>
<h2>About the Owner</h2>
<img class="img2" src="images/chef.jpg" alt="chef">
<p>Executive chef Nicholas St. Clair knew he wanted to do something extraordinary from a young age. Little did he know, his budding culinary expertise would launch him into a whirlwind adventure in the fine dining industry. St. Clair, who graduated with high honors from the California Culinary Institute in Pasadena, CA, polished his cuisine with some of America’s premier chefs over the past five years. St. Clair and his wife, Alison, ventured into the restaurant business with determination for success and passion for fine cuisine. e took a blind leap of faith and opened a place of his own.</p>
</div>
<h2><em>Contact us for a reservations</em></h2>
<p>Please call at least 2 days ahead for all reservations that include 10 or more people.</p>
</main>
<!-- Footer -->
<footer class="footer">
<div class="box">
<p>SuperRestraunt</p>
<p>(478) 302-1981</p>
<p>manager#superrestraunt.com</p>
<p>Contact us via Skype by clicking the following link</p>
<a href="skype:echo123?call">
Call Us Today!
</a>
<br/>
</div>
<div class="box">
<p>Check out are Social Media for more coupons and pictures!</p>
<p>Facebook:</p>
<p>Instagram:</p>
<p>Twitter:</p>
</div>
<div class="box">
<p>Locations:</p>
<br/>
<p>543 Cherry St suite b, Macon, GA 31201</p>
</div>
</footer>
<div class="copyright">
<h2>#copyright: Landon Byrd</h2>
<p>Fall 2021, All Rights Reserved</p>
</div>
<p>
<a href="http://jigsaw.w3.org/css-validator/check/referer">
<img style="border:0;width:88px;height:31px"
src="http://jigsaw.w3.org/css-validator/images/vcss"
alt="Valid CSS!" />
</a>
</p>
Back to top of page
</body>
</html>
I am also wondering how to change the hyperlink text color that is in my footer, as well as changing the back to top into a button. Thanks for the help! If needed I can post separate questions for those though.
To Change the color of hyperlink Back to top of page in footer and put it into a button.
Simply you can use this code snippet to change the font color of hyperlink and keep it into a button.
/* Footer Section */
.footer .top_a{
color : Red;
text-decoration: none;
font-size: 1.4rem;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>SuperRestraunt</title>
<meta charset="utf-8">
<link href="Style.css" rel="stylesheet">
</head>
<body>
<footer class = 'footer'>
<button class = 'top_btn'> <a href="#top" class = 'top_a'>Back to top of page</a> </button>
</footer>
</body>
</html>
If you want to make the button more nicely just add this CSS part to your CSS file.
/* Footer Section */
.footer .top_btn{
background : #1f1f1f;
border : none;
border-radius : 5px;
width : 200px;
height : 50px;
}
.footer .top_a{
color : #efefef;
text-decoration: none;
font-size:16px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>SuperRestraunt</title>
<meta charset="utf-8">
<link href="Style.css" rel="stylesheet">
</head>
<body>
<footer class = 'footer'>
<button class = 'top_btn'> <a href="#top" class = 'top_a'>Back to top of the page</a> </button>
</footer>
</body>
</html>
I am a newbie to html and css. I am trying to move the button "dropbtn" to the right side of my webpage, but it remains on the left side. I have tried using float, align, right, text-align but they all don't seem to work. I have also tried using the tag !important but that does not help either.
.mystyle{
height: 90px;
width: 254px;
color: white;
font-size: smaller;
}
.flip-container{
perspective: 1000px;
}
.flip-container:hover .flipper,
.flip-container.hover .flipper{
transform: rotateY(180deg);
}
.flip-container,
.front
.back{
height: 200px;
width: 260px;
}
.flipper{
transition: 1s;
transform-style: preserve-3d;
position: relative;
}
.front,
.back{
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front{
text-align: center;
color: black !important;
z-index: 2;
transform: rotateY(0deg);
}
.back{
transform: rotateY(180deg);
}
footer{
background: #aaa;
color: white;
}
.edit{
float: right;
padding-right: 10px;
}
nav{
height: 6cm;
background-image: url("bg.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
position: absolute;
}
/* Dropdown Button */
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #ddd;}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {display: block;}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {background-color: #3e8e41;}
<!DOCTYPE html>
<html lang="en">
<head>
<title>webpage title</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/mystyle.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="js/app.js"></script>
<script src="js/restaurants.js"></script>
</head>
<body onload="getRestaurantData()">
<!-- This is where top navigation html codes is -->
<div w3-include-html="top-navigation.html"></div>
<!-- This is the container that holds the initial message, heading, and movies -->
<div class="dropdown">
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div>
<div class="container">
<!-- The message will be shown when the page loads and will
disappear after the movies are loaded -->
<div class="row" id="parent">
Retrieving movies from database... Please wait...<br><br>
If you are seeing this message for a long time, it is likely
that you have a JavaScript error. Troubleshoot your script by
using the browser console panel now. Please use either Firefox
or Chrome to render this webpage.
</div>
<p>
<!-- This is the heading showing how many movies are there -->
<h3 id="summary"></h3>
</p>
<!-- Displays thumbnails of the movies here -->
<div id="restaurantsTable" class="row"></div>
</div>
<br><br>
<!-- Include footer here -->
<div w3-include-html="footer.html"></div>
</body>
<script src="js/w3.js"></script>
<script>
//to bring in other HTML on the fly into this page
w3.includeHTML();
</script>
</html>
Cannot move html button to the right
.mystyle{
height: 90px;
width: 254px;
color: white;
font-size: smaller;
}
.flip-container{
perspective: 1000px;
}
.flip-container:hover .flipper,
.flip-container.hover .flipper{
transform: rotateY(180deg);
}
.flip-container,
.front
.back{
height: 200px;
width: 260px;
}
.flipper{
transition: 1s;
transform-style: preserve-3d;
position: relative;
}
.front,
.back{
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front{
text-align: center;
color: black !important;
z-index: 2;
transform: rotateY(0deg);
}
.back{
transform: rotateY(180deg);
}
footer{
background: #aaa;
color: white;
}
.edit{
float: right;
padding-right: 10px;
}
nav{
height: 6cm;
background-image: url("bg.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
position: absolute;
}
/* Dropdown Button */
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
right:0px;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-menu.show {
display: block;
right: 0px !important;
left: initial !important;
transform: translate3d(0px, 56px, 0px) !important;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #ddd;}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {display: block;}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {background-color: #3e8e41;}
<!DOCTYPE html>
<html lang="en">
<head>
<title>webpage title</title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="css/mystyle.css">
</head>
<body onload="getRestaurantData()">
<!-- This is where top navigation html codes is -->
<div w3-include-html="top-navigation.html"></div>
<!-- This is the container that holds the initial message, heading, and movies -->
<div class="clearfix">
<div class="dropdown float-right">
<button class="dropbtn" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
<button class="dropdown-item" type="button">Action</button>
<button class="dropdown-item" type="button">Another action</button>
<button class="dropdown-item" type="button">Something else here</button>
</div>
</div>
</div>
<div class="container">
<!-- The message will be shown when the page loads and will
disappear after the movies are loaded -->
<div class="row" id="parent">
Retrieving movies from database... Please wait...<br><br>
If you are seeing this message for a long time, it is likely
that you have a JavaScript error. Troubleshoot your script by
using the browser console panel now. Please use either Firefox
or Chrome to render this webpage.
</div>
<p>
<!-- This is the heading showing how many movies are there -->
<h3 id="summary"></h3>
</p>
<!-- Displays thumbnails of the movies here -->
<div id="restaurantsTable" class="row"></div>
</div>
<br><br>
<!-- Include footer here -->
<div w3-include-html="footer.html"></div>
</body>
<script>
//to bring in other HTML on the fly into this page
w3.includeHTML();
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="js/app.js"></script>
<script src="js/restaurants.js"></script>
</html>
Just simply changes in your HTML and CSS
.mystyle{
height: 90px;
width: 254px;
color: white;
font-size: smaller;
}
.flip-container{
perspective: 1000px;
}
.flip-container:hover .flipper,
.flip-container.hover .flipper{
transform: rotateY(180deg);
}
.flip-container,
.front
.back{
height: 200px;
width: 260px;
}
.flipper{
transition: 1s;
transform-style: preserve-3d;
position: relative;
}
.front,
.back{
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front{
text-align: center;
color: black !important;
z-index: 2;
transform: rotateY(0deg);
}
.back{
transform: rotateY(180deg);
}
footer{
background: #aaa;
color: white;
}
.edit{
float: right;
padding-right: 10px;
}
nav{
height: 6cm;
background-image: url("bg.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
position: absolute;
}
/* Dropdown Button */
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
right:0px;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #ddd;}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {display: block;}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {background-color: #3e8e41;}
<!DOCTYPE html>
<html lang="en">
<head>
<title>webpage title</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/mystyle.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="js/app.js"></script>
<script src="js/restaurants.js"></script>
</head>
<body onload="getRestaurantData()">
<!-- This is where top navigation html codes is -->
<div w3-include-html="top-navigation.html"></div>
<!-- This is the container that holds the initial message, heading, and movies -->
<div class="clearfix">
<div class="dropdown float-right">
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div>
</div>
<div class="container">
<!-- The message will be shown when the page loads and will
disappear after the movies are loaded -->
<div class="row" id="parent">
Retrieving movies from database... Please wait...<br><br>
If you are seeing this message for a long time, it is likely
that you have a JavaScript error. Troubleshoot your script by
using the browser console panel now. Please use either Firefox
or Chrome to render this webpage.
</div>
<p>
<!-- This is the heading showing how many movies are there -->
<h3 id="summary"></h3>
</p>
<!-- Displays thumbnails of the movies here -->
<div id="restaurantsTable" class="row"></div>
</div>
<br><br>
<!-- Include footer here -->
<div w3-include-html="footer.html"></div>
</body>
<script src="js/w3.js"></script>
<script>
//to bring in other HTML on the fly into this page
w3.includeHTML();
</script>
</html>
The issue with the code you posted is that you've added display: inline-block; to the dropdown class. This means that the div marked with dropdown class will by default only take up the space required to render its children. Unlike display: inline;, however, inline-block elements will respond to setting width and height properties on the element or its class. So, if you just want to set the width: 100%; property on the class, as shown in this fiddle, you'll then be able to use text-align: right;.
Like others have suggested, you could use set the display property to flex, which gives a little more control to you when trying to position children within the containing element. There are also some compatibility issues with older browsers (mostly IE < 11). Probably not that big of a deal at this point.
But the root cause is the display: inline-block; property. If that weren't set I suspect most of your other attempts may have worked, as there are many other ways to properly position the button the way you want.
.mystyle{
height: 90px;
width: 254px;
color: white;
font-size: smaller;
}
.dropdown{
float: right !important;
}
.flip-container{
perspective: 1000px;
}
.flip-container:hover .flipper,
.flip-container.hover .flipper{
transform: rotateY(180deg);
}
.flip-container,
.front
.back{
height: 200px;
width: 260px;
}
.flipper{
transition: 1s;
transform-style: preserve-3d;
position: relative;
}
.front,
.back{
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front{
text-align: center;
color: black !important;
z-index: 2;
transform: rotateY(0deg);
}
.back{
transform: rotateY(180deg);
}
footer{
background: #aaa;
color: white;
}
.edit{
float: right;
padding-right: 10px;
}
nav{
height: 6cm;
background-image: url("bg.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
position: absolute;
}
/* Dropdown Button */
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #ddd;}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {display: block;}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {background-color: #3e8e41;}
<!DOCTYPE html>
<html lang="en">
<head>
<title>webpage title</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/mystyle.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="js/app.js"></script>
<script src="js/restaurants.js"></script>
</head>
<body onload="getRestaurantData()">
<!-- This is where top navigation html codes is -->
<div w3-include-html="top-navigation.html"></div>
<!-- This is the container that holds the initial message, heading, and movies -->
<div class="dropdown">
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div>
<div class="container">
<!-- The message will be shown when the page loads and will
disappear after the movies are loaded -->
<div class="row" id="parent">
Retrieving movies from database... Please wait...<br><br>
If you are seeing this message for a long time, it is likely
that you have a JavaScript error. Troubleshoot your script by
using the browser console panel now. Please use either Firefox
or Chrome to render this webpage.
</div>
<p>
<!-- This is the heading showing how many movies are there -->
<h3 id="summary"></h3>
</p>
<!-- Displays thumbnails of the movies here -->
<div id="restaurantsTable" class="row"></div>
</div>
<br><br>
<!-- Include footer here -->
<div w3-include-html="footer.html"></div>
</body>
<script src="js/w3.js"></script>
<script>
//to bring in other HTML on the fly into this page
w3.includeHTML();
</script>
</html>
.dropdown {
float: right;
}
Add this to you style.
Give float:right to the div that has class dropdown.
You can fix this easily while using CSS Flexbox. Avoid using things like float, this is considered a bad practice in current days of web development, because it can be solved in a better way.
Add display: flex to the parent of .dropbtn (in this case .dropdown) and add margin-left: auto to .dropbtn to move it completely to the right side of the page.
Updated styling for these two classes:
/* Dropdown Button */
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
margin-left: auto;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: flex;
}
Read more about using CSS Flexbox at MDN.
.mystyle {
height: 90px;
width: 254px;
color: white;
font-size: smaller;
}
.flip-container {
perspective: 1000px;
}
.flip-container:hover .flipper,
.flip-container.hover .flipper {
transform: rotateY(180deg);
}
.flip-container,
.front .back {
height: 200px;
width: 260px;
}
.flipper {
transition: 1s;
transform-style: preserve-3d;
position: relative;
}
.front,
.back {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front {
text-align: center;
color: black !important;
z-index: 2;
transform: rotateY(0deg);
}
.back {
transform: rotateY(180deg);
}
footer {
background: #aaa;
color: white;
}
.edit {
float: right;
padding-right: 10px;
}
nav {
height: 6cm;
background-image: url("bg.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
position: absolute;
}
/* Dropdown Button */
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
margin-left: auto;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: flex;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
right: 0;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
top: 100%;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {
background-color: #ddd;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>webpage title</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/mystyle.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="js/app.js"></script>
<script src="js/restaurants.js"></script>
</head>
<body onload="getRestaurantData()">
<!-- This is where top navigation html codes is -->
<div w3-include-html="top-navigation.html"></div>
<!-- This is the container that holds the initial message, heading, and movies -->
<div class="dropdown">
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div>
<div class="container">
<!-- The message will be shown when the page loads and will
disappear after the movies are loaded -->
<div class="row" id="parent">
Retrieving movies from database... Please wait...<br><br> If you are seeing this message for a long time, it is likely that you have a JavaScript error. Troubleshoot your script by using the browser console panel now. Please use either Firefox or
Chrome to render this webpage.
</div>
<p>
<!-- This is the heading showing how many movies are there -->
<h3 id="summary"></h3>
</p>
<!-- Displays thumbnails of the movies here -->
<div id="restaurantsTable" class="row"></div>
</div>
<br><br>
<!-- Include footer here -->
<div w3-include-html="footer.html"></div>
</body>
<script src="js/w3.js"></script>
<script>
//to bring in other HTML on the fly into this page
w3.includeHTML();
</script>
</html>
I have followed a detailed instruction from https://www.webdesignerdepot.com/2012/10/creating-a-modal-window-with-html5-and-css3/ on creating a modal.
I have done everything to plan but when I go to click the modal in the navBar arrow link, it opens stating that #openModal cannot be found.
Attached is my HTML and CSS code:
body { /* General Body Properties */
font-family: Trebuchet MS, Georgia, Helvetica, sans-serif;
margin: 0;
overflow: hidden;
}
* { /* Key element to aligning <divs> (DO NOT REMOVE) */
box-sizing: border-box;
}
#wrapper {
bottom: 0;
left: 0;
overflow: hidden;
position: absolute;
right: 0;
top: 0
}
.header { /* Header properties featuring myEd and school emblems */
padding: 30px;
text-align: center; /* Aligns links in the navBar */
background-image: url(/Default/Img/backgroundHeader-4K.jpg);
background-size: cover;
background-repeat: no-repeat;
}
.myEd-reverse {
width: 240px;
height: 70px;
float: left;
margin-left: -60px;
margin-top: -40px;
}
.navBar { /* Sticky navBar, either relative or fixed, depending on the scroll position of the site */
overflow: hidden;
background-color: #333;
position: sticky;
position: -webkit-sticky;
top: 0;
}
.navBar a { /* Style the navBar links */
float: left;
display: block;
color: #fff;
text-align: center;
padding: 6px 12px;
text-decoration: none;
}
.navBar a.right { /* Float Quick Links, Help and Log-out navBar directory items to the right of the navBar */
float: right;
}
.navBar a:hover { /* Change color on hover */
background-color: #ddd;
color: #000;
}
.navBar a.active { /* Active Link */
background-color: #666;
color: #fff;
}
.modalDialog {
position: fixed;
font-family: Arial, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
opacity:0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}
.modalDialog:target {
opacity:1;
pointer-events: auto;
}
.modalDialog > div {
width: 400px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff, #999);
background: -webkit-linear-gradient(#fff, #999);
background: -o-linear-gradient(#fff, #999);
}
.close {
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}
.close:hover { background: #00d9ff; }
.row { /* Alignment between sideBar and main */
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.sideBar { /* sideBar alignment properties */
-ms-flex: 20%;
flex: 20%;
background-color: #a7a7a7;
padding: 0px;
height: 5000px; /* As standard to work on all screen resolutions, overflow hides excess */
overflow-y: scroll; /* Allows myEd news to scroll */
overflow: hidden;
}
#newsmyEd {
width: 100%;
height: 11.4%;
min-height: 11.4%;
top: 0;
right: 0;
}
.main { /* Main Column */
-ms-flex: 80%;
flex: 80%;
background-color: #a7a7a7;
padding: 0px;
height: 5000px; /* As standard to work on all screen resolutions, overflow hides excess */
overflow-y: scroll; /* Allows embedded iFrame to scroll */
position: relative;
overflow: hidden;
}
.frameMain { /* Frame Properties */
position: absolute;
top: 0;
left: 0;
border: 0;
min-height: 11.4%;
}
.footer { /* Footer properties */
position: fixed;
bottom: 0;
left: 0;
right: 0;
background-color: #333;
}
.footer a { /* Footer navBar properties */
float: right;
display: block;
color: #fff;
text-align: center;
padding: 6px 12px;
text-decoration: none;
}
.footer a:hover { /* Change color on hover */
background-color: #ddd;
color: #000;
}
.footer a.active { /* Active Link */
background-color: #666;
color: #fff;
}
#media screen and (max-width: 700px) { /* Responsive Layout - If screen px is less than 700px, make sideBar and main stack on top of each other */
.row {
flex-direction: column;
}
}
#media screen and (max-width: 400px) { /* Responsive Layout - If screen px is less than 400px, make navBar links stack vertically on top of each other */
.navBar a {
float: none;
width: 100%;
}
}
<link rel="stylesheet" type="text/css" href="/Home/Welcome/Style/style.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz" crossorigin="anonymous">
<link rel="shortcut icon" href="/Default/Img/faviconmyEd-16x16.png">
<script>
// Required scripts for certain activities on myEd, each entry will be noted for understanding
</script>
<div id="wrapper">
<!-- Wrapper fitting website to all screen resolutions -->
<div class="header">
<!-- Header featuring 4K Background, myEd and school emblems -->
<img src="/Default/Img/myEd-reverse.png" class="myEd-reverse" alt="myEd" title="myEd Software"> <!-- myEd Software -->
</div>
<div class="navBar">
<!-- Main sticky navBar with categories listed -->
<i class="fa fa-home"></i> <!-- Home -->
<i class="fa fa-book"></i> <!-- Learning -->
<i class="fa fa-user"></i> <!-- Student Management -->
<i class="fa fa-globe"></i> <!-- Portals -->
<i class="fas fa-sign-out-alt"></i> <!-- Log-out (right to left) -->
<i class="fa fa-question-circle"></i> <!-- Help (right to left) -->
<i class="fa fa-bookmark"></i> <!-- Quick Links (right to left) -->
<i class="fas fa-caret-down"></i> <!-- Profile dropDown (right to left) -->
<div id="openModal" class="modalDialog">
<div>
X
<h2>Modal Box</h2>
<p>This is a sample modal box that can be created using the powers of CSS3.</p>
<p>You could do a lot of things here like have a pop-up ad that shows when your website loads, or create a login/register form for users.</p>
</div>
</div>
</div>
<div class="row">
<!-- Format for alignment of the sideBar and main panels -->
<div class="main">
<!-- Main learning or collaborative workspace -->
<iframe class="frameMain" width="100%" height="11.4%" scrolling="yes" src="/Home/Welcome/iFrame/index.html"></iframe> <!-- Embedded frame -->
</div>
<div class="sideBar">
<!-- sideBar featuring Profile, myEd News and directory -->
<iframe id="newsmyEd" frameborder="0" src="/Default/News/index.html"></iframe> <!-- myEd News -->
</div>
</div>
<div class="footer">
<!-- Featuring Site Navigation and myEd News navBar links -->
<i class="far fa-newspaper"></i> <!-- myEd News -->
<i class="fa fa-location-arrow"></i> <!-- Site Navigation -->
</div>
</div>
<i class="fas fa-caret-down"></i>
should be
<i class="fas fa-caret-down"></i>`
<a href="#openModal" class="right" title="Profile Overview">
<i class="fas fa-caret-down"></i>
</a>
You forgot to put '#'
I cannot center my bootstrap thumbnail images no matter what I try on tablet size and smaller. Once thumbnails reach thoses sizes they no longer scroll to stay center of screen. I have tried everything I can think of from adding center block to both my thumbnail class's and my img responsive class's HTML to text-algin center and margin auto 0. Nothing changes.
Here is my html
<div class="portfolio">
<div class="container">
<a name="porty"></a>
<h1 class="text-center" id = "port">My Work</h1>
<div class="row">
<div class="col-md-4">
<div class="thumbnail ">
<div class="caption">
<h4 class="text-center">A Berine Sanders Tribute page made with HTML,CSS, and Bootstrap</h4> <i class="fa fa-codepen fa-5x fa-fw" id="first"></i>
</div>
<img src="http://goodedevelopment.com/images/Bernie.PNG" class="img-responsive center-block" alt="tribute">
</div>
<legend>Tribute page</legend>
</div>
<div class="col-md-4">
<div class="thumbnail">
<div class="caption">
<h4 class="text-center">Google mockup page made with HTML,CSS,and Bootstrap</h4>
<i class="fa fa-codepen fa-5x fa-fw" id ="second"></i>
</div>
<img src="http://goodedevelopment.com/images/google.png" class="img-resposive center-block" alt="google">
</div>
<legend>Google homepage</legend>
</div>
<div class="col-md-4">
<div class="thumbnail">
<div class="caption">
<h4 class="text-center">A cannon game made with HTML,CSS, and Javascript</h4>
<i class="fa fa-codepen fa-5x fa-fw" id ="icon"></i>
</div>
<img src="http://goodedevelopment.com/images/cannon.png" class="img-responsive center-block" alt="cannon">
</div>
<legend>Cannon game</legend>
</div>
</div>
Here is my CSS
/*Portfolio*/
.portfolio {
background-color:#706C61;
padding-top: 50px;
padding-bottom: 100px;
display: inline-block;
width: 100%;
height: 800px;
position:relative;
}
.portfolio h1 {
font-size: 65px;
font-family: "Roboto",serif !important;
color: #0d0d0d !important;
}
.row {
padding-top: 100px;
}
.thumbnail {
height: 250px;
display: flex;
justify-content: center;
align-items: center;
position: relative;
overflow: hidden;
border: 1px solid black !important;
border-radius: 5px !important;
}
.caption img {
flex-shrink: 0;
max-width 100%;
max-height: 100%;
}
.caption {
position: absolute;
top: 0;
right: 0;
background: rgba(128, 128, 128, 0.75);
width: 100%;
height: 100%;
padding: 2%;
display: none;
text-align: center;
color: #fff !important;
z-index: 2;
font-family: "Montserrat",serif !important;
}
.caption a {
text-decoration: none;
color: white;
}
.caption h4 {
position: relative;
left: 5px;
bottom: 10px;
font-size: 25px;
}
.caption i:hover {
color: orange !important;
}
legend {
font-family: "Roboto",serif !important;
border-bottom: none !important;
color: #0d0d0d !important;
font-size:22px; !important;
height:200px;
}
#first {
position: relative !important;
bottom: -35px !important;
}
#second {
position: relative !important;
bottom: -35px !important;
}
#icon {
position: relative;
top: 30px;
}
#media screen and (min-width:767px) and (max-width:1199px) {
#first {
position: relative;
bottom: 20px;
}
#icon {
top: 50px !important;
}
.caption h4 {
font-size: 20px;
}
}
#media screen and (min-width:767px) and (max-width:991px) {
#first {
position: relative;
top: 50px;
}
.caption h4 {
font-size: 30px;
}
.caption {
font-size: 15px;
}
.caption i {
position: relative;
top: 50px;
}
#icon {
position: relative;
top: 65px !important;
}
.caption .fa {
font-size: 50px;
}
}
#media screen and (max-width: 1200px) {
.portfolio h1 {
font-size: 55px;
}
}
#media screen and (max-width: 991px){
.thumbnail {
height: 369px;
width: 440px;
position: relative;
right: -142px;
bottom: 48px;
}
.portfolio{
height: 2650px;
}
#profile li {
position: relative;
left: 60px;
}
.caption h4 {
font-size: px !important;
}
.caption .fa {
font-size: 80px !important;
}
legend {
height: 80px;
position: relative;
left: 139px;
bottom: 53px;
}
}
#media screen and (max-width: 965px) {
.portfolio {
margin-top: -150px !important;
}
}
#media screen and (max-width:767px) {
#first {
position: relative;
top: 25px;
}
.caption h4 {
font-size: 30px;
}
.caption {
font-size: 15px;
}
#port{
width: 50%;
height: 50%;
overflow: auto;
margin: auto;
position: absolute;
top: -1285px;
left: 0;
bottom: 0;
right: 0;
}
.thumbnail {
position: relative;
bottom: 0px;
}
legend
{
position: relative;
bottom: 13px;
}
}
#media screen and (max-width: 454px){
.caption h4{
font-size:25px;
}
#first{
top:15px;
}
#second{
top:15px;
}
}
#media screen and (max-width:400px) {
#icon {
position: relative;
bottom: 20px;
}
}
#media screen and (max-width:397px) {
#icon {
position: relative;
top: 0px;
}
}
#media screen and (max-width:390px) {
#first{
top:5px;
}
}
#media screen and (max-width:325px) {
.caption .fa {
font-size:60px;
}
}
#media screen and (max-width:307px) {
#first{
top:-5px;
}
}
/*End Portfolio*/
Here is the website
And finally here is a screenshot of what I am experiencing any help would be greatly appreciated thanks!
Instead of just using class="col-md-4" you should include "instructions" for Bootstrap at different screen sizes. Using multiple classes like class="col-xs-12 col-sm-6 col-md-4" would adjust the number of columns at the various screen sizes, making it easy to center the contents of each column, and just use the "img-responsive" class on the images so they will always fit in the column they are in. Then when the screen size is smaller, fewer columns will be displayed but the content of the column remains the same and stays centered in the column. If you want to center the column on the screen without filling the width of the screen (like to use col-xs-10 so it doesn't fill the width of 12 col's) then use the col-x-offset-x class to create a "blank" column to the left of where your div will display. You can use combinations of screen sizes and offsets as needed. The grid makes it really easy to get the alignment you want at different sizes without having to use CSS to define exact pixels for margins and whatnot. Once you start overwriting the CSS with "other instructions" as far as height/width go, things can get goofy...
Your fixed-navbar are with a width bigger than lower resolutions, theres alot of blank space on the right when you drop the resolution. I recommend you start developing your website following this basic bootstrap responsible template.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>Bare - Start Bootstrap Template</title>
<!-- Custom CSS -->
<link data-require="bootstrap-css#3.2.0" data-semver="3.2.0" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
<script data-require="jquery#*" data-semver="3.0.0" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"></script>
<style>
body {
padding-top: 70px;
/* Required padding for .navbar-fixed-top. Remove if using .navbar-static-top. Change if height of navigation changes. */
}
</style>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Start Bootstrap</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
About
</li>
<li>
Services
</li>
<li>
Contact
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<!-- Page Content -->
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h1>A Bootstrap Starter Template</h1>
<p class="lead">Complete with pre-defined file paths that you won't have to change!!</p>
<ul class="list-unstyled">
<li>Bootstrap v3.3.7</li>
<li>jQuery v1.11.1</li>
</ul>
</div>
</div>
<!-- /.row -->
</div>
<!-- /.container -->
</body>
</html>
Rebase your website inside the .container and link your style and keep going.. I hope it helps you to understand better the concepts of bootstrap, i cannot do the whole job for you after all you are a full stack developer.