HTML/CSS Tabs Display Unique Content - html

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");
}
);

Related

My Html tab switch is not working, what am i doing wrong?

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>

Pure HTML and CSS hamburger menu does not work

I'm making a hamburger menu right now with html and css (no js), and the :checked + .something does not work. I'm searching for solutions for about 3 hours but i can't find any. If you would help me that would be nice.
Maybe I messed up somewhere because i watched it from a video, but i did the exact same thing like him but i doesn't work :(
Here is the code:
* {
margin: 0;
padding: 0;
}
body {
background-color: teal;
}
.navigations {
right: 0;
z-index: 10;
display: block;
position: fixed;
top: 15px;
padding-bottom: 20px;
padding-left: 25px;
padding-right: 150px;
border-radius: 50px 10px 10px 50px;
background: rgba(0, 0, 0, 0.5);
}
.navigations div {
display: inline-block;
font-size: 25px;
}
.navigations a {
text-decoration: none;
color: white;
}
.burger {
z-index: 100;
position: fixed;
right: 25px;
display: block;
top: 25px;
cursor: pointer;
}
.burger div {
width: 45px;
height: 5px;
background-color: white;
margin: 12px;
border-radius: 10px;
}
#toggle {
display: none;
position: fixed;
}
#toggle:checked+.navigations {
display: none;
}
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale = 1.0">
<link rel="stylesheet" type="text/css" href="something.css">
</head>
<body>
<div class="navigations">
<div class="nav">
About us
</div>
<div class="nav">
Tours
</div>
<div class="nav">
Contacts
</div>
</div>
<label for="toggle">
<div class="burger">
<div class="burgerelem"></div>
<div class="burgerelem"></div>
<div class="burgerelem"></div>
</div>
</label>
</body>
</html>
It seems like you're actually missing the checkbox element. Since you're using the adjacent sibling selector, (+ in #toggle:checked + .navigations) you should put the checkbox with the .navigations div immediately before the #toggle input.
* {
margin: 0;
padding: 0;
}
body {
background-color: teal;
}
.navigations {
right: 0;
z-index: 10;
display: block;
position: fixed;
top: 15px;
padding-bottom: 20px;
padding-left: 25px;
padding-right: 150px;
border-radius: 50px 10px 10px 50px;
background: rgba(0, 0, 0, 0.5);
}
.navigations div {
display: inline-block;
font-size: 25px;
}
.navigations a {
text-decoration: none;
color: white;
}
.burger {
z-index: 100;
position: fixed;
right: 25px;
display: block;
top: 25px;
cursor: pointer;
}
.burger div {
width: 45px;
height: 5px;
background-color: white;
margin: 12px;
border-radius: 10px;
}
#toggle {
display: none;
position: fixed;
}
/*
Since the .navigations is the next sibling element after #toggle,
the + selector works here
*/
#toggle:checked+.navigations {
display: none;
}
<input type="checkbox" id="toggle" /> <!-- Add this! -->
<div class="navigations">
<div class="nav">
About us
</div>
<div class="nav">
Tours
</div>
<div class="nav">
Contacts
</div>
</div>
<label for="toggle">
<div class="burger">
<div class="burgerelem"></div>
<div class="burgerelem"></div>
<div class="burgerelem"></div>
</div>
</label>

Tabbed Nav Not showing Content

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.

Adjacent sibling selector not working

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.

How can I insert the skill name inside the progress bar?

I am working on my resume and I want the skill name inside the progress bar, and not above. But I dont get it. Thx
this is the web: http://working.virgiliodelavega.com/
<span class="skills-each">Illustrator</span>
<div class="progress-bar blue">
<span style="width: 90%"></span>
</div>
.skills-title {
font-size: 1em;
}
.skills-each {
font-size: .8em;
}
.progress-bar {
background-color: #727e7f;
height: 25px;
padding: 3px;
}
.progress-bar span {
display: inline-block;
height: 100%;
}
.blue span {
background-color: #34495e;
}
.red span {
background-color: #e74c3c;
}
I would recommend a change in markup. Using lists is a lot cleaner than divs/spans.
http://codepen.io/cimmanon/pen/Hikxp
ul.skills {
padding: 0;
}
ul.skills li {
background-color: #727e7f;
position: relative;
line-height: 2em;
margin: 1em 0;
padding: 0 .5em;
position: relative;
color: white;
}
ul.skills li span {
position: relative;
z-index: 10;
font-size: .8em;
}
ul.skills li:after {
position: absolute;
left: 3px;
top: 3px;
bottom: 3px;
content: '';
}
ul.skills li.seven:after {
width: 70%;
}
ul.skills li.eight:after {
width: 80%;
}
ul.skills li.nine:after {
width: 90%;
}
ul.skills li.ten:after {
right: 3px;
}
ul.skills.graphic li:after {
background-color: #34495e;
}
ul.skills.web li:after {
background-color: #e74c3c;
}
<h1>Graphic Skills</h1>
<ul class="skills graphic">
<li class="eight"><span>Illustrator</span></li>
<li class="ten"><span>Photoshop</span></li>
<li class="nine"><span>Indesign</span></li>
</ul>
<h1>Web Development</h1>
<ul class="skills web">
<li class="seven"><span>Illustrator</span></li>
<li class="eight"><span>Photoshop</span></li>
<li class="nine"><span>Indesign</span></li>
</ul>
hi you can try this way if you want
html
<span class="skillEachWrap"> <span class="skills-each">Illustrator</span></span>
<div class="progress-bar blue">
<span style="width: 90%"></span>
</div>
css
.skillEachWrap {
float:left;
position:relative;
}
.skills-each {
font-size: .8em;
position:absolute;
top:7px;
left:10px;
}
working demo hope this help you.....
You can use position:absolute to place the text on top of your progress bar. Then use line-height:25px to center the text vertically within the bar. I also recommend you give you bar a class and not just target it as span since we have multiple children in .progress-bar now.
jsFiddle
HTML
<div class="progress-bar blue">
<span class="bar" style="width: 80%"></span>
<span class="name">Photoshop</span>
</div>
CSS
.progress-bar {
background-color: #727e7f;
height: 25px;
padding: 3px;
position:relative;
}
.progress-bar .bar {
display: inline-block;
height: 100%;
}
.progress-bar.blue .bar {
background-color: #34495e;
}
.progress-bar .name {
color:#FFF;
position:absolute;
left:10px;
line-height:25px;
}