I'm trying to make a sliding sidebar without javascript, but I have a problem with an adjacent sibling selector which is not working.
This is my code:
.sidebar {
position: fixed;
top: 100px;
right: 0px;
z-index: 0;
width: 120px;
height: 100px;
padding: 30px;
background-color: rgba(255, 255, 255, 0.00);
border-bottom: solid 1px #181918;
border-left: solid 1px #181918;
}
.sidebar ul li {
font-family: 'Zona Pro';
font-size: 18px;
margin-bottom: 16px;
-webkit-font-smoothing: antialiased;
color: rgba(24, 25, 24, 0.78);
cursor: pointer;
}
#sidebarToggler {
display: none;
}
#sidebartoggler + .sidebar {
top: 500px;
}
<div class="pageWrap">
<input type="checkbox" id="sidebarToggler" />
<div class="sidebar">
<ul>
<li>Settings</li>
<li>Log out</li>
</ul>
</div>
<div class="userNameDiv">
<label for="sidebarToggler">
Fale1994
</label>
</div>
<div class="pageContent">
#RenderBody()
</div>
</div>
Everything is working OK except the last line of CSS... I tried everything and have no more ideas.
When clicked on label, the checkbox changes checked/unchecked, and then CSS should set a sidebar attribute 'top' to 500px if checked. I also tried this with background-color, but it is also not working.
2 things you are missing:
the :checked from ckeckbox
and you have #sidebartoggler but CSS is case sensitive, so use #sidebarToggler
Snippet
.sidebar {
position: fixed;
top: 100px;
right: 0px;
z-index: 0;
width: 120px;
height: 100px;
padding: 30px;
background-color: rgba(255, 255, 255, 0.00);
border-bottom: solid 1px #181918;
border-left: solid 1px #181918;
}
.sidebar ul li {
font-family: 'Zona Pro';
font-size: 18px;
margin-bottom: 16px;
-webkit-font-smoothing: antialiased;
color: rgba(24, 25, 24, 0.78);
cursor: pointer;
}
#sidebarToggler {
display: none;
}
#sidebarToggler:checked + .sidebar {
top: 500px;
}
<div class="pageWrap">
<input type="checkbox" id="sidebarToggler" />
<div class="sidebar">
<ul>
<li>Settings</li>
<li>Log out</li>
</ul>
</div>
<div class="userNameDiv">
<label for="sidebarToggler">
Fale1994
</label>
</div>
<div class="pageContent">
#RenderBody()
</div>
</div>
#sidebartoggler:checked + .sidebar
You forgot the :checked.
Related
I am trying to group my CV into section, by using the tabs 'Profile', 'Education', 'Skills'. 'Work Experience', 'Featured Projects'.
However, with the code snippets I have found and put together (and the help of W3schools), It seems that my tab functions are not working, but just list the Education "page" below the Profile "page".
What am I not considering? This is my first attempt with HTML and CSS. If you see any clean-up potential, please point it out.
#import url(https://weloveiconfonts.com/api/?family=entypo|fontawesome);
/* entypo */
[class*="entypo-"]:before {
font-family: 'entypo', sans-serif;
}
/* fontawesome */
[class*="fontawesome-"]:before {
font-family: 'FontAwesome', sans-serif;
}
/* Utils */
.clear {
clear: both;
}
.purple {
color: #837c9a;
}
.block {
margin: 25px 30px;
}
.block h1 {
margin-left: -5px;
font-weight: 200;
}
.last.block {
margin-bottom: 110px;
}
.horizontal_list {
margin: 0;
padding: 0;
list-style-type: none;
}
.horizontal_list li {
float: left;
}
.horizontal_list li:before {
content: none;
}
.horizontal_list li {
padding-left: 0;
text-indent: 0;
}
.horizontal_line {
margin: 34px 0 0 30px;
height: 26px;
position: relative;
}
.line_left,
.line_right {
border-top: 1px solid #434247;
width: 305px;
margin-top: 13px;
}
.line_left {
float: left;
}
.line_right {
float: right;
}
.left_circle,
.central_circle,
.right_circle {
background: rgb(69, 68, 73);
background: rgba(255, 255, 255, 0.15);
position: absolute;
border-radius: 50px;
}
.left_circle,
.right_circle {
width: 13px;
height: 13px;
top: 7px;
}
.left_circle {
left: 314px;
}
.central_circle {
width: 26px;
height: 26px;
top: 0px;
left: 322px;
}
.right_circle {
left: 343px;
}
/* Main tags */
body {
background: url(https://www.toptal.com/designers/subtlepatterns/patterns/dark_wall.png) repeat;
margin: 0;
}
h1,
h2,
h3,
h4 {
font-family: 'Lato', Helvetica, sans-serif;
font-weight: 300;
color: #48DA9B;
}
h1 {
font-size: 48px;
font-weight: 300;
margin: 20px 0;
}
h2 {
font-size: 28px;
margin: 32px 0 24px;
}
h3 {
font-size: 24px;
}
h4 {
font-size: 18px;
font-weight: 400;
}
blockquote {
font-style: italic;
margin: 25px 0;
padding-left: 20px;
border-left: 2px solid #48DA9B;
}
blockquote,
p,
a,
li {
font-family: 'Lato', Helvetica, sans-serif;
font-weight: 300;
font-size: 15px;
color: #3c3b3f;
}
a:focus {
outline: none;
}
ul {
list-style: none;
padding: 0;
margin: 0;
}
li {
padding-left: 1em;
text-indent: -.7em;
}
li:before {
content: "• ";
color: #837c9a;
font-size: 20px;
padding-right: 8px;
}
/* Containers size */
#main_container {
width: 960px;
margin: 0 auto;
}
#header {
height: 130px;
border-bottom: 1px solid #403F44;
}
.header_logotype_container {
width: 260px;
height: 130px;
border-right: 1px solid #403F44;
float: left;
}
.header_menu_container {
height: 130px;
width: 699px;
float: left;
}
.header_menu_container a {
font-family: 'Lato', Helvetica, sans-serif;
}
#left_col {
width: 260px;
float: left;
}
#content_container1 {
width: 699px;
border-left: 1px solid #403F44;
float: left;
}
#content_container2 {
width: 699px;
border-left: 1px solid #403F44;
float: left;
}
#content_container3 {
width: 699px;
border-left: 1px solid #403F44;
float: left;
}
#content_container4 {
width: 699px;
border-left: 1px solid #403F44;
float: left;
}
#content_container5 {
width: 699px;
border-left: 1px solid #403F44;
float: left;
}
#footer {
width: 960px;
height: 60px;
border-top: 1px solid #403F44;
display: inline-block;
}
/* HEADER */
.logotype_name {
text-transform: uppercase;
font-size: 32px;
margin: 43px 0 0;
}
.logotype_occupation {
text-transform: uppercase;
margin-top: 5px;
color: #5ce2af;
font-size: 14px;
letter-spacing: 2px;
padding-left: 7px;
}
.download_print_buttons {
width: 225px;
height: 45px;
float: right;
}
.download_print_buttons a {
text-decoration: none;
font-size: 12px;
font-family: 'Lato', Helvetica, sans-serif;
font-style: italic;
line-height: 45px;
padding: 16px 17px;
background: #ffffff;
}
.download_print_buttons a:hover {
background: #666666;
}
.download_print_buttons .icon {
color: #02070a;
padding-right: 6px;
font-style: normal;
font-size: 18px;
}
.icon-angle-double-right {
position: relative;
top: 2px;
}
.download_print_buttons a:hover .icon {
color: #e4e3e8;
}
.header_menu {
width: 699px;
margin-top: 40px;
margin-left: 5px;
}
.header_menu a {
text-decoration: none;
padding: 0 20px;
border-left: 1px solid #e4e3e8;
font-size: 16px;
font-weight: 400;
}
.header_menu a.no_border {
border-left: none;
}
.header_menu a:hover {
color: #837c9a;
}
/* LEFT NAV */
#left_nav h2 {
margin: 0;
font-size: 24px;
}
.profile_frame {
width: 230px;
height: 260px;
background: black;
border: 1px solid #403F44;
margin-top: 30px;
}
.profile_picture {
width: 210px;
height: 240px;
margin: 10px;
background: url(//s3-us-west-2.amazonaws.com/s.cdpn.io/86033/profile/profile-512_3.jpg) 100% /210px no-repeat;
}
.hello_content,
.contact_details_content {
margin-top: 25px;
}
.hello_content {
width: 230px;
}
.contact_details_content h2+p.purple {
margin-top: 10px;
}
.contact_details_content p {
margin: 0;
}
.contact_details_content p.purple {
margin-top: 25px;
}
.send_message_button,
.special_button {
margin-top: 25px;
display: block;
background: #48DA9B;
width: 230px;
height: 50px;
position: relative;
z-index: 1;
}
.cut1:after {
content: "";
position: absolute;
bottom: -19px;
left: -20px;
width: 30px;
height: 30px;
z-index: 9;
background: url(https://www.toptal.com/designers/subtlepatterns/patterns/dark_wall.png) repeat;
transform: rotate(45deg);
}
.cut2:before {
content: "";
position: absolute;
top: -19px;
right: -20px;
width: 30px;
height: 30px;
z-index: 9;
background: url(https://www.toptal.com/designers/subtlepatterns/patterns/dark_wall.png) repeat;
transform: rotate(45deg);
}
.content {
text-align: center;
color: #04080b;
width: 100%;
height: 40px;
position: absolute;
z-index: 2;
font: 18px 'Lato', Arial, sans-serif;
margin: 0;
padding: 16px 0 0;
top: -4px;
bottom: 10px;
border-top: 1px solid #403F44;
border-bottom: 1px solid #403F44;
}
.send_message_button:hover,
.special_button:hover {
background: #29C782;
}
.get_social_content {
margin-top: 15px;
}
.get_social_content h2 {
margin-bottom: 8px;
}
.social_icons {
margin-left: -8px;
}
.social_icons a {
font-size: 35px;
text-decoration: none;
color: #000507;
padding: 0;
padding: 0 5px;
}
.social_icons a span.invisible {
display: none;
}
.social_icons .facebook:hover {
background: #3b5998;
color: #dfe3ee;
border-top-right-radius: 50px;
border-bottom-left-radius: 50px;
}
.social_icons .twitter:hover {
background: #00B0ED;
color: #fff;
border-top-left-radius: 50px;
border-bottom-right-radius: 50px;
}
.social_icons .linkedin:hover {
background: #007bb6;
color: #fff;
border-top-right-radius: 50px;
border-bottom-left-radius: 50px;
}
.footer_name {
font-style: italic;
margin-top: 20px;
}
/* Profile Content */
.profile_quote {
position: relative;
/* margin-left: 5px; */
}
.profile_quote p {
font-size: 17px;
width: 455px;
}
.profile_quote .entypo-quote {
color: #3d3a41;
font-size: 80px;
font-style: normal;
position: absolute;
top: -20px;
right: 70px;
cursor: default;
}
.philosophy_content {
margin-top: 20px;
}
.philosophy_content p {
margin: 0;
width: 370px;
float: left;
}
.philosophy_content ul {
float: left;
padding-left: 40px;
}
#import url("https://fonts.googleapis.com/css?family=Open+Sans:400,600,700");
#import url("https://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css");
section {
display: none;
padding: 20px 0 0;
border-top: 1px solid #ddd;
}
input {
display: none;
}
label {
display: inline-block;
margin: 0 0 -1px;
padding: 12px 28.5px;
font-weight: 600;
text-align: center;
color: #bbb;
border: 1px solid transparent;
}
label:before {
font-family: fontawesome;
font-weight: normal;
margin-right: 10px;
}
label:hover {
color: #888;
cursor: pointer;
}
input:checked+label {
color: #555;
border: 1px solid #ddd;
border-top: 2px solid orange;
border-bottom: 1px solid #fff;
}
#tab1:checked~#content_container1,
#tab2:checked~#content_container2,
#tab3:checked~#content_container3,
#tab4:checked~#content_container4,
#tab5:checked~#content_container5 {
display: block;
}
#media screen and (max-width: 650px) {
label {
font-size: 0;
}
label:before {
margin: 0;
font-size: 18px;
}
}
#media screen and (max-width: 400px) {
label {
padding: 15px;
}
}
<link href='https://fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic' rel='stylesheet' type='text/css'>
<!-- MAIN CONTAINER -->
<div id="main_container">
<!-- HEADER -->
<div id="header">
<!-- LOGOTYPE/NAME -->
<div class="header_logotype_container">
<h1 class="logotype_name">Firstname <span class="purple">Lachname</span></h1>
<h2 class="logotype_occupation">Occupation</h2>
</div>
<!-- MAIN MENU -->
<main>
<div class="header_menu_container">
<ul class="download_print_buttons horizontal_list">
<li><span class="icon entypo-download"></span>Download CV</li>
<li><span class="icon entypo-print"></span>Print CV</li>
</ul>
<div class="clear tab"></div>
<ul class="header_menu horizontal_list">
<li><input id="tab1" type="radio" name="tabs" checked>
<label for="tab1">Profile</label></li>
<li><input id="tab2" type="radio" name="tabs">
<label for="tab2">Education</label></li>
<li><input id="tab3" type="radio" name="tabs">
<label for="tab3">Skills</label></li>
<li><input id="tab4" type="radio" name="tabs">
<label for="tab4">Work Experience</label></li>
<li><input id="tab5" type="radio" name="tabs">
<label for="tab5">Featured Projects</label></li>
</ul>
</div>
</div>
<!-- LEFT COL -->
<div id="left_col">
<div class="profile_frame">
<div class="profile_picture"></div>
<!-- <img src="images/javier_latorre.jpg" alt="profile picture"> -->
</div>
<div class="hello_content">
<h2>Hello!</h2>
<p>I'm passionate about technology and human behavior, hardworker and a fast-learner with experience in around 5 different countries studying, working and volunteering. I believe that the right digital innovation is key to our society's wellbeing.
This motivates me to not only consume the latest technology but to be an active driver of change and development.</p>
</div>
<div class="contact_details_content">
<h2>Contact details</h2>
<p class="purple">Phone:</p>
<p>any numbers</p>
<p class="purple">Email:</p>
<p>first.last#xyz.com</p>
<p class="purple">Adress:</p>
<p>Street Nr.</p>
<p>Zip Location</p>
<p>Country</p>
</div>
<a href="first.last#xyz.com" class="send_message_button">
<span class="cut1"></span>
<span class="cut2"></span>
<span class="content">Send me a message <span class="fontawesome-double-angle-right"></span></span>
</a>
<div class="get_social_content">
<h2>Get social</h2>
<ul class="social_icons horizontal_list">
<li><a class="linkedin" href="https://www.linkedin.com/in/xyz/"><span class="entypo-linkedin-circled"></span><span class="invisible">LinkedIn</span></a></li>
</ul>
</div>
</div>
<!-- PROFILE CONTENT -->
<div id="content_container1">
<div class="block">
<h1>Profile</h1>
<blockquote class="profile_quote">
<p>"There is no end to education. It is not that you read a book, pass an examination, and finish with education. The whole of life, from the moment you are born to the moment you die, is a process of learning."</p>
<p>Jiddu Krishnamurti.</p>
<span class="entypo-quote"></span>
</blockquote>
</div>
<div class="block">
<h2>A few words about me</h2>
<p>Until now, in my life, I change from active moments with a lot of variety, challenges and improvisations, to moments of tranquility and stability, being difficult to stay in a place during a long time. I consider myself a tolerant and respectful
person with open mind and quite honest. I really like to listen people stories and backgrounds and their different experiences around the world.</p>
</div>
<div class="horizontal_line">
<div class="line_left"></div>
<div class="left_circle"></div>
<div class="central_circle"></div>
<div class="right_circle"></div>
<div class="line_right"></div>
</div>
<div class="block">
<h2>Philosophy</h2>
<p>I belive in ethic and moral not in imposed rules that you "have to" do or follow.</p>
<div class="philosophy_content">
<p>I believe life is made from different shades of grey, not from black and white. Furthermore, as a human being with rationality, I think it is our duty to take care of the world and treat others as one would like others to treat oneself. This way
of perceiving reality affects my beliefs and my way of behaving. Summarizing on several points:</p>
<ul>
<li>Pragmatic</li>
<li>Honest</li>
<li>Respectful</li>
<li>Open-minded</li>
<li>Coherent</li>
</ul>
<div class="clear"></div>
</div>
</div>
<div class="horizontal_line">
<div class="line_left"></div>
<div class="left_circle"></div>
<div class="central_circle"></div>
<div class="right_circle"></div>
<div class="line_right"></div>
</div>
<div class="last block">
<h2>Work Motivation</h2>
<p>I'm passionate about technology and human behavior, yet, these are only a few of my interests. others include:</p>
<ul>
<li>Visiting new places</li>
<li>Meeting people</li>
<li>Hiking and Biking</li>
<li>Bouldering</li>
<li>Cooking</li>
<li>Reading</li>
</ul>
</div>
</div>
<div class="clear"></div>
<!-- Education CONTENT -->
<div id="content_container2">
<div class="block">
<h1>Education Timeline</h1>
<blockquote class="profile_quote">
<p>"There is no end to education. It is not that you read a book, pass an examination, and finish with education. The whole of life, from the moment you are born to the moment you die, is a process of learning."</p>
<p>Jiddu Krishnamurti.</p>
<span class="entypo-quote"></span>
</blockquote>
</div>
<div class="block">
<h2>A few words about me</h2>
<p>Until now, in my life, I change from active moments with a lot of variety, challenges and improvisations, to moments of tranquility and stability, being difficult to stay in a place during a long time. I consider myself a tolerant and respectful
person with open mind and quite honest. I really like to listen people stories and backgrounds and their different experiences around the world.</p>
</div>
<div class="horizontal_line">
<div class="line_left"></div>
<div class="left_circle"></div>
<div class="central_circle"></div>
<div class="right_circle"></div>
<div class="line_right"></div>
</div>
<div class="block">
<h2>Philosophy</h2>
<p>I belive in ethic and moral not in imposed rules that you "have to" do or follow.</p>
<div class="philosophy_content">
<p>I believe life is made from different shades of grey, not from black and white. Furthermore, as a human being with rationality, I think it is our duty to take care of the world and treat others as one would like others to treat oneself. This way
of perceiving reality affects my beliefs and my way of behaving. Summarizing on several points:</p>
<ul>
<li>Pragmatic</li>
<li>Honest</li>
<li>Respectful</li>
<li>Open-minded</li>
<li>Coherent</li>
</ul>
<div class="clear"></div>
</div>
</div>
<div class="horizontal_line">
<div class="line_left"></div>
<div class="left_circle"></div>
<div class="central_circle"></div>
<div class="right_circle"></div>
<div class="line_right"></div>
</div>
<div class="last block">
<h2>Work Motivation</h2>
<p>I'm passionate about technology and human behavior, yet, these are only a few of my interests. others include:</p>
<ul>
<li>Visiting new places</li>
<li>Meeting people</li>
<li>Hiking and Biking</li>
<li>Bouldering</li>
<li>Cooking</li>
<li>Reading</li>
</ul>
</div>
</div>
<div class="clear"></div>
</main>
<!-- FOOTER -->
<div id="footer">
<p class="footer_name">Fist Last CV 2022</p>
</div>
</div>
Add this simple js function to switch the tabs. Also add one class (here tabcontainer) in different tab containers. Add style display:none to next tabs initially, the style will be changed to display:block by js
function openTab(tab) {
var i;
var x = document.getElementsByClassName("tabcontainer");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
document.getElementById(tab).style.display = "block";
}
<ul class="header_menu horizontal_list">
<li>
<input id="tab1" type="radio" name="tabs" checked onclick="openTab('content_container1')">
<label for="tab1">Profile</label>
</li>
<li>
<input id="tab2" type="radio" name="tabs" onclick="openTab('content_container2')">
<label for="tab2">Education</label></li>
<li>
<input id="tab3" type="radio" name="tabs" onclick="openTab('content_container3')">
<label for="tab3">Skills</label>
</li>
<li>
<input id="tab4" type="radio" name="tabs" onclick="openTab('content_container4')">
<label for="tab4">Work Experience</label>
</li>
<li>
<input id="tab5" type="radio" name="tabs" onclick="openTab('content_container5')">
<label for="tab5">Featured Projects</label>
</li>
</ul>
<div id="content_container1" class="tabcontainer">
<div class="block">
<h1>Profile</h1>
<blockquote class="profile_quote">
<p>"Tab 1: About Profile"</p>
<p>Jiddu Krishnamurti.</p>
<span class="entypo-quote"></span>
</blockquote>
</div>
</div>
<div class="clear"></div>
<!-- Education CONTENT -->
<div id="content_container2" class="tabcontainer" style="display:none">
<div class="block">
<h1>Education Timeline</h1>
<blockquote class="profile_quote">
<p>"Tab 3: About Education Timeline."</p>
<p>Test Author2</p>
<span class="entypo-quote"></span>
</blockquote>
</div>
</div>
<div id="content_container3" class="tabcontainer" style="display:none">
<div class="block">
<h1>Skills</h1>
<blockquote class="profile_quote">
<p>"Tab 3: About Skills."</p>
<p>Test Author3</p>
<span class="entypo-quote"></span>
</blockquote>
</div>
</div>
<div class="clear"></div>
I am having an issue with resizing and a div. When I resize the browser, then scroll over to the right, I see that the bottom div is not extending all the way despite my width at 100% I have tried position and width tags and am at a loss. Any ideas? The form is moving into the white space and not sticking to the background div area.
https://codepen.io/CaptainMattyP/pen/mdJRKpo
body {
width: 100%;
margin: 0px;
background-image: url("https://wallpaperplay.com/walls/full/d/8/b/329997.jpg");
background-attachment: fixed;
font-family: 'Ubuntu Condensed';
right: 0px;
}
h1 {
text-align: center;
padding: 200px 0px 0px 1320px;
position: absolute;
white-space: nowrap;
}
#navbar {
height: 50px;
width: 100%;
background-image: url("https://www.setaswall.com/wp-content/uploads/2018/02/Grey-Abstract-Wallpaper-16-1920x1080.jpg");
background-color: rgb(80, 80, 86);
border-bottom: solid;
border-width: 1px;
border-color: black;
position: fixed;
top: 0px;
z-index: 5
}
a,
.white {
text-decoration: none;
color: white;
}
a:hover {
color: limegreen;
}
ul {
padding: 0px 0px 0px 1160px;
white-space: nowrap;
}
li {
color: white;
display: inline;
padding: 40px;
}
#welcome-section {
height: 800px;
}
.picture {
margin: 300px 0px 0px 1340px;
border-radius: 50%;
position: absolute;
z-index: 1;
box-shadow: 10px 10px 10px grey;
border-style: solid;
border-width: 1px;
}
#footer {
height: 230px;
background-image: url("https://www.setaswall.com/wp-content/uploads/2018/02/Grey-Abstract-Wallpaper-16-1920x1080.jpg");
background-size: auto;
border-top: solid;
bottom: 0px;
right: 0px;
border-width: 1px;
}
#footer-info1 {
color: white;
padding: 80px 0px 0px 150px;
positon: absolute;
}
#copyright {
color: white;
padding: 0px 0px 0px 900px;
positon: absolute;
}
#contact-info {
padding: 20px 10vw 0px 1600px;
position: absolute;
}
.block {
display: block;
}
#media (max-height: 100%) {
#welcome-section {
height: 800px;
}
}
<link href="https://fonts.googleapis.com/css?family=Ubuntu+Condensed&display=swap" rel="stylesheet">
<main>
<nav id="navbar">
<ul>
<li>About</li>
<li>Skills</li>
<li>Projects</li>
<li>Contact</li>
<li>FCC Profile</li>
</ul>
</nav>
<h1>Hi, I'm Matt. <br>Future Front-End Developer.</h1>
<div id="welcome-section">
<img class="picture" src="https://i.ibb.co/71rD5ND/picture.png">
</div>
<section id="footer">
<form style="display: block" id="contact-info">
<label for="email" class="white">E-mail Address:
<input id="email" type="email" name="emailaddress" class="block">
</label>
<label for="inquiry" class="white">Comments or Inquiries:
<textarea rows="8" cols="25" style="resize: none" class="block">
</textarea>
</label>
<button type="submit">Submit</button>
</form>
<div id="footer-info1">
Matthew Paciello <br><br> 561-305-5761
<br> Boca Raton, FL<br> mpaciell#gmail.com
</div>
<div id="copyright">
#Matthew Paciello
</div>
</section>
</main>
I'm going to take a guess here that you have a very wide monitor that you are doing most of your work on. You have hard coded almost all of the padding and margins used in your code to place the different items on the page. This is the root of your problem. When you put something to width: 100% what is actually occurring is you are telling the browser to give a width of 100% of the current screen size. This means it will be subjective to the size of the browser that is displaying the page. The rest of your padding and margins though are set to a hard pixel value. Combine these two different display styles together and you can have a page that displays different portions off of the initial screen.
I think you might want something closer to this. I do still use hard coded padding values, but they are padding based on dynamic values instead of absolute values so it allows for easier reflowing and resizing of the page so it looks better for more screen sizes.
body {
width: 100%;
margin: 0px;
background-image: url("https://wallpaperplay.com/walls/full/d/8/b/329997.jpg");
background-attachment: fixed;
font-family: 'Ubuntu Condensed';
right: 0px;
}
h1 {
text-align: center;
white-space: nowrap;
}
#navbar {
height: 50px;
width: 100%;
background-image: url("https://www.setaswall.com/wp-content/uploads/2018/02/Grey-Abstract-Wallpaper-16-1920x1080.jpg");
background-color: rgb(80, 80, 86);
border-bottom: solid;
border-width: 1px;
border-color: black;
top: 0px;
z-index: 5
}
a,
.white {
text-decoration: none;
color: white;
}
a:hover {
color: limegreen;
}
ul {
white-space: nowrap;
text-align: right;
padding-right: 10px;
padding-top: 10px;
margin: 0px;
}
li {
color: white;
display: inline;
padding-left: 10px;
}
#welcome-section {
padding-bottom: 40px;
text-align: center;
}
.picture {
border-radius: 50%;
z-index: 1;
box-shadow: 10px 10px 10px grey;
border-style: solid;
border-width: 1px;
}
#footer {
background-image: url("https://www.setaswall.com/wp-content/uploads/2018/02/Grey-Abstract-Wallpaper-16-1920x1080.jpg");
background-size: auto;
border-top: solid;
bottom: 0px;
right: 0px;
border-width: 1px;
overflow: auto;
}
#footer-info1 {
color: white;
text-align: right;
padding-right: 10px;
float: right;
}
#email-section {
float: left;
padding-bottom: 10px;
padding-left: 10px;
}
.block {
display: block;
}
<link href="https://fonts.googleapis.com/css?family=Ubuntu+Condensed&display=swap" rel="stylesheet">
<main>
<nav id="navbar">
<ul>
<li>About</li>
<li>Skills</li>
<li>Projects</li>
<li>Contact</li>
<li>FCC Profile</li>
</ul>
</nav>
<h1>Hi, I'm Matt. <br>Future Front-End Developer.</h1>
<div id="welcome-section">
<img class="picture" src="https://i.ibb.co/71rD5ND/picture.png">
</div>
<section id="footer">
<div id="email-section">
<form style="display: block" id="contact-info">
<label for="email" class="white">E-mail Address:
<input id="email" type="email" name="emailaddress" class="block">
</label>
<label for="inquiry" class="white">Comments or Inquiries:
<textarea rows="8" cols="25" style="resize: none" class="block">
</textarea>
</label>
<button type="submit">Submit</button>
</form>
</div>
<div id="footer-info1">
Matthew Paciello <br><br> 561-305-5761
<br> Boca Raton, FL<br> mpaciell#gmail.com
<div id="copyright">
#Matthew Paciello
</div>
</div>
</section>
</main>
If I'm reading this right, I suggest adjusting the bottom area and use a flex like so:
body {
width: 100%;
margin: 0px;
background-image: url("https://wallpaperplay.com/walls/full/d/8/b/329997.jpg");
background-attachment: fixed;
font-family: 'Ubuntu Condensed';
right: 0px;
}
h1 {
text-align: center;
padding: 200px 0px 0px 1320px;
position: absolute;
white-space: nowrap;
}
#navbar {
height: 50px;
width: 100%;
background-image: url("https://www.setaswall.com/wp-content/uploads/2018/02/Grey-Abstract-Wallpaper-16-1920x1080.jpg");
background-color: rgb(80, 80, 86);
border-bottom: solid;
border-width: 1px;
border-color: black;
position: fixed;
top: 0px;
z-index: 5
}
a,
.white {
text-decoration: none;
color: white;
}
a:hover {
color: limegreen;
}
ul {
padding: 0px 0px 0px 1160px;
white-space: nowrap;
}
li {
color: white;
display: inline;
padding: 40px;
}
#welcome-section {
height: 800px;
}
.picture {
margin: 300px 0px 0px 1340px;
border-radius: 50%;
position: absolute;
z-index: 1;
box-shadow: 10px 10px 10px grey;
border-style: solid;
border-width: 1px;
}
#footer {
height: 230px;
background-image: url("https://www.setaswall.com/wp-content/uploads/2018/02/Grey-Abstract-Wallpaper-16-1920x1080.jpg");
background-size: auto;
border-top: solid;
bottom: 0px;
right: 0px;
border-width: 1px;
display:flex;
flex-direction:row;
justify-content: space-between;
align-items: center;
}
#footer-info1 {
color: white;
}
#copyright {
color: white;
}
#contact-info {
}
.block {
display: block;
}
#media (max-height: 100%) {
#welcome-section {
height: 800px;
}
}
<link href="https://fonts.googleapis.com/css?family=Ubuntu+Condensed&display=swap" rel="stylesheet">
<main>
<nav id="navbar">
<ul>
<li>About</li>
<li>Skills</li>
<li>Projects</li>
<li>Contact</li>
<li>FCC Profile</li>
</ul>
</nav>
<h1>Hi, I'm Matt. <br>Future Front-End Developer.</h1>
<div id="welcome-section">
<img class="picture" src="https://i.ibb.co/71rD5ND/picture.png">
</div>
<section id="footer">
<div id="footer-info1">
Matthew Paciello <br><br> 561-305-5761
<br> Boca Raton, FL<br> mpaciell#gmail.com
</div>
<div id="copyright">
#Matthew Paciello
</div>
<form style="display: block" id="contact-info">
<label for="email" class="white">E-mail Address:
<input id="email" type="email" name="emailaddress" class="block">
</label>
<label for="inquiry" class="white">Comments or Inquiries:
<textarea rows="8" cols="25" style="resize: none" class="block">
</textarea>
</label>
<button type="submit">Submit</button>
</form>
</section>
</main>
Your footer is 100% but:
The form in your footer have a 10vw padding-right which make the page horizontally scrollabe. And that white space on your right. either bring the form more to the left by reducing the padding-left or padding-right.
The position of the image is set by margin-top and margin-left which also plays a roll in making the page horizontally off, and scrollable. You can bring the image closer to the left by reducing margin-left of it. Or use other methods to center the image, if necessary.
Can someone help me, I'm at my wits end. I've created a CSS3 tabbed nav set up. When the tab is clicked it should be showing the base content -- at this point it's only one line. I'm missing something and I just can't see it. I'm not looking to implement JS or Jquery this should work but it's not.
Here's the code:
.tabs
{
position: relative;
display: block;
height: 40px;
width: 600px;
margin: 75px auto;
list-style: none;
float: none;
}
.tabs input[type="radio"]
{
display: none;
}
.tabs label
{
float: left;
display: block;
position: relative;
height: 40px;
width: 160px;
display:block;
padding: 10px 20px;
font-weight: normal;
font-family: 'Lucida Sans';
font-size: 17px;
background: #f2f2f2;
line-height: 20px;
text-align: center;
cursor: pointer;
color: #bfbfbf;
box-shadow: 0.5px -2px 2px rgba(0,0,0,0.1), 0.5px -1px 2px rgba(0,0,0,0.1);
transition: all 0.1s ease-in-out;
top: 2px;
}
.tabs label:hover
{
background: rgba(255,255,255,0.5);
top:0;
}
.tab-content
{
position: absolute;
top: 100px;
left: 0;
display: none;
}
[id^=tab]:checked+label
{
background: rgba(255,255,255,0.5);
top:0;
}
[id^=tab]:checked~[id^=tab-content]
{
display: block;
}
<ul class="tabs">
<li>
<input type="radio" name="tab" id="tab1" checked />
<label for="tab1">Personal Information</label>
<div class="tab-content" id="tab1-content">Here is the content for tab 1</div>
</li>
<li>
<input type="radio" name="tab" id="tab2" />
<label for="tab2">Academic Information</label>
<div class="tab-content" id="tab2-content">Here is the content for tab 2</div>
</li>
<li>
<input type="radio" name="tab" id="tab3" />
<label for="tab3">OECTA Involvement</label>
<div class="tab-content" id="tab3-content">Here is the content for tab 3</div>
</li>
</ul>
It's only your last css selector
[id^=tab]:checked~.tab-content{
display: block;
}
[id^=tab-content] selects all elements with an attribute ID starting with tab-content which is not what you want.
I have a tabbed content that has 4 tabs and in each there are going to be two divs that make up the border design. The problem that I'm running into is that I have no idea how to animate the divs to change height when the tab they're located in is selected. I have a fiddle for reference and the markup is below.
HTML
<div class="container">
<ul class="tabs">
<li class="tab-link current" data-tab="tab-1" id="welcome_selector">Welcome</li>
<li class="tab-link" data-tab="tab-2">Tab Two</li>
<li class="tab-link" data-tab="tab-3">Tab Three</li>
<li class="tab-link" data-tab="tab-4">Tab Four</li>
</ul>
<div class="tabcontentcontainer">
<div id="tab-1" class="tab-content current"> <div class="bordertop_animate"> </div>welcome tab will be empty, save for the borders <div class="borderbottom_animate"></div></div>
<div id="tab-2" class="tab-content"><div class="bordertop_animate"></div> tab 2 content<div class="borderbottom_animate"></div> </div>
<div id="tab-3" class="tab-content"><div class="bordertop_animate"></div> tab 3 content<div class="borderbottom_animate"></div> </div>
<div id="tab-4" class="tab-content"><div class="bordertop_animate"></div> tab 4 content<div class="borderbottom_animate"></div>
</div>
</div>
</div>
CSS
.container {
width: 1000px;
min-height: 400px;
margin: 0 auto;
}
ul.tabs {
margin: 0px;
padding: 0px;
list-style: none;
background: #000;
vertical-align: middle;
font-weight: 400;
color:#FFF;
text-align: right;
text-transform: uppercase;
font-size: 8px;
letter-spacing: 0.6px;
}
ul.tabs li {
background: #000;
vertical-align: middle;
font-weight: 400;
color:#FFF;
text-align: right;
text-transform: uppercase;
font-size: 8px;
letter-spacing: 0.6px;
display: inline-block;
padding: 55px 15px 55px 15px;
cursor: pointer;
}
ul.tabs li.current {
background: #000;
color: #FFF;
}
#welcome_selector {
float: left;
padding-left: 128px;
}
.tabcontentcontainer {
height: 400px;
width: 1000px;
background: url(http://placehold.it/1000x400) #000;
position: relative;
}
.tab-content {
display: none;
background: rgba(0, 0, 0, 0.0);
padding: 15px;
}
.tab-content.current {
display: inherit;
}
.bordertop_animate {
position: absolute;
height: 38px;
width: 966px;
border-top: 2px solid #FFF;
border-right: 2px solid #FFF;
border-bottom: 0px solid #FFF;
border-left: 2px solid #FFF;
}
.borderbottom_animate {
position: absolute;
bottom: 15px;
height: 38px;
width: 966px;
border-top: 0px solid #FFF;
border-right: 2px solid #FFF;
border-bottom: 2px solid #FFF;
border-left: 2px solid #FFF;
}
JS
$(document).ready(function(){
$('ul.tabs li').click(function(){
var tab_id = $(this).attr('data-tab');
$('ul.tabs li').removeClass('current');
$('.tab-content').removeClass('current');
$(this).addClass('current');
$("#"+tab_id).addClass('current');
})
})
I'd like for the first tab to keep current divs height which is 38px, however I'd like the other 3 tabs to have theirs at a height of 185px- but for the height to grow from 38px to 185px when the tab is selected. The animation would be similar to if the divs had a :hover css selector applied with a 0.5s transition, except it would happen when the tab is selected, not on mouseover.
Sorry if this isn't detailed or specific enough, this is my first time posting a question/and dealing with jquery.
Here is a jquery solution to your problem, just in case you need it.
JS fiddle: http://jsfiddle.net/nPAhw/
html
<ul>
<li id="tab1">Tab One</li>
<li id="tab2">Tab Two</li>
</ul>
<div id="tabone">Tab one</div>
<div id="tabtwo">Tab Two</div>
css
#tabone{
width:200px;
height:38px;
border:solid blue;
margin:10px;
}
#tabtwo{
width:200px;
height:38px;
border:solid black;
margin:10px;
}
#tab1:hover{
cursor:pointer;
}
#tab2:hover{
cursor:pointer;
}
jquery / javascript
$('#tab1').click(function(){
var h = $('#tabone').height();
if(h < 185){
$('#tabone').animate({height:'185px'});
$('#tabtwo').animate({height:'38px'});
}
else $('#tabone').animate({height:'38px'});
});
$('#tab2').click(function(){
var h = $('#tabtwo').height();
if(h < 185){
$('#tabtwo').animate({height:'185px'});
$('#tabone').animate({height:'38px'});
}
else $('#tabtwo').animate({height:'38px'});
});
You would want to use the Jquery Animate method.
This method can perform animation effects on any numeric CSS property, like for example, height, which is what you want to achieve.
$( ".element-class" ).animate({
height: "185px"
}, 500);
For each tab the user clicks, I need to display different content. I must insist that the layout be kept the same. My CSS is as follows:
#header ul {
list-style: none;
padding:0;
margin:0;
}
#header li {
float: left;
border: 1px solid;
border-bottom-width: 0;
margin: 0 0.5em 0 0;
}
#header li a {
padding: 0 1em;
}
#content {
border: 1px solid;
clear: both;
}
h1 {
margin: 0;
padding: 0 0 1em 0;
}
#header #selected {
position: relative;
top: 1px;
background: white;
}
And my HTML file is as follows:
<head>
<link rel="stylesheet" href="style/style-style.css">
</head>
<div id="header">
<h1><center>Tabs</center></h1>
<ul>
<li>This</li>
<li id="selected">That</li>
<li>The Other</li>
<li>Banana</li>
</ul>
</div>
<div id="content">
<p>Ispum schmipsum.</p>
</div>
Again, my question is how to display unique content based on which tab (This, That, The Other, Banana) that the user may click.
Do something Like this
your html code
<ul class="tabs">
<li>
<input type="radio" checked name="tabs" id="tab1">
<label for="tab1">tab 1</label>
<div id="tab-content1" class="tab-content animated fadeIn">
...
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab2">
<label for="tab2">tab 2</label>
<div id="tab-content2" class="tab-content animated fadeIn">
...
</div>
</li>
<li>
<input type="radio" name="tabs" id="tab3">
<label for="tab3">tab 3</label>
<div id="tab-content3" class="tab-content animated fadeIn">
...
</div>
</li>
</ul>
your css
body, html {
height: 100%;
margin: 0;
-webkit-font-smoothing: antialiased;
font-weight: 100;
background: #aadfeb;
text-align: center;
font-family: helvetica;
}
.tabs input[type=radio] {
position: absolute;
top: -9999px;
left: -9999px;
}
.tabs {
width: 650px;
float: none;
list-style: none;
position: relative;
padding: 0;
margin: 75px auto;
}
.tabs li{
float: left;
}
.tabs label {
display: block;
padding: 10px 20px;
border-radius: 2px 2px 0 0;
color: #08C;
font-size: 24px;
font-weight: normal;
font-family: 'Lily Script One', helveti;
background: rgba(255,255,255,0.2);
cursor: pointer;
position: relative;
top: 3px;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
.tabs label:hover {
background: rgba(255,255,255,0.5);
top: 0;
}
[id^=tab]:checked + label {
background: #08C;
color: white;
top: 0;
}
[id^=tab]:checked ~ [id^=tab-content] {
display: block;
}
.tab-content{
z-index: 2;
display: none;
text-align: left;
width: 100%;
font-size: 20px;
line-height: 140%;
padding-top: 10px;
background: #08C;
padding: 15px;
color: white;
position: absolute;
top: 53px;
left: 0;
box-sizing: border-box;
-webkit-animation-duration: 0.5s;
-o-animation-duration: 0.5s;
-moz-animation-duration: 0.5s;
animation-duration: 0.5s;
}
you can try writing following code:
HTML :
<div id="header">
<h1><center>Tabs</center></h1>
<ul>
<li>This</li>
<li class="selected">That</li>
<li>The Other</li>
<li>Banana</li>
</ul>
</div>
<div id="content1" class="content">
<p>Ispum schmipsum.11</p>
</div>
<div id="content2" class="content" style="display:none">
<p>Ispum schmipsum.22</p>
</div>
<div id="content3" class="content" style="display:none">
<p>Ispum schmipsum.33</p>
</div>
<div id="content4" class="content" style="display:none">
<p>Ispum schmipsum.44</p>
</div>
CSS :
#header ul {
list-style: none;
padding:0;
margin:0;
}
#header li {
float: left;
border: 1px solid;
border-bottom-width: 0;
margin: 0 0.5em 0 0;
}
#header li a {
padding: 0 1em;
}
.content {
border: 1px solid;
clear: both;
}
h1 {
margin: 0;
padding: 0 0 1em 0;
}
#header .selected {
position: relative;
top: 1px;
background: white;
}
jQuery :
$("#tab1").click(function (){
$(".content").hide();
$("li").removeClass("selected");
$("#content1").show();
$(this).parent().addClass("selected");
});
$("#tab2").click(function (){
$(".content").hide();
$("li").removeClass("selected");
$("#content2").show();
$(this).parent().addClass("selected");
});
$("#tab3").click(function (){
$(".content").hide();
$("li").removeClass("selected");
$("#content3").show();
$(this).parent().addClass("selected");
});
$("#tab4").click(function (){
$(".content").hide();
$("li").removeClass("selected");
$("#content4").show();
$(this).parent().addClass("selected");
});
Refer Demo here :: http://jsfiddle.net/7d7gM/
Please see the Fiddle here
$(document).ready(
function() {
$("ul#tabs > li").on("click", function() {
$("ul#tabs > li").removeAttr("id");
$(this).attr("id", "selected");
if ($(this).find("a").text() == "This")
{
$("div#content > p").text("This content");
}
else if ($(this).find("a").text() == "That")
{
$("div#content > p").text("That content");
}
else if ($(this).find("a").text() == "The Other")
{
$("div#content > p").text("The Other content");
}
else if ($(this).find("a").text() == "Banana")
{
$("div#content > p").text("Banana content");
}
});
//Trigger click on first tab to initiate
$("ul#tabs > li:first-child").trigger("click");
}
);